@@ -70,7 +70,10 @@ void php_v8_message_create_from_message(zval *return_value, php_v8_isolate_t *ph
70
70
if (!message->GetLineNumber (context).IsNothing ()) {
71
71
line_number = message->GetLineNumber (context).FromJust ();
72
72
}
73
- zend_update_property_long (this_ce, return_value, ZEND_STRL (" line_number" ), static_cast <zend_long>(line_number));
73
+
74
+ if (v8::Message::kNoLineNumberInfo != line_number) {
75
+ zend_update_property_long (this_ce, return_value, ZEND_STRL (" line_number" ), static_cast <zend_long>(line_number));
76
+ }
74
77
75
78
/* v8::Message::GetStartPosition */
76
79
zend_update_property_long (this_ce, return_value, ZEND_STRL (" start_position" ), static_cast <zend_long>(message->GetStartPosition ()));
@@ -85,15 +88,19 @@ void php_v8_message_create_from_message(zval *return_value, php_v8_isolate_t *ph
85
88
start_column = message->GetStartColumn (context).FromJust ();
86
89
}
87
90
88
- zend_update_property_long (this_ce, return_value, ZEND_STRL (" start_column" ), static_cast <zend_long>(start_column));
91
+ if (v8::Message::kNoColumnInfo != start_column) {
92
+ zend_update_property_long (this_ce, return_value, ZEND_STRL (" start_column" ), static_cast <zend_long>(start_column));
93
+ }
89
94
90
95
/* v8::Message::GetEndColumn */
91
96
/* NOTE: we don't use FromMaybe(v8::Message::kNoColumnInfo) due to static const (https://gcc.gnu.org/wiki/VerboseDiagnostics#missing_static_const_definition)*/
92
97
int end_column = v8::Message::kNoColumnInfo ;
93
98
if (!message->GetEndColumn (context).IsNothing ()) {
94
99
end_column = message->GetEndColumn (context).FromJust ();
95
100
}
96
- zend_update_property_long (this_ce, return_value, ZEND_STRL (" end_column" ), static_cast <zend_long>(end_column));
101
+ if (v8::Message::kNoColumnInfo != end_column) {
102
+ zend_update_property_long (this_ce, return_value, ZEND_STRL (" end_column" ), static_cast <zend_long>(end_column));
103
+ }
97
104
98
105
/* v8::Message::IsSharedCrossOrigin */
99
106
zend_update_property_bool (this_ce, return_value, ZEND_STRL (" is_shared_cross_origin" ), static_cast <zend_bool>(message->IsSharedCrossOrigin ()));
@@ -110,11 +117,11 @@ static PHP_METHOD(Message, __construct) {
110
117
zend_string *resource_name = NULL ;
111
118
zval *stack_trace = NULL ;
112
119
113
- zend_long line_number = static_cast <zend_long>(v8::Message:: kNoLineNumberInfo ) ;
120
+ zend_long line_number = - 1 ;
114
121
zend_long start_position = -1 ;
115
- zend_long end_position = -1 ;
116
- zend_long start_column = static_cast <zend_long>(v8::Message:: kNoColumnInfo ) ;
117
- zend_long end_column = static_cast <zend_long>(v8::Message:: kNoColumnInfo ) ;
122
+ zend_long end_position = -1 ;
123
+ zend_long start_column = - 1 ;
124
+ zend_long end_column = - 1 ;
118
125
119
126
zend_bool is_shared_cross_origin = ' \0 ' ;
120
127
zend_bool is_opaque = ' \0 ' ;
@@ -132,11 +139,21 @@ static PHP_METHOD(Message, __construct) {
132
139
zend_update_property_str (this_ce, getThis (), ZEND_STRL (" resource_name" ), resource_name);
133
140
zend_update_property (this_ce, getThis (), ZEND_STRL (" stack_trace" ), stack_trace);
134
141
135
- zend_update_property_long (this_ce, getThis (), ZEND_STRL (" line_number" ), line_number);
136
- zend_update_property_long (this_ce, getThis (), ZEND_STRL (" start_position" ), start_position);
137
- zend_update_property_long (this_ce, getThis (), ZEND_STRL (" end_position" ), end_position);
138
- zend_update_property_long (this_ce, getThis (), ZEND_STRL (" start_column" ), start_column);
139
- zend_update_property_long (this_ce, getThis (), ZEND_STRL (" end_column" ), end_column);
142
+ if (line_number > 0 ) {
143
+ zend_update_property_long (this_ce, getThis (), ZEND_STRL (" line_number" ), line_number);
144
+ }
145
+ if (start_position >= 0 ) {
146
+ zend_update_property_long (this_ce, getThis (), ZEND_STRL (" start_position" ), start_position);
147
+ }
148
+ if (end_position >= 0 ) {
149
+ zend_update_property_long (this_ce, getThis (), ZEND_STRL (" end_position" ), end_position);
150
+ }
151
+ if (start_column > 0 ) {
152
+ zend_update_property_long (this_ce, getThis (), ZEND_STRL (" start_column" ), start_column);
153
+ }
154
+ if (end_column > 0 ) {
155
+ zend_update_property_long (this_ce, getThis (), ZEND_STRL (" end_column" ), end_column);
156
+ }
140
157
141
158
zend_update_property_bool (this_ce, getThis (), ZEND_STRL (" is_shared_cross_origin" ), is_shared_cross_origin);
142
159
zend_update_property_bool (this_ce, getThis (), ZEND_STRL (" is_opaque" ), is_opaque);
@@ -280,11 +297,11 @@ PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 5)
280
297
ZEND_ARG_OBJ_INFO(0 , script_origin, V8\\ScriptOrigin, 0 )
281
298
ZEND_ARG_TYPE_INFO(0 , resource_name, IS_STRING, 0 )
282
299
ZEND_ARG_OBJ_INFO(0 , stack_trace, V8\\StackTrace, 0 )
283
- ZEND_ARG_TYPE_INFO(0 , line_number, IS_LONG, 0 )
284
- ZEND_ARG_TYPE_INFO(0 , start_position, IS_LONG, 0 )
285
- ZEND_ARG_TYPE_INFO(0 , end_position, IS_LONG, 0 )
286
- ZEND_ARG_TYPE_INFO(0 , start_column, IS_LONG, 0 )
287
- ZEND_ARG_TYPE_INFO(0 , end_column, IS_LONG, 0 )
300
+ ZEND_ARG_TYPE_INFO(0 , line_number, IS_LONG, 1 )
301
+ ZEND_ARG_TYPE_INFO(0 , start_position, IS_LONG, 1 )
302
+ ZEND_ARG_TYPE_INFO(0 , end_position, IS_LONG, 1 )
303
+ ZEND_ARG_TYPE_INFO(0 , start_column, IS_LONG, 1 )
304
+ ZEND_ARG_TYPE_INFO(0 , end_column, IS_LONG, 1 )
288
305
ZEND_ARG_TYPE_INFO(0 , is_shared_cross_origin, _IS_BOOL, 0 )
289
306
ZEND_ARG_TYPE_INFO(0 , is_opaque, _IS_BOOL, 0 )
290
307
ZEND_END_ARG_INFO()
@@ -304,19 +321,19 @@ ZEND_END_ARG_INFO()
304
321
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_getStackTrace, ZEND_RETURN_VALUE, 0 , V8\\StackTrace, 1 )
305
322
ZEND_END_ARG_INFO()
306
323
307
- PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getLineNumber, ZEND_RETURN_VALUE, 0 , IS_LONG, 0 )
324
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getLineNumber, ZEND_RETURN_VALUE, 0 , IS_LONG, 1 )
308
325
ZEND_END_ARG_INFO()
309
326
310
- PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getStartPosition, ZEND_RETURN_VALUE, 0 , IS_LONG, 0 )
327
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getStartPosition, ZEND_RETURN_VALUE, 0 , IS_LONG, 1 )
311
328
ZEND_END_ARG_INFO()
312
329
313
- PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getEndPosition, ZEND_RETURN_VALUE, 0 , IS_LONG, 0 )
330
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getEndPosition, ZEND_RETURN_VALUE, 0 , IS_LONG, 1 )
314
331
ZEND_END_ARG_INFO()
315
332
316
- PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getStartColumn, ZEND_RETURN_VALUE, 0 , IS_LONG, 0 )
333
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getStartColumn, ZEND_RETURN_VALUE, 0 , IS_LONG, 1 )
317
334
ZEND_END_ARG_INFO()
318
335
319
- PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getEndColumn, ZEND_RETURN_VALUE, 0 , IS_LONG, 0 )
336
+ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getEndColumn, ZEND_RETURN_VALUE, 0 , IS_LONG, 1 )
320
337
ZEND_END_ARG_INFO()
321
338
322
339
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_isSharedCrossOrigin, ZEND_RETURN_VALUE, 0 , _IS_BOOL, 0 )
@@ -349,22 +366,18 @@ PHP_MINIT_FUNCTION (php_v8_message) {
349
366
INIT_NS_CLASS_ENTRY (ce, PHP_V8_NS, " Message" , php_v8_message_methods);
350
367
this_ce = zend_register_internal_class (&ce);
351
368
352
- zend_declare_class_constant_long (this_ce, ZEND_STRL (" kNoLineNumberInfo" ), static_cast <zend_long>(v8::Message::kNoLineNumberInfo ));
353
- zend_declare_class_constant_long (this_ce, ZEND_STRL (" kNoColumnInfo" ), static_cast <zend_long>(v8::Message::kNoColumnInfo ));
354
- zend_declare_class_constant_long (this_ce, ZEND_STRL (" kNoScriptIdInfo" ), static_cast <zend_long>(v8::Message::kNoLineNumberInfo ));
355
-
356
- zend_declare_property_string (this_ce, ZEND_STRL (" message" ), " " , ZEND_ACC_PRIVATE);
357
- zend_declare_property_null (this_ce, ZEND_STRL (" script_origin" ), ZEND_ACC_PRIVATE);
358
- zend_declare_property_string (this_ce, ZEND_STRL (" source_line" ), " " , ZEND_ACC_PRIVATE);
369
+ zend_declare_property_string (this_ce, ZEND_STRL (" message" ), " " , ZEND_ACC_PRIVATE);
370
+ zend_declare_property_null (this_ce, ZEND_STRL (" script_origin" ), ZEND_ACC_PRIVATE);
371
+ zend_declare_property_string (this_ce, ZEND_STRL (" source_line" ), " " , ZEND_ACC_PRIVATE);
359
372
zend_declare_property_string (this_ce, ZEND_STRL (" resource_name" ), " " , ZEND_ACC_PRIVATE);
360
- zend_declare_property_null (this_ce, ZEND_STRL (" stack_trace" ), ZEND_ACC_PRIVATE);
373
+ zend_declare_property_null (this_ce, ZEND_STRL (" stack_trace" ), ZEND_ACC_PRIVATE);
361
374
362
- zend_declare_property_long (this_ce, ZEND_STRL (" line_number" ), static_cast <zend_long>(v8::Message:: kNoLineNumberInfo ), ZEND_ACC_PRIVATE);
363
- zend_declare_property_long (this_ce, ZEND_STRL (" start_position" ), - 1 , ZEND_ACC_PRIVATE);
364
- zend_declare_property_long (this_ce, ZEND_STRL (" end_position" ), - 1 , ZEND_ACC_PRIVATE);
375
+ zend_declare_property_null (this_ce, ZEND_STRL (" line_number" ), ZEND_ACC_PRIVATE);
376
+ zend_declare_property_null (this_ce, ZEND_STRL (" start_position" ), ZEND_ACC_PRIVATE);
377
+ zend_declare_property_null (this_ce, ZEND_STRL (" end_position" ), ZEND_ACC_PRIVATE);
365
378
366
- zend_declare_property_long (this_ce, ZEND_STRL (" start_column" ), static_cast <zend_long>(v8::Message:: kNoColumnInfo ), ZEND_ACC_PRIVATE);
367
- zend_declare_property_long (this_ce, ZEND_STRL (" end_column" ), static_cast <zend_long>(v8::Message:: kNoColumnInfo ), ZEND_ACC_PRIVATE);
379
+ zend_declare_property_null (this_ce, ZEND_STRL (" start_column" ), ZEND_ACC_PRIVATE);
380
+ zend_declare_property_null (this_ce, ZEND_STRL (" end_column" ), ZEND_ACC_PRIVATE);
368
381
369
382
zend_declare_property_bool (this_ce, ZEND_STRL (" is_shared_cross_origin" ), static_cast <zend_bool>(false ), ZEND_ACC_PRIVATE);
370
383
zend_declare_property_bool (this_ce, ZEND_STRL (" is_opaque" ), static_cast <zend_bool>(false ), ZEND_ACC_PRIVATE);
0 commit comments