2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2021, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
18 #include "ext/standard/info.h"
20 #include "Zend/zend_enum.h"
21 #include "Zend/zend_exceptions.h"
22 #include "Zend/zend_closures.h"
23 #include "Zend/zend_interfaces.h"
24 #include "Zend/zend_smart_str.h"
26 #include "ext/date/php_date.h"
27 #include "ext/spl/spl_exceptions.h"
30 #include "ion_private.h"
32 static ZEND_METHOD(ion_Symbol_ImportLocation
, __construct
)
34 php_ion_symbol_iloc
*obj
= php_ion_obj(symbol_iloc
, Z_OBJ_P(ZEND_THIS
));
38 ZEND_PARSE_PARAMETERS_START(2, 2)
39 Z_PARAM_STR(obj
->name
)
40 Z_PARAM_LONG(location
)
41 ZEND_PARSE_PARAMETERS_END();
43 obj
->loc
.location
= (SID
) location
;
44 php_ion_symbol_iloc_ctor(obj
);
46 static ZEND_METHOD(ion_Symbol
, __construct
)
48 php_ion_symbol
*obj
= php_ion_obj(symbol
, Z_OBJ_P(ZEND_THIS
));
52 ZEND_PARSE_PARAMETERS_START(0, 3)
54 Z_PARAM_STR_OR_NULL(obj
->value
)
56 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->iloc
, ce_Symbol_ImportLocation
)
57 ZEND_PARSE_PARAMETERS_END();
59 obj
->sym
.sid
= (SID
) sid
;
60 php_ion_symbol_ctor(obj
);
62 static ZEND_METHOD(ion_Symbol
, equals
)
64 php_ion_symbol
*sym
= php_ion_obj(symbol
, Z_OBJ_P(ZEND_THIS
));
67 zend_object
*other_obj
;
68 ZEND_PARSE_PARAMETERS_START(1, 1)
69 Z_PARAM_OBJ_OF_CLASS(other_obj
, ce_Symbol
)
70 ZEND_PARSE_PARAMETERS_END();
73 iERR err
= ion_symbol_is_equal(
75 &php_ion_obj(symbol
, other_obj
)->sym
, &eq
);
79 static ZEND_METHOD(ion_Symbol
, __toString
)
81 php_ion_symbol
*sym
= php_ion_obj(symbol
, Z_OBJ_P(ZEND_THIS
));
84 ZEND_PARSE_PARAMETERS_NONE();
87 RETURN_EMPTY_STRING();
89 RETURN_STR_COPY(sym
->value
);
91 static ZEND_METHOD(ion_Symbol_Enum
, toSymbol
)
93 ZEND_PARSE_PARAMETERS_NONE();
95 zval
*zc
= zend_enum_fetch_case_name(Z_OBJ_P(ZEND_THIS
));
98 zval
*zsym
= php_ion_global_symbol_fetch_by_enum(Z_STR_P(zc
));
100 RETVAL_ZVAL(zsym
, 1, 0);
102 static ZEND_METHOD(ion_Symbol_Enum
, toSID
)
104 ZEND_PARSE_PARAMETERS_NONE();
106 zval
*zc
= zend_enum_fetch_case_name(Z_OBJ_P(ZEND_THIS
));
109 zval
*zsym
= php_ion_global_symbol_fetch_by_enum(Z_STR_P(zc
));
113 RETVAL_ZVAL(zend_read_property(Z_OBJCE_P(zsym
), Z_OBJ_P(zsym
), ZEND_STRL("sid"), 0, &tmp
), 1, 0);
115 static ZEND_METHOD(ion_Symbol_Enum
, toString
)
117 ZEND_PARSE_PARAMETERS_NONE();
119 zval
*zc
= zend_enum_fetch_case_name(Z_OBJ_P(ZEND_THIS
));
122 zval
*zsym
= php_ion_global_symbol_fetch_by_enum(Z_STR_P(zc
));
126 RETVAL_ZVAL(zend_read_property(Z_OBJCE_P(zsym
), Z_OBJ_P(zsym
), ZEND_STRL("value"), 0, &tmp
), 1, 0);
128 static ZEND_FUNCTION(ion_Symbol_Table_System
)
130 ZEND_PARSE_PARAMETERS_NONE();
132 object_init_ex(return_value
, ce_Symbol_Table_Shared
);
133 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(return_value
));
134 ION_CHECK(ion_symbol_table_get_system_table(&obj
->tab
, 1));
135 php_ion_symbol_table_ctor(obj
);
136 ion_symbol_table_lock(obj
->tab
);
138 static ZEND_FUNCTION(ion_Symbol_Table_PHP
)
140 ZEND_PARSE_PARAMETERS_NONE();
142 object_init_ex(return_value
, ce_Symbol_Table_Shared
);
143 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(return_value
));
144 obj
->tab
= g_sym_tab_php
;
145 php_ion_symbol_table_ctor(obj
);
146 ion_symbol_table_lock(obj
->tab
);
148 static ZEND_METHOD(ion_Symbol_Table_Local
, __construct
)
150 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
153 ZEND_PARSE_PARAMETERS_NONE();
155 ION_CHECK(ion_symbol_table_open_with_type(&obj
->tab
, NULL
, ist_LOCAL
));
156 obj
->dtor
= ion_symbol_table_close
;
159 static ZEND_METHOD(ion_Symbol_Table_Local
, import
)
161 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
164 zend_object
*zo_import
;
165 ZEND_PARSE_PARAMETERS_START(1, 1)
166 Z_PARAM_OBJ_OF_CLASS(zo_import
, ce_Symbol_Table
);
167 ZEND_PARSE_PARAMETERS_END();
169 php_ion_symbol_table_import(obj
, php_ion_obj(symbol_table
, zo_import
));
171 static ZEND_METHOD(ion_Symbol_Table_Shared
, __construct
)
173 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
177 zend_long version
= 1;
178 HashTable
*ht_sym
= NULL
;
179 ZEND_PARSE_PARAMETERS_START(1, 3)
182 Z_PARAM_LONG(version
)
183 Z_PARAM_ARRAY_HT_OR_NULL(ht_sym
)
184 ZEND_PARSE_PARAMETERS_END();
186 ION_CHECK(ion_symbol_table_open_with_type(&obj
->tab
, NULL
, ist_SHARED
));
187 obj
->dtor
= ion_symbol_table_close
;
190 ION_CHECK(ion_symbol_table_set_name(obj
->tab
, ion_string_from_zend(&is
, zname
)));
191 ION_CHECK(ion_symbol_table_set_version(obj
->tab
, version
));
193 php_ion_symbol_table_ctor(obj
);
196 if (ht_sym
) ZEND_HASH_FOREACH_VAL(ht_sym
, zsym
)
198 zend_string
*str
= zval_get_string(zsym
);
204 ION_CHECK(ion_symbol_table_add_symbol(obj
->tab
, ion_string_from_zend(&istr
, str
), NULL
), zend_string_release(str
));
205 zend_string_release(str
);
207 ZEND_HASH_FOREACH_END();
209 static ZEND_METHOD(ion_Symbol_Table
, getMaxId
)
211 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
214 ZEND_PARSE_PARAMETERS_NONE();
217 ION_CHECK(ion_symbol_table_get_max_sid(obj
->tab
, &max_sid
));
218 RETURN_LONG(max_sid
);
220 static ZEND_METHOD(ion_Symbol_Table
, add
)
222 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
225 zend_object
*zo_sym
= NULL
;
226 zend_string
*zs_sym
= NULL
;
227 ZEND_PARSE_PARAMETERS_START(1, 1)
228 Z_PARAM_OBJ_OF_CLASS_OR_STR(zo_sym
, ce_Symbol
, zs_sym
)
229 ZEND_PARSE_PARAMETERS_END();
233 ZVAL_OBJ(&z_sym
, zo_sym
);
234 zs_sym
= zval_get_string(&z_sym
);
239 ION_CHECK(ion_symbol_table_add_symbol(obj
->tab
, ion_string_from_zend(&is
, zs_sym
), &sid
),
241 zend_string_release(zs_sym
);
244 zend_string_release(zs_sym
);
248 static ZEND_METHOD(ion_Symbol_Table
, find
)
250 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
254 zend_string
*zstring
= NULL
;
255 ZEND_PARSE_PARAMETERS_START(1, 1)
256 Z_PARAM_STR_OR_LONG(zstring
, zsid
)
257 ZEND_PARSE_PARAMETERS_END();
262 ION_CHECK(ion_symbol_table_find_by_name(obj
->tab
, ion_string_from_zend(&is
, zstring
), &sid
));
266 ION_CHECK(ion_symbol_table_get_symbol(obj
->tab
, zsid
, &sym
));
268 php_ion_symbol_table_symbol_zval(obj
, sym
, return_value
);
271 static ZEND_METHOD(ion_Symbol_Table
, findLocal
)
273 php_ion_symbol_table
*obj
= php_ion_obj(symbol_table
, Z_OBJ_P(ZEND_THIS
));
277 zend_string
*zstring
;
278 ZEND_PARSE_PARAMETERS_START(1, 1)
279 Z_PARAM_STR_OR_LONG(zstring
, zsid
)
280 ZEND_PARSE_PARAMETERS_END();
285 ION_CHECK(ion_symbol_table_find_by_name(obj
->tab
, ion_string_from_zend(&is
, zstring
), &sid
));
289 ION_CHECK(ion_symbol_table_get_local_symbol(obj
->tab
, zsid
, &sym
));
291 php_ion_symbol_table_symbol_zval(obj
, sym
, return_value
);
294 static ZEND_METHOD(ion_Catalog
, __construct
)
296 php_ion_catalog
*obj
= php_ion_obj(catalog
, Z_OBJ_P(ZEND_THIS
));
299 ZEND_PARSE_PARAMETERS_NONE();
301 php_ion_catalog_ctor(obj
);
303 static ZEND_METHOD(ion_Catalog
, count
)
305 php_ion_catalog
*obj
= php_ion_obj(catalog
, Z_OBJ_P(ZEND_THIS
));
308 ZEND_PARSE_PARAMETERS_NONE();
311 ION_CHECK(ion_catalog_get_symbol_table_count(obj
->cat
, &c
));
314 static ZEND_METHOD(ion_Catalog
, add
)
316 php_ion_catalog
*obj
= php_ion_obj(catalog
, Z_OBJ_P(ZEND_THIS
));
319 zend_object
*zo_symtab
;
320 ZEND_PARSE_PARAMETERS_START(1, 1)
321 Z_PARAM_OBJ_OF_CLASS(zo_symtab
, ce_Symbol_Table
)
322 ZEND_PARSE_PARAMETERS_END();
324 php_ion_symbol_table
*o_symtab
= php_ion_obj(symbol_table
, zo_symtab
);
325 php_ion_catalog_add_symbol_table(obj
, o_symtab
);
328 static ZEND_METHOD(ion_Catalog
, remove
)
330 php_ion_catalog
*obj
= php_ion_obj(catalog
, Z_OBJ_P(ZEND_THIS
));
333 zend_object
*zo_symtab
= NULL
;
334 zend_string
*zs_symtab
= NULL
;
335 ZEND_PARSE_PARAMETERS_START(1, 1)
336 Z_PARAM_OBJ_OF_CLASS_OR_STR(zo_symtab
, ce_Symbol_Table
, zs_symtab
)
337 ZEND_PARSE_PARAMETERS_END();
342 zval
*ztabs
= zend_read_property(obj
->std
.ce
, &obj
->std
, ZEND_STRL("symbolTables"), 0, &tmp
);
346 zend_ulong idx
= (uintptr_t) &zo_symtab
->gc
;
347 RETVAL_BOOL(SUCCESS
== zend_hash_index_del(Z_ARRVAL_P(ztabs
), idx
));
348 ION_CHECK(ion_catalog_release_symbol_table(obj
->cat
, php_ion_obj(symbol_table
, zo_symtab
)->tab
));
350 bool deleted
= false;
351 ION_SYMBOL_TABLE
*tab
;
353 ion_string_from_zend(&is
, zs_symtab
);
356 ION_CHECK(ion_catalog_find_best_match(obj
->cat
, &is
, 0, &tab
));
358 ION_CHECK(ion_catalog_release_symbol_table(obj
->cat
, tab
));
362 RETVAL_BOOL(deleted
);
366 static ZEND_METHOD(ion_Catalog
, find
)
368 php_ion_catalog
*obj
= php_ion_obj(catalog
, Z_OBJ_P(ZEND_THIS
));
371 zend_long zversion
= 0;
373 ZEND_PARSE_PARAMETERS_START(1, 2)
376 Z_PARAM_LONG(zversion
)
377 ZEND_PARSE_PARAMETERS_END();
380 ION_SYMBOL_TABLE
*tab_ptr
= NULL
;
381 ION_CHECK(ion_catalog_find_symbol_table(obj
->cat
, ion_string_from_zend(&is
, zname
), zversion
, &tab_ptr
));
383 php_ion_catalog_symbol_table_zval(obj
, tab_ptr
, return_value
);
386 static ZEND_METHOD(ion_Catalog
, findBest
)
388 php_ion_catalog
*obj
= php_ion_obj(catalog
, Z_OBJ_P(ZEND_THIS
));
391 zend_long zversion
= 0;
393 ZEND_PARSE_PARAMETERS_START(1, 2)
396 Z_PARAM_LONG(zversion
)
397 ZEND_PARSE_PARAMETERS_END();
400 ION_SYMBOL_TABLE
*tab_ptr
= NULL
;
401 ION_CHECK(ion_catalog_find_best_match(obj
->cat
, ion_string_from_zend(&is
, zname
), zversion
, &tab_ptr
));
403 php_ion_catalog_symbol_table_zval(obj
, tab_ptr
, return_value
);
406 static ZEND_METHOD(ion_Timestamp
, __construct
)
408 php_ion_timestamp
*obj
= php_ion_obj(timestamp
, Z_OBJ_P(ZEND_THIS
));
412 zend_object
*precision_obj
= NULL
, *format_obj
= NULL
;
413 zend_string
*fmt
= NULL
, *dt
= NULL
;
415 ZEND_PARSE_PARAMETERS_START(1, 4)
416 Z_PARAM_OBJ_OF_CLASS_OR_LONG(precision_obj
, ce_Timestamp_Precision
, precision
)
418 Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(format_obj
, ce_Timestamp_Format
, fmt
)
419 Z_PARAM_STR_OR_NULL(dt
)
421 ZEND_PARSE_PARAMETERS_END();
424 precision
= Z_LVAL_P(zend_enum_fetch_case_value(precision_obj
));
427 fmt
= Z_STR_P(zend_enum_fetch_case_value(format_obj
));
429 php_ion_timestamp_ctor(obj
, precision
, fmt
, dt
, tz
);
431 static ZEND_METHOD(ion_Timestamp
, __toString
)
433 php_ion_timestamp
*obj
= php_ion_obj(timestamp
, Z_OBJ_P(ZEND_THIS
));
436 ZEND_PARSE_PARAMETERS_NONE();
440 zend_call_method_with_1_params(&obj
->std
, obj
->std
.ce
, NULL
, "format", return_value
,
441 zend_read_property(obj
->std
.ce
, &obj
->std
, ZEND_STRL("format"), 0, &fmt
));
443 static ZEND_METHOD(ion_Decimal_Context
, __construct
)
445 php_ion_decimal_ctx
*obj
= php_ion_obj(decimal_ctx
, Z_OBJ_P(ZEND_THIS
));
449 zend_object
*o_round
= NULL
;
450 zend_long digits
, emax
, emin
, round
;
451 ZEND_PARSE_PARAMETERS_START(5, 5)
455 Z_PARAM_OBJ_OF_CLASS_OR_LONG(o_round
, ce_Decimal_Context_Rounding
, round
)
457 ZEND_PARSE_PARAMETERS_END();
460 round
= Z_LVAL_P(zend_enum_fetch_case_value(o_round
));
462 php_ion_decimal_ctx_init(&obj
->ctx
, digits
, emax
, emin
, round
, clamp
); // NOLINT(cppcoreguidelines-narrowing-conversions)
463 php_ion_decimal_ctx_ctor(obj
, o_round
);
465 static inline void make_decimal_ctx(INTERNAL_FUNCTION_PARAMETERS
, int kind
)
467 ZEND_PARSE_PARAMETERS_NONE();
469 object_init_ex(return_value
, ce_Decimal_Context
);
470 php_ion_decimal_ctx
*obj
= php_ion_obj(decimal_ctx
, Z_OBJ_P(return_value
));
471 decContextDefault(&obj
->ctx
, kind
);
472 php_ion_decimal_ctx_ctor(obj
, NULL
);
474 static ZEND_METHOD(ion_Decimal_Context
, Dec32
)
476 make_decimal_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU
, DEC_INIT_DECIMAL32
);
478 static ZEND_METHOD(ion_Decimal_Context
, Dec64
)
480 make_decimal_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU
, DEC_INIT_DECIMAL64
);
482 static ZEND_METHOD(ion_Decimal_Context
, Dec128
)
484 make_decimal_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU
, DEC_INIT_DECIMAL128
);
486 static ZEND_METHOD(ion_Decimal_Context
, DecMax
)
488 zend_object
*o_round
= NULL
;
489 zend_long round
= DEC_ROUND_HALF_EVEN
;
490 ZEND_PARSE_PARAMETERS_START(0, 1)
492 Z_PARAM_OBJ_OF_CLASS_OR_LONG(o_round
, ce_Decimal_Context_Rounding
, round
)
493 ZEND_PARSE_PARAMETERS_END();
496 round
= Z_LVAL_P(zend_enum_fetch_case_value(o_round
));
498 object_init_ex(return_value
, ce_Decimal_Context
);
499 php_ion_decimal_ctx
*obj
= php_ion_obj(decimal_ctx
, Z_OBJ_P(return_value
));
500 php_ion_decimal_ctx_init_max(&obj
->ctx
, round
);
501 php_ion_decimal_ctx_ctor(obj
, o_round
);
503 static ZEND_METHOD(ion_Decimal
, __construct
)
505 php_ion_decimal
*obj
= php_ion_obj(decimal
, Z_OBJ_P(ZEND_THIS
));
510 ZEND_PARSE_PARAMETERS_START(1, 2)
511 Z_PARAM_STR_OR_LONG(zstr
, num
)
513 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->ctx
, ce_Decimal_Context
)
514 ZEND_PARSE_PARAMETERS_END();
520 object_init_ex(&zdc
, ce_Decimal_Context
);
521 obj
->ctx
= Z_OBJ(zdc
);
522 php_ion_decimal_ctx_ctor(php_ion_obj(decimal_ctx
, obj
->ctx
), NULL
);
525 decContext
*ctx
= &php_ion_obj(decimal_ctx
, obj
->ctx
)->ctx
;
528 ION_CHECK(ion_decimal_from_string(&obj
->dec
, zstr
->val
, ctx
), OBJ_RELEASE(obj
->ctx
));
530 php_ion_decimal_from_zend_long(&obj
->dec
, ctx
, num
);
533 php_ion_decimal_ctor(obj
);
534 OBJ_RELEASE(obj
->ctx
);
536 static ZEND_METHOD(ion_Decimal
, equals
)
538 php_ion_decimal
*obj
= php_ion_obj(decimal
, Z_OBJ_P(ZEND_THIS
));
541 zend_object
*dec_obj
;
542 ZEND_PARSE_PARAMETERS_START(1, 1)
543 Z_PARAM_OBJ_OF_CLASS(dec_obj
, ce_Decimal
)
544 ZEND_PARSE_PARAMETERS_END();
547 ION_CHECK(ion_decimal_equals(&obj
->dec
, &php_ion_obj(decimal
, dec_obj
)->dec
,
548 obj
->ctx
? &php_ion_obj(decimal_ctx
, obj
->ctx
)->ctx
: NULL
, &is
));
551 static ZEND_METHOD(ion_Decimal
, __toString
)
553 php_ion_decimal
*obj
= php_ion_obj(decimal
, Z_OBJ_P(ZEND_THIS
));
556 ZEND_PARSE_PARAMETERS_NONE();
558 RETURN_STR(php_ion_decimal_to_string(&obj
->dec
));
560 static ZEND_METHOD(ion_Decimal
, toInt
)
562 php_ion_decimal
*obj
= php_ion_obj(decimal
, Z_OBJ_P(ZEND_THIS
));
565 ZEND_PARSE_PARAMETERS_NONE();
568 php_ion_decimal_to_zend_long(&obj
->dec
, &php_ion_obj(decimal_ctx
, obj
->ctx
)->ctx
, &l
);
571 static ZEND_METHOD(ion_Decimal
, isInt
)
573 php_ion_decimal
*obj
= php_ion_obj(decimal
, Z_OBJ_P(ZEND_THIS
));
576 ZEND_PARSE_PARAMETERS_NONE();
578 RETURN_BOOL(ion_decimal_is_integer(&obj
->dec
));
580 static ZEND_METHOD(ion_LOB
, __construct
)
583 zend_object
*type
= NULL
;
584 ZEND_PARSE_PARAMETERS_START(1, 2)
587 Z_PARAM_OBJ_OF_CLASS(type
, ce_Type
)
588 ZEND_PARSE_PARAMETERS_END();
591 type
= zend_enum_get_case_cstr(ce_Type
, "CLob");
593 update_property_obj(Z_OBJ_P(ZEND_THIS
), ZEND_STRL("type"), type
);
594 zend_update_property_str(Z_OBJCE_P(ZEND_THIS
), Z_OBJ_P(ZEND_THIS
), ZEND_STRL("value"), value
);
596 static ZEND_METHOD(ion_Reader_Options
, __construct
)
598 php_ion_reader_options
*opt
= php_ion_obj(reader_options
, Z_OBJ_P(ZEND_THIS
));
599 zend_bool ret_sys_val
= false, skip_validation
= false;
600 zend_long max_depth
= 10, max_ann
= 10, ann_buf_siz
= 0x4000, tmp_buf_siz
= 0x4000;
604 ZEND_PARSE_PARAMETERS_START(0, 9)
606 // public readonly ?\ion\Catalog $catalog = null,
607 Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt
->cat
, ce_Catalog
)
608 // public readonly ?\ion\Decimal\Context $decimalContext = null,
609 Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt
->dec_ctx
, ce_Decimal_Context
)
610 // public readonly ?\Closure $onContextChange = null,
611 Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt
->cb
, zend_ce_closure
);
612 // public readonly bool $returnSystemValues = false,
613 Z_PARAM_BOOL(ret_sys_val
)
614 // public readonly int $maxContainerDepth = 10,
615 Z_PARAM_LONG(max_depth
)
616 // public readonly int $maxAnnotations = 10,
617 Z_PARAM_LONG(max_ann
)
618 // public readonly int $annotationBufferSize = 0x4000,
619 Z_PARAM_LONG(ann_buf_siz
)
620 // public readonly int $tempBufferSize = 0x4000,
621 Z_PARAM_LONG(tmp_buf_siz
)
622 // public readonly bool $skipCharacterValidation = false,
623 Z_PARAM_BOOL(skip_validation
)
624 ZEND_PARSE_PARAMETERS_END();
628 ZVAL_OBJ(&zcb
, opt
->cb
);
629 zend_fcall_info_init(&zcb
, 0, &opt
->ccn
.fci
, &opt
->ccn
.fcc
, NULL
, NULL
);
630 opt
->opt
.context_change_notifier
.context
= &opt
->ccn
;
631 update_property_obj(&opt
->std
, ZEND_STRL("onContextChange"), opt
->cb
);
633 zend_update_property_null(NULL
, &opt
->std
, ZEND_STRL("onContextChange"));
636 update_property_obj(&opt
->std
, ZEND_STRL("catalog"), opt
->cat
);
637 opt
->opt
.pcatalog
= php_ion_obj(catalog
, opt
->cat
)->cat
;
639 zend_update_property_null(NULL
, &opt
->std
, ZEND_STRL("catalog"));
642 update_property_obj(&opt
->std
, ZEND_STRL("decimalContext"), opt
->dec_ctx
);
643 opt
->opt
.decimal_context
= &php_ion_obj(decimal_ctx
, opt
->dec_ctx
)->ctx
;
645 zend_update_property_null(NULL
, &opt
->std
, ZEND_STRL("decimalContext"));
647 zend_update_property_bool(opt
->std
.ce
, &opt
->std
, ZEND_STRL("returnSystemValues"),
648 opt
->opt
.return_system_values
= ret_sys_val
);
649 zend_update_property_long(opt
->std
.ce
, &opt
->std
, ZEND_STRL("maxContainerDepth"),
650 opt
->opt
.max_container_depth
= (SIZE
) max_depth
);
651 zend_update_property_long(opt
->std
.ce
, &opt
->std
, ZEND_STRL("maxAnnotations"),
652 opt
->opt
.max_annotation_count
= (SIZE
) max_ann
);
653 zend_update_property_long(opt
->std
.ce
, &opt
->std
, ZEND_STRL("annotationBufferSize"),
654 opt
->opt
.max_annotation_buffered
= (SIZE
) ann_buf_siz
);
655 zend_update_property_long(opt
->std
.ce
, &opt
->std
, ZEND_STRL("tempBufferSize"),
656 opt
->opt
.chunk_threshold
= opt
->opt
.user_value_threshold
= opt
->opt
.symbol_threshold
= (SIZE
) tmp_buf_siz
);
657 zend_update_property_long(opt
->std
.ce
, &opt
->std
, ZEND_STRL("skipCharacterValidation"),
658 opt
->opt
.skip_character_validation
= (SIZE
) skip_validation
);
660 static ZEND_METHOD(ion_Reader_Reader
, hasChildren
)
662 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
665 ZEND_PARSE_PARAMETERS_NONE();
668 ION_CHECK(ion_reader_get_type(obj
->reader
, &t
));
669 switch (ION_TYPE_INT(t
)) {
680 static ZEND_METHOD(ion_Reader_Reader
, getChildren
)
682 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
685 ZEND_PARSE_PARAMETERS_NONE();
687 ION_CHECK(ion_reader_step_in(obj
->reader
));
689 RETURN_ZVAL(ZEND_THIS
, 1, 0);
691 static ZEND_METHOD(ion_Reader_Reader
, rewind
)
693 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
696 ZEND_PARSE_PARAMETERS_NONE();
698 ION_CHECK(ion_reader_next(obj
->reader
, &obj
->state
));
700 static ZEND_METHOD(ion_Reader_Reader
, next
)
702 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
705 ZEND_PARSE_PARAMETERS_NONE();
707 if (obj
->state
== tid_EOF
) {
709 ION_CHECK(ion_reader_get_depth(obj
->reader
, &depth
));
711 ION_CHECK(ion_reader_step_out(obj
->reader
));
714 ION_CHECK(ion_reader_next(obj
->reader
, &obj
->state
));
716 static ZEND_METHOD(ion_Reader_Reader
, valid
)
718 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
721 ZEND_PARSE_PARAMETERS_NONE();
722 RETURN_BOOL(obj
->state
!= tid_none
&& obj
->state
!= tid_EOF
);
724 static ZEND_METHOD(ion_Reader_Reader
, key
)
726 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
729 ZEND_PARSE_PARAMETERS_NONE();
730 RETURN_IONTYPE(obj
->state
);
732 static ZEND_METHOD(ion_Reader_Reader
, current
)
734 ZEND_PARSE_PARAMETERS_NONE();
735 RETURN_ZVAL(ZEND_THIS
, 1, 0);
737 static ZEND_METHOD(ion_Reader_Reader
, getType
)
739 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
742 ZEND_PARSE_PARAMETERS_NONE();
745 ION_CHECK(ion_reader_get_type(obj
->reader
, &typ
));
748 static ZEND_METHOD(ion_Reader_Reader
, hasAnnotations
)
750 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
753 ZEND_PARSE_PARAMETERS_NONE();
756 ION_CHECK(ion_reader_has_any_annotations(obj
->reader
, &has
));
759 static ZEND_METHOD(ion_Reader_Reader
, hasAnnotation
)
761 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
764 zend_string
*ann_zstr
;
765 ZEND_PARSE_PARAMETERS_START(1, 1);
766 Z_PARAM_STR(ann_zstr
);
767 ZEND_PARSE_PARAMETERS_END();
771 ION_CHECK(ion_reader_has_annotation(obj
->reader
, ion_string_from_zend(&ann_istr
, ann_zstr
), &has
));
774 static ZEND_METHOD(ion_Reader_Reader
, isNull
)
776 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
779 ZEND_PARSE_PARAMETERS_NONE();
782 ION_CHECK(ion_reader_is_null(obj
->reader
, &is
));
785 static ZEND_METHOD(ion_Reader_Reader
, isInStruct
)
787 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
790 ZEND_PARSE_PARAMETERS_NONE();
793 ION_CHECK(ion_reader_is_in_struct(obj
->reader
, &is
));
796 static ZEND_METHOD(ion_Reader_Reader
, getFieldName
)
798 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
801 ZEND_PARSE_PARAMETERS_NONE();
804 ION_CHECK(ion_reader_get_field_name(obj
->reader
, &name
));
805 RETURN_STRINGL((char *) name
.value
, name
.length
);
807 static ZEND_METHOD(ion_Reader_Reader
, getFieldNameSymbol
)
809 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
812 ZEND_PARSE_PARAMETERS_NONE();
815 ION_CHECK(ion_reader_get_field_name_symbol(obj
->reader
, &sym_ptr
));
817 php_ion_symbol_zval(sym_ptr
, return_value
);
819 static ZEND_METHOD(ion_Reader_Reader
, getAnnotations
)
821 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
824 ZEND_PARSE_PARAMETERS_NONE();
828 max
= php_ion_obj(reader_options
, obj
->opt
)->opt
.max_annotation_count
;
832 ION_STRING
*ptr
= ecalloc(sizeof(*ptr
), max
);
833 iERR err
= ion_reader_get_annotations(obj
->reader
, ptr
, max
, &count
);
835 array_init_size(return_value
, count
);
836 for (int32_t i
= 0; i
< count
; ++i
) {
837 add_next_index_str(return_value
, zend_string_from_ion(&ptr
[i
]));
843 static ZEND_METHOD(ion_Reader_Reader
, getAnnotationSymbols
)
845 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
848 ZEND_PARSE_PARAMETERS_NONE();
852 max
= php_ion_obj(reader_options
, obj
->opt
)->opt
.max_annotation_count
;
856 ION_SYMBOL
*ptr
= ecalloc(sizeof(*ptr
), max
);
857 iERR err
= ion_reader_get_annotation_symbols(obj
->reader
, ptr
, max
, &count
);
859 array_init_size(return_value
, count
);
860 for (int32_t i
= 0; i
< count
; ++i
) {
862 php_ion_symbol_zval(&ptr
[i
], &zsym
);
863 add_next_index_zval(return_value
, &zsym
);
869 static ZEND_METHOD(ion_Reader_Reader
, countAnnotations
)
871 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
874 ZEND_PARSE_PARAMETERS_NONE();
877 ION_CHECK(ion_reader_get_annotation_count(obj
->reader
, &sz
));
880 static ZEND_METHOD(ion_Reader_Reader
, getAnnotation
)
882 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
886 ZEND_PARSE_PARAMETERS_START(1, 1)
888 ZEND_PARSE_PARAMETERS_END();
891 ION_CHECK(ion_reader_get_an_annotation(obj
->reader
, idx
, &ann
));
892 RETURN_STRINGL((char *) ann
.value
, ann
.length
);
894 static ZEND_METHOD(ion_Reader_Reader
, getAnnotationSymbol
)
896 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
900 ZEND_PARSE_PARAMETERS_START(1, 1)
902 ZEND_PARSE_PARAMETERS_END();
905 ION_CHECK(ion_reader_get_an_annotation_symbol(obj
->reader
, idx
, &sym
));
906 php_ion_symbol_zval(&sym
, return_value
);
908 static ZEND_METHOD(ion_Reader_Reader
, readNull
)
910 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
913 ZEND_PARSE_PARAMETERS_NONE();
916 ION_CHECK(ion_reader_read_null(obj
->reader
, &typ
));
919 static ZEND_METHOD(ion_Reader_Reader
, readBool
)
921 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
924 ZEND_PARSE_PARAMETERS_NONE();
927 ION_CHECK(ion_reader_read_bool(obj
->reader
, &b
));
930 static ZEND_METHOD(ion_Reader_Reader
, readInt
)
932 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
935 ZEND_PARSE_PARAMETERS_NONE();
937 php_ion_reader_read_int(obj
->reader
, return_value
);
939 static ZEND_METHOD(ion_Reader_Reader
, readFloat
)
941 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
944 ZEND_PARSE_PARAMETERS_NONE();
947 ION_CHECK(ion_reader_read_double(obj
->reader
, &dval
));
950 static ZEND_METHOD(ion_Reader_Reader
, readDecimal
)
952 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
955 ZEND_PARSE_PARAMETERS_NONE();
957 object_init_ex(return_value
, ce_Decimal
);
958 php_ion_decimal
*dec
= php_ion_obj(decimal
, Z_OBJ_P(return_value
));
959 ION_CHECK(ion_reader_read_ion_decimal(obj
->reader
, &dec
->dec
));
960 php_ion_decimal_ctor(dec
);
962 static ZEND_METHOD(ion_Reader_Reader
, readTimestamp
)
964 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
967 ZEND_PARSE_PARAMETERS_NONE();
969 php_ion_reader_read_timestamp(obj
->reader
, obj
->opt
? &php_ion_obj(reader_options
, obj
->opt
)->opt
: NULL
, return_value
);
971 static ZEND_METHOD(ion_Reader_Reader
, readSymbol
)
973 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
976 ZEND_PARSE_PARAMETERS_NONE();
979 ION_CHECK(ion_reader_read_ion_symbol(obj
->reader
, &sym
));
980 php_ion_symbol_zval(&sym
, return_value
);
982 static ZEND_METHOD(ion_Reader_Reader
, readString
)
984 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
987 ZEND_PARSE_PARAMETERS_NONE();
990 ION_CHECK(ion_reader_read_string(obj
->reader
, &str
));
991 RETURN_STRINGL((char *) str
.value
, str
.length
);
994 typedef iERR (*read_part_fn
)(ION_READER
*, BYTE
*, SIZE
, SIZE
*);
995 static void read_part(INTERNAL_FUNCTION_PARAMETERS
, read_part_fn fn
)
997 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1002 zend_long len
= 0x1000;
1003 ZEND_PARSE_PARAMETERS_START(1, 1)
1007 ZEND_PARSE_PARAMETERS_END();
1011 if (Z_TYPE_P(ref
) == IS_STRING
&& Z_STRLEN_P(ref
) == len
) {
1013 zstr
= Z_STR_P(ref
);
1016 zstr
= zend_string_alloc(len
, 0);
1020 ION_CHECK(fn(obj
->reader
, (BYTE
*) zstr
->val
, zstr
->len
, &read
), goto fail
);
1022 if (read
< zstr
->len
) {
1023 zstr
= zend_string_truncate(zstr
, read
, 0);
1025 ZVAL_STR(ref
, zstr
);
1029 zend_string_release(zstr
);
1030 ZVAL_EMPTY_STRING(ref
);
1033 static ZEND_METHOD(ion_Reader_Reader
, readStringPart
)
1035 read_part(INTERNAL_FUNCTION_PARAM_PASSTHRU
, ion_reader_read_partial_string
);
1037 static ZEND_METHOD(ion_Reader_Reader
, readLob
)
1039 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1042 ZEND_PARSE_PARAMETERS_NONE();
1044 php_ion_reader_read_lob(obj
->reader
, return_value
);
1046 static ZEND_METHOD(ion_Reader_Reader
, readLobPart
)
1048 read_part(INTERNAL_FUNCTION_PARAM_PASSTHRU
, ion_reader_read_lob_partial_bytes
);
1050 static ZEND_METHOD(ion_Reader_Reader
, getPosition
)
1052 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1055 ZEND_PARSE_PARAMETERS_NONE();
1059 ION_CHECK(ion_reader_get_position(obj
->reader
, &bytes
, &dummy
, &dummy
));
1062 static ZEND_METHOD(ion_Reader_Reader
, getDepth
)
1064 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1067 ZEND_PARSE_PARAMETERS_NONE();
1070 ION_CHECK(ion_reader_get_depth(obj
->reader
, &depth
));
1073 static ZEND_METHOD(ion_Reader_Reader
, seek
)
1075 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1078 zend_long off
, len
= -1;
1079 ZEND_PARSE_PARAMETERS_START(1, 2)
1083 ZEND_PARSE_PARAMETERS_END();
1085 ION_CHECK(ion_reader_seek(obj
->reader
, off
, len
));
1087 static ZEND_METHOD(ion_Reader_Reader
, getValueOffset
)
1089 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1092 ZEND_PARSE_PARAMETERS_NONE();
1095 ION_CHECK(ion_reader_get_value_offset(obj
->reader
, &off
));
1098 static ZEND_METHOD(ion_Reader_Reader
, getValueLength
)
1100 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1103 ZEND_PARSE_PARAMETERS_NONE();
1106 ION_CHECK(ion_reader_get_value_length(obj
->reader
, &len
));
1109 static ZEND_METHOD(ion_Reader_Buffer_Reader
, __construct
)
1111 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1115 ZEND_PARSE_PARAMETERS_START(1, 2)
1118 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->opt
, ce_Reader_Options
)
1119 ZEND_PARSE_PARAMETERS_END();
1121 obj
->type
= BUFFER_READER
;
1122 obj
->buffer
= zend_string_copy(zstr
);
1124 php_ion_reader_ctor(obj
);
1126 static ZEND_METHOD(ion_Reader_Buffer_Reader
, getBuffer
)
1128 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1131 ZEND_PARSE_PARAMETERS_NONE();
1132 RETURN_STR_COPY(obj
->buffer
);
1135 static ZEND_METHOD(ion_Reader_Stream_Reader
, __construct
)
1137 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1141 ZEND_PARSE_PARAMETERS_START(1, 2)
1142 Z_PARAM_RESOURCE(zstream
)
1144 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->opt
, ce_Reader_Options
)
1145 ZEND_PARSE_PARAMETERS_END();
1147 obj
->type
= STREAM_READER
;
1148 php_stream_from_zval_no_verify(obj
->stream
.ptr
, zstream
);
1150 php_ion_reader_ctor(obj
);
1152 static ZEND_METHOD(ion_Reader_Stream_Reader
, getStream
)
1154 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1157 ZEND_PARSE_PARAMETERS_NONE();
1158 PTR_CHECK(obj
->stream
.ptr
);
1160 GC_ADDREF(obj
->stream
.ptr
->res
);
1161 RETURN_RES(obj
->stream
.ptr
->res
);
1163 static ZEND_METHOD(ion_Reader_Stream_Reader
, resetStream
)
1165 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1169 ZEND_PARSE_PARAMETERS_START(1, 1);
1170 Z_PARAM_RESOURCE(zstream
);
1171 ZEND_PARSE_PARAMETERS_END();
1173 ION_CHECK(ion_reader_reset_stream(&obj
->reader
, obj
, php_ion_reader_stream_handler
));
1175 if (obj
->stream
.ptr
) {
1176 zend_list_delete(obj
->stream
.ptr
->res
);
1178 php_stream_from_zval_no_verify(obj
->stream
.ptr
, zstream
);
1179 PTR_CHECK(obj
->stream
.ptr
);
1180 Z_ADDREF_P(zstream
);
1182 static ZEND_METHOD(ion_Reader_Stream_Reader
, resetStreamWithLength
)
1184 php_ion_reader
*obj
= php_ion_obj(reader
, Z_OBJ_P(ZEND_THIS
));
1189 ZEND_PARSE_PARAMETERS_START(2, 2);
1190 Z_PARAM_RESOURCE(zstream
);
1191 Z_PARAM_LONG(length
)
1192 ZEND_PARSE_PARAMETERS_END();
1194 ION_CHECK(ion_reader_reset_stream_with_length(&obj
->reader
, obj
, php_ion_reader_stream_handler
, length
));
1196 if (obj
->stream
.ptr
) {
1197 zend_list_delete(obj
->stream
.ptr
->res
);
1199 php_stream_from_zval_no_verify(obj
->stream
.ptr
, zstream
);
1200 PTR_CHECK(obj
->stream
.ptr
);
1201 Z_ADDREF_P(zstream
);
1203 static ZEND_METHOD(ion_Writer_Options
, __construct
)
1205 php_ion_writer_options
*obj
= php_ion_obj(writer_options
, Z_OBJ_P(ZEND_THIS
));
1208 zend_bool binary
= false, compact_floats
= false, escape
= false, pretty
= false,
1209 tabs
= true, flush
= false;
1210 zend_long indent
= 2, max_depth
= 10, max_ann
= 10, temp
= 0x4000;
1211 ZEND_PARSE_PARAMETERS_START(0, 12)
1213 //public readonly ?\ion\Catalog $catalog = null,
1214 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->cat
, ce_Catalog
)
1215 //public readonly ?\ion\Decimal\Context $decimalContext = null,
1216 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->dec_ctx
, ce_Decimal_Context
)
1217 //public readonly bool $outputBinary = false,
1218 Z_PARAM_BOOL(binary
)
1219 //public readonly bool $compactFloats = false,
1220 Z_PARAM_BOOL(compact_floats
)
1221 //public readonly bool $escapeNonAscii = false,
1222 Z_PARAM_BOOL(escape
)
1223 //public readonly bool $prettyPrint = false,
1224 Z_PARAM_BOOL(pretty
)
1225 //public readonly bool $indentTabs = true,
1227 //public readonly int $indentSize = 2,
1228 Z_PARAM_LONG(indent
)
1229 //public readonly bool $flushEveryValue = false,
1231 //public readonly int $maxContainerDepth = 10,
1232 Z_PARAM_LONG(max_depth
)
1233 //public readonly int $maxAnnotations = 10,
1234 Z_PARAM_LONG(max_ann
)
1235 //public readonly int $tempBufferSize = 0x4000,
1237 ZEND_PARSE_PARAMETERS_END();
1240 update_property_obj(&obj
->std
, ZEND_STRL("catalog"), obj
->cat
);
1241 obj
->opt
.pcatalog
= php_ion_obj(catalog
, obj
->cat
)->cat
;
1243 zend_update_property_null(NULL
, &obj
->std
, ZEND_STRL("catalog"));
1246 update_property_obj(&obj
->std
, ZEND_STRL("decimalContext"), obj
->dec_ctx
);
1247 obj
->opt
.decimal_context
= &php_ion_obj(decimal_ctx
, obj
->dec_ctx
)->ctx
;
1249 zend_update_property_null(NULL
, &obj
->std
, ZEND_STRL("decimalContext"));
1251 zend_update_property_bool(obj
->std
.ce
, &obj
->std
, ZEND_STRL("outputBinary"),
1252 obj
->opt
.output_as_binary
= binary
);
1253 zend_update_property_bool(obj
->std
.ce
, &obj
->std
, ZEND_STRL("compactFloats"),
1254 obj
->opt
.compact_floats
= compact_floats
);
1255 zend_update_property_bool(obj
->std
.ce
, &obj
->std
, ZEND_STRL("escapeNonAscii"),
1256 obj
->opt
.escape_all_non_ascii
= escape
);
1257 zend_update_property_bool(obj
->std
.ce
, &obj
->std
, ZEND_STRL("prettyPrint"),
1258 obj
->opt
.pretty_print
= pretty
);
1259 zend_update_property_bool(obj
->std
.ce
, &obj
->std
, ZEND_STRL("indentTabs"),
1260 obj
->opt
.indent_with_tabs
= tabs
);
1261 zend_update_property_long(obj
->std
.ce
, &obj
->std
, ZEND_STRL("indentSize"),
1262 obj
->opt
.indent_size
= (SIZE
) indent
);
1263 zend_update_property_bool(obj
->std
.ce
, &obj
->std
, ZEND_STRL("flushEveryValue"),
1264 obj
->opt
.flush_every_value
= flush
);
1265 zend_update_property_long(obj
->std
.ce
, &obj
->std
, ZEND_STRL("maxContainerDepth"),
1266 obj
->opt
.max_container_depth
= (SIZE
) max_depth
);
1267 zend_update_property_long(obj
->std
.ce
, &obj
->std
, ZEND_STRL("maxAnnotations"),
1268 obj
->opt
.max_annotation_count
= (SIZE
) max_ann
);
1269 zend_update_property_long(obj
->std
.ce
, &obj
->std
, ZEND_STRL("tempBufferSize"),
1270 obj
->opt
.temp_buffer_size
= (SIZE
) temp
);
1272 static ZEND_METHOD(ion_Writer_Writer
, writeNull
)
1274 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1277 ZEND_PARSE_PARAMETERS_NONE();
1279 ION_CHECK(ion_writer_write_null(obj
->writer
));
1281 static ZEND_METHOD(ion_Writer_Writer
, writeTypedNull
)
1283 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1286 zend_object
*typ_obj
;
1287 ZEND_PARSE_PARAMETERS_START(1, 1)
1288 Z_PARAM_OBJ_OF_CLASS(typ_obj
, ce_Type
)
1289 ZEND_PARSE_PARAMETERS_END();
1291 ION_CHECK(ion_writer_write_typed_null(obj
->writer
, ion_type_from_enum(typ_obj
)));
1293 static ZEND_METHOD(ion_Writer_Writer
, writeBool
)
1295 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1299 ZEND_PARSE_PARAMETERS_START(1, 1)
1301 ZEND_PARSE_PARAMETERS_END();
1303 ION_CHECK(ion_writer_write_bool(obj
->writer
, b
));
1305 static ZEND_METHOD(ion_Writer_Writer
, writeInt
)
1307 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1312 ZEND_PARSE_PARAMETERS_START(1, 1)
1313 Z_PARAM_STR_OR_LONG(s
, l
)
1314 ZEND_PARSE_PARAMETERS_END();
1318 ION_CHECK(ion_int_alloc(obj
->writer
, &i
));
1319 ION_CHECK(ion_int_from_chars(i
, s
->val
, s
->len
));
1320 ION_CHECK(ion_writer_write_ion_int(obj
->writer
, i
));
1323 ION_CHECK(ion_writer_write_int64(obj
->writer
, l
));
1326 static ZEND_METHOD(ion_Writer_Writer
, writeFloat
)
1328 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1332 ZEND_PARSE_PARAMETERS_START(1, 1)
1334 ZEND_PARSE_PARAMETERS_END();
1336 ION_CHECK(ion_writer_write_double(obj
->writer
, d
));
1338 static ZEND_METHOD(ion_Writer_Writer
, writeDecimal
)
1340 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1343 zend_object
*dec_obj
;
1344 zend_string
*dec_str
;
1345 ZEND_PARSE_PARAMETERS_START(1, 1)
1346 Z_PARAM_OBJ_OF_CLASS_OR_STR(dec_obj
, ce_Decimal
, dec_str
)
1347 ZEND_PARSE_PARAMETERS_END();
1350 decContext
*ctx
= &php_ion_globals
.decimal
.ctx
;
1351 ION_DECIMAL dec
= {0};
1354 php_ion_writer_options
*opt_obj
= php_ion_obj(writer_options
, obj
->opt
);
1355 if (opt_obj
->opt
.decimal_context
) {
1356 ctx
= opt_obj
->opt
.decimal_context
;
1359 ION_CHECK(ion_decimal_from_string(&dec
, dec_str
->val
, ctx
));
1360 ION_CHECK(ion_writer_write_ion_decimal(obj
->writer
, &dec
));
1362 php_ion_decimal
*dec
= php_ion_obj(decimal
, dec_obj
);
1363 ION_CHECK(ion_writer_write_ion_decimal(obj
->writer
, &dec
->dec
));
1366 static ZEND_METHOD(ion_Writer_Writer
, writeTimestamp
)
1368 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1371 zend_object
*ts_obj
;
1372 zend_string
*ts_str
;
1373 ZEND_PARSE_PARAMETERS_START(1, 1)
1374 Z_PARAM_OBJ_OF_CLASS_OR_STR(ts_obj
, ce_Timestamp
, ts_str
)
1375 ZEND_PARSE_PARAMETERS_END();
1377 decContext
*ctx
= NULL
;
1379 ctx
= php_ion_obj(reader_options
, obj
->opt
)->opt
.decimal_context
;
1382 ION_TIMESTAMP tmp
= {0};
1385 ION_CHECK(ion_timestamp_parse(&tmp
, ts_str
->val
, ts_str
->len
, &used
, ctx
));
1387 php_ion_timestamp
*ts
= php_ion_obj(timestamp
, ts_obj
);
1389 ion_timestamp_from_php(&tmp
, ts
, ctx
);
1391 ION_CHECK(ion_writer_write_timestamp(obj
->writer
, &tmp
));
1393 static ZEND_METHOD(ion_Writer_Writer
, writeSymbol
)
1395 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1398 zend_object
*sym_obj
;
1399 zend_string
*sym_str
;
1400 ZEND_PARSE_PARAMETERS_START(1, 1)
1401 Z_PARAM_OBJ_OF_CLASS_OR_STR(sym_obj
, ce_Symbol
, sym_str
);
1402 ZEND_PARSE_PARAMETERS_END();
1406 ION_CHECK(ion_writer_write_symbol(obj
->writer
, ion_string_from_zend(&is
, sym_str
)));
1408 php_ion_symbol
*sym
= php_ion_obj(symbol
, sym_obj
);
1410 ION_CHECK(ion_writer_write_ion_symbol(obj
->writer
, &sym
->sym
));
1413 static ZEND_METHOD(ion_Writer_Writer
, writeString
)
1415 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1419 ZEND_PARSE_PARAMETERS_START(1, 1)
1421 ZEND_PARSE_PARAMETERS_END();
1424 ION_CHECK(ion_writer_write_string(obj
->writer
, ion_string_from_zend(&is
, str
)));
1426 static ZEND_METHOD(ion_Writer_Writer
, writeCLob
)
1428 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1432 ZEND_PARSE_PARAMETERS_START(1, 1)
1434 ZEND_PARSE_PARAMETERS_END();
1436 ION_CHECK(ion_writer_write_clob(obj
->writer
, (BYTE
*) str
->val
, str
->len
));
1438 static ZEND_METHOD(ion_Writer_Writer
, writeBLob
)
1440 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1444 ZEND_PARSE_PARAMETERS_START(1, 1)
1446 ZEND_PARSE_PARAMETERS_END();
1448 ION_CHECK(ion_writer_write_blob(obj
->writer
, (BYTE
*) str
->val
, str
->len
));
1450 static ZEND_METHOD(ion_Writer_Writer
, startLob
)
1452 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1455 zend_object
*typ_obj
;
1456 ZEND_PARSE_PARAMETERS_START(1, 1)
1457 Z_PARAM_OBJ_OF_CLASS(typ_obj
, ce_Type
)
1458 ZEND_PARSE_PARAMETERS_END();
1460 ION_CHECK(ion_writer_start_lob(obj
->writer
, ion_type_from_enum(typ_obj
)));
1462 static ZEND_METHOD(ion_Writer_Writer
, appendLob
)
1464 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1468 ZEND_PARSE_PARAMETERS_START(1, 1)
1470 ZEND_PARSE_PARAMETERS_END();
1472 ION_CHECK(ion_writer_append_lob(obj
->writer
, (BYTE
*) str
->val
, str
->len
));
1474 static ZEND_METHOD(ion_Writer_Writer
, finishLob
)
1476 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1479 ZEND_PARSE_PARAMETERS_NONE();
1481 ION_CHECK(ion_writer_finish_lob(obj
->writer
));
1483 static ZEND_METHOD(ion_Writer_Writer
, startContainer
)
1485 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1488 zend_object
*typ_obj
;
1489 ZEND_PARSE_PARAMETERS_START(1, 1)
1490 Z_PARAM_OBJ_OF_CLASS(typ_obj
, ce_Type
)
1491 ZEND_PARSE_PARAMETERS_END();
1493 ION_CHECK(ion_writer_start_container(obj
->writer
, ion_type_from_enum(typ_obj
)));
1495 static ZEND_METHOD(ion_Writer_Writer
, finishContainer
)
1497 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1500 ZEND_PARSE_PARAMETERS_NONE();
1502 ION_CHECK(ion_writer_finish_container(obj
->writer
));
1504 static ZEND_METHOD(ion_Writer_Writer
, writeFieldName
)
1506 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1509 zend_object
*sym_obj
;
1510 zend_string
*sym_str
;
1511 ZEND_PARSE_PARAMETERS_START(1, 1)
1512 Z_PARAM_OBJ_OF_CLASS_OR_STR(sym_obj
, ce_Symbol
, sym_str
);
1513 ZEND_PARSE_PARAMETERS_END();
1517 ION_CHECK(ion_writer_write_field_name(obj
->writer
, ion_string_from_zend(&is
, sym_str
)));
1519 php_ion_symbol
*sym
= php_ion_obj(symbol
, sym_obj
);
1521 ION_CHECK(ion_writer_write_field_name_symbol(obj
->writer
, &sym
->sym
));
1524 static ZEND_METHOD(ion_Writer_Writer
, writeAnnotation
)
1526 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1531 ZEND_PARSE_PARAMETERS_START(1, -1)
1532 Z_PARAM_VARIADIC('+', args
, argc
);
1533 ZEND_PARSE_PARAMETERS_END();
1535 for (unsigned i
= 0; i
< argc
; ++i
) {
1536 switch (Z_TYPE(args
[i
])) {
1539 ION_CHECK(ion_writer_add_annotation(obj
->writer
, ion_string_from_zend(&is
, Z_STR(args
[i
]))));
1543 ION_CHECK(ion_writer_add_annotation_symbol(obj
->writer
, &php_ion_obj(symbol
, Z_OBJ(args
[i
]))->sym
));
1548 static ZEND_METHOD(ion_Writer_Writer
, getDepth
)
1550 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1553 ZEND_PARSE_PARAMETERS_NONE();
1556 ION_CHECK(ion_writer_get_depth(obj
->writer
, &depth
));
1559 static ZEND_METHOD(ion_Writer_Writer
, flush
)
1561 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1564 ZEND_PARSE_PARAMETERS_NONE();
1567 ION_CHECK(ion_writer_flush(obj
->writer
, &flushed
));
1568 RETURN_LONG(flushed
);
1570 static ZEND_METHOD(ion_Writer_Writer
, finish
)
1572 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1575 ZEND_PARSE_PARAMETERS_NONE();
1578 ION_CHECK(ion_writer_finish(obj
->writer
, &flushed
));
1579 RETURN_LONG(flushed
);
1581 static ZEND_METHOD(ion_Writer_Buffer_Writer
, __construct
)
1583 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1586 ZEND_PARSE_PARAMETERS_START(0, 1)
1588 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->opt
, ce_Writer_Options
)
1589 ZEND_PARSE_PARAMETERS_END();
1591 obj
->type
= BUFFER_WRITER
;
1592 php_ion_writer_ctor(obj
);
1594 static ZEND_METHOD(ion_Writer_Buffer_Writer
, getBuffer
)
1596 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1599 ZEND_PARSE_PARAMETERS_NONE();
1601 RETVAL_STR(php_ion_writer_buffer_copy(obj
));
1603 static ZEND_METHOD(ion_Writer_Buffer_Writer
, resetBuffer
)
1605 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1608 ZEND_PARSE_PARAMETERS_NONE();
1610 php_ion_writer_buffer_reset(obj
);
1612 static ZEND_METHOD(ion_Writer_Stream_Writer
, __construct
)
1614 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1618 ZEND_PARSE_PARAMETERS_START(1, 2)
1619 Z_PARAM_RESOURCE(zstream
)
1621 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->opt
, ce_Writer_Options
)
1622 ZEND_PARSE_PARAMETERS_END();
1624 obj
->type
= STREAM_WRITER
;
1625 php_stream_from_zval_no_verify(obj
->stream
.ptr
, zstream
);
1627 php_ion_writer_ctor(obj
);
1629 static ZEND_METHOD(ion_Writer_Stream_Writer
, getStream
)
1631 php_ion_writer
*obj
= php_ion_obj(writer
, Z_OBJ_P(ZEND_THIS
));
1634 ZEND_PARSE_PARAMETERS_NONE();
1635 PTR_CHECK(obj
->stream
.ptr
);
1637 GC_ADDREF(obj
->stream
.ptr
->res
);
1638 RETURN_RES(obj
->stream
.ptr
->res
);
1641 static ZEND_METHOD(ion_Serializer_PHP
, __construct
)
1643 php_ion_serializer_php
*obj
= php_ion_obj(serializer_php
, Z_OBJ_P(ZEND_THIS
));
1646 obj
->serializer
.call_magic
= true;
1648 ZEND_PARSE_PARAMETERS_START(0, 4)
1650 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->opt
, ce_Writer_Options
)
1651 Z_PARAM_BOOL(obj
->serializer
.multi_seq
)
1652 Z_PARAM_BOOL(obj
->serializer
.call_magic
)
1653 Z_PARAM_STR_OR_NULL(obj
->serializer
.call_custom
)
1654 ZEND_PARSE_PARAMETERS_END();
1656 php_ion_serializer_php_ctor(obj
);
1658 static ZEND_METHOD(ion_Serializer_PHP
, serialize
)
1660 zend_object
*obj
= Z_OBJ_P(ZEND_THIS
);
1663 ZEND_PARSE_PARAMETERS_START(1, 1)
1665 ZEND_PARSE_PARAMETERS_END();
1667 php_ion_serialize(&php_ion_obj(serializer_php
, obj
)->serializer
, data
, return_value
);
1669 static ZEND_FUNCTION(ion_serialize
)
1672 zend_object
*zo_ser
= NULL
;
1673 ZEND_PARSE_PARAMETERS_START(1, 2)
1676 Z_PARAM_OBJ_OF_CLASS_OR_NULL(zo_ser
, ce_Serializer
)
1677 ZEND_PARSE_PARAMETERS_END();
1679 if (!zo_ser
|| zo_ser
->ce
== ce_Serializer_PHP
) {
1680 // default, fast path
1681 php_ion_serializer
*ser
= zo_ser
? &php_ion_obj(serializer_php
, zo_ser
)->serializer
: NULL
;
1682 php_ion_serialize(ser
, data
, return_value
);
1684 zend_call_method_with_1_params(zo_ser
, NULL
, NULL
, "serialize", return_value
, data
);
1688 static ZEND_METHOD(ion_Unserializer_PHP
, __construct
)
1690 php_ion_unserializer_php
*obj
= php_ion_obj(unserializer_php
, Z_OBJ_P(ZEND_THIS
));
1693 obj
->unserializer
.call_magic
= true;
1695 ZEND_PARSE_PARAMETERS_START(0, 4)
1697 Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj
->opt
, ce_Reader_Options
)
1698 Z_PARAM_BOOL(obj
->unserializer
.multi_seq
)
1699 Z_PARAM_BOOL(obj
->unserializer
.call_magic
)
1700 Z_PARAM_STR_OR_NULL(obj
->unserializer
.call_custom
)
1701 ZEND_PARSE_PARAMETERS_END();
1703 php_ion_unserializer_php_ctor(obj
);
1705 static ZEND_METHOD(ion_Unserializer_PHP
, unserialize
)
1707 zend_object
*obj
= Z_OBJ_P(ZEND_THIS
);
1710 ZEND_PARSE_PARAMETERS_START(1, 1)
1712 ZEND_PARSE_PARAMETERS_END();
1714 php_ion_unserialize(&php_ion_obj(unserializer_php
, obj
)->unserializer
, data
, return_value
);
1716 static ZEND_FUNCTION(ion_unserialize
)
1719 zend_object
*zo_ser
= NULL
;
1720 ZEND_PARSE_PARAMETERS_START(1, 2)
1723 Z_PARAM_OBJ_OF_CLASS_OR_NULL(zo_ser
, ce_Unserializer
)
1724 ZEND_PARSE_PARAMETERS_END();
1726 if (!zo_ser
|| zo_ser
->ce
== ce_Unserializer_PHP
) {
1727 // default, fast path
1728 php_ion_unserializer
*ser
= zo_ser
? &php_ion_obj(unserializer_php
, zo_ser
)->unserializer
: NULL
;
1729 php_ion_unserialize(ser
, data
, return_value
);
1731 zend_call_method_with_1_params(zo_ser
, NULL
, NULL
, "__invoke", return_value
, data
);
1735 PHP_RINIT_FUNCTION(ion
)
1737 #if defined(ZTS) && defined(COMPILE_DL_ION)
1738 ZEND_TSRMLS_CACHE_UPDATE();
1741 php_ion_globals_symbols_init();
1742 php_ion_globals_serializer_init();
1743 php_ion_globals_unserializer_init();
1747 PHP_RSHUTDOWN_FUNCTION(ion
)
1749 php_ion_globals_unserializer_dtor();
1750 php_ion_globals_serializer_dtor();
1751 php_ion_globals_symbols_dtor();
1755 #define ZEND_ARG_VARIADIC_OBJ_TYPE_MASK(pass_by_ref, name, classname, type_mask, default_value) \
1756 { #name, ZEND_TYPE_INIT_CLASS_CONST_MASK(#classname, ((type_mask) | _ZEND_ARG_INFO_FLAGS(pass_by_ref, 1, 0))), default_value },
1757 #include "ion_arginfo.h"
1759 // spl_iterators.h includes ext/pcre/php_pcre.h which might not find pcre2.h
1760 extern PHPAPI zend_class_entry
*spl_ce_RecursiveIterator
;
1762 PHP_MINIT_FUNCTION(ion
)
1765 if (SUCCESS
!= g_sym_init()) {
1768 g_intern_str_init();
1771 php_ion_register(catalog
, Catalog
, zend_ce_countable
);
1774 php_ion_register(decimal
, Decimal
);
1775 php_ion_register(decimal_ctx
, Decimal_Context
);
1776 ce_Decimal_Context_Rounding
= register_class_ion_Decimal_Context_Rounding();
1779 ce_LOB
= register_class_ion_LOB();
1782 ce_Reader
= register_class_ion_Reader(spl_ce_RecursiveIterator
);
1783 php_ion_register(reader_options
, Reader_Options
);
1784 php_ion_register(reader
, Reader_Reader
, ce_Reader
);
1785 ce_Reader_Buffer
= register_class_ion_Reader_Buffer(ce_Reader
);
1786 ce_Reader_Buffer_Reader
= register_class_ion_Reader_Buffer_Reader(ce_Reader_Reader
, ce_Reader_Buffer
);
1787 ce_Reader_Stream
= register_class_ion_Reader_Stream(ce_Reader
);
1788 ce_Reader_Stream_Reader
= register_class_ion_Reader_Stream_Reader(ce_Reader_Reader
, ce_Reader_Stream
);
1791 ce_Serializer
= register_class_ion_Serializer();
1792 php_ion_register(serializer_php
, Serializer_PHP
, ce_Serializer
);
1795 php_ion_register(symbol
, Symbol
);
1796 oh_Symbol
.compare
= php_ion_symbol_zval_compare
;
1797 php_ion_register(symbol_iloc
, Symbol_ImportLocation
);
1798 php_ion_register(symbol_table
, Symbol_Table
);
1799 ce_Symbol_Table
->create_object
= NULL
;
1800 ce_Symbol_Table_Local
= register_class_ion_Symbol_Table_Local(ce_Symbol_Table
);
1801 ce_Symbol_Table_Local
->create_object
= create_ion_Symbol_Table
;
1802 ce_Symbol_Table_Shared
= register_class_ion_Symbol_Table_Shared(ce_Symbol_Table
);
1803 ce_Symbol_Table_Shared
->create_object
= create_ion_Symbol_Table
;
1804 ce_Symbol_Enum
= register_class_ion_Symbol_Enum();
1805 ce_Symbol_Table_System
= register_class_ion_Symbol_Table_System(ce_Symbol_Enum
);
1806 ce_Symbol_Table_PHP
= register_class_ion_Symbol_Table_PHP(ce_Symbol_Enum
);
1809 ce_Timestamp
= register_class_ion_Timestamp(php_date_get_date_ce());
1810 ce_Timestamp_Format
= register_class_ion_Timestamp_Format();
1811 ce_Timestamp_Precision
= register_class_ion_Timestamp_Precision();
1814 ce_Type
= register_class_ion_Type();
1817 ce_Writer
= register_class_ion_Writer();
1818 php_ion_register(writer_options
, Writer_Options
);
1819 php_ion_register(writer
, Writer_Writer
, ce_Writer
);
1820 ce_Writer_Buffer
= register_class_ion_Writer_Buffer(ce_Writer
);
1821 ce_Writer_Buffer_Writer
= register_class_ion_Writer_Buffer_Writer(ce_Writer_Writer
, ce_Writer_Buffer
);
1822 ce_Writer_Stream
= register_class_ion_Writer_Stream(ce_Writer
);
1823 ce_Writer_Stream_Writer
= register_class_ion_Writer_Stream_Writer(ce_Writer_Writer
, ce_Writer_Stream
);
1826 ce_Unserializer
= register_class_ion_Unserializer();
1827 php_ion_register(unserializer_php
, Unserializer_PHP
, ce_Unserializer
);
1832 PHP_MSHUTDOWN_FUNCTION(ion
)
1834 if (g_sym_tab_php
) {
1835 ion_symbol_table_close(g_sym_tab_php
);
1837 zend_hash_destroy(&g_sym_hash
);
1841 PHP_MINFO_FUNCTION(ion
)
1843 php_info_print_table_start();
1844 php_info_print_table_header(2, "ion support", "enabled");
1845 php_info_print_table_end();
1848 PHP_GINIT_FUNCTION(ion
)
1850 memset(ion_globals
, 0, sizeof(*ion_globals
));
1852 php_ion_decimal_ctx_init_max(&ion_globals
->decimal
.ctx
, DEC_ROUND_HALF_EVEN
);
1853 php_ion_decimal_from_zend_long(&ion_globals
->decimal
.zend_max
, &ion_globals
->decimal
.ctx
, ZEND_LONG_MAX
);
1854 php_ion_decimal_from_zend_long(&ion_globals
->decimal
.zend_min
, &ion_globals
->decimal
.ctx
, ZEND_LONG_MIN
);
1857 PHP_GSHUTDOWN_FUNCTION(ion
)
1861 static zend_module_dep ion_module_deps
[] = {
1862 ZEND_MOD_REQUIRED("date")
1863 ZEND_MOD_REQUIRED("spl")
1867 zend_module_entry ion_module_entry
= {
1868 STANDARD_MODULE_HEADER_EX
,
1871 "ion", /* Extension name */
1872 ext_functions
, /* zend_function_entry */
1873 PHP_MINIT(ion
), /* PHP_MINIT - Module initialization */
1874 PHP_MSHUTDOWN(ion
), /* PHP_MSHUTDOWN - Module shutdown */
1875 PHP_RINIT(ion
), /* PHP_RINIT - Request initialization */
1876 PHP_RSHUTDOWN(ion
), /* PHP_RSHUTDOWN - Request shutdown */
1877 PHP_MINFO(ion
), /* PHP_MINFO - Module info */
1878 PHP_ION_VERSION
, /* Version */
1879 ZEND_MODULE_GLOBALS(ion
),
1880 PHP_GINIT(ion
), /* PHP_GINIT */
1881 PHP_GSHUTDOWN(ion
), /* PHP_GSHUTDOWN */
1883 STANDARD_MODULE_PROPERTIES_EX
1886 #ifdef COMPILE_DL_ION
1888 ZEND_TSRMLS_CACHE_DEFINE()
1890 ZEND_GET_MODULE(ion
)