fix bad method call
[awesomized/ext-ion] / ion.c
diff --git a/ion.c b/ion.c
index f101f4c6c8a5f21b23af2ad2cbd6b40171b4173b..b357995a86f6aa604098b15653d48d098dcc393f 100644 (file)
--- a/ion.c
+++ b/ion.c
@@ -125,7 +125,7 @@ static ZEND_METHOD(ion_Symbol_Enum, toString)
        zval tmp;
        RETVAL_ZVAL(zend_read_property(Z_OBJCE_P(zsym), Z_OBJ_P(zsym), ZEND_STRL("value"), 0, &tmp), 1, 0);
 }
-static ZEND_FUNCTION(ion_Symbol_Table_System)
+static ZEND_METHOD(ion_Symbol_System, asTable)
 {
        ZEND_PARSE_PARAMETERS_NONE();
 
@@ -135,7 +135,7 @@ static ZEND_FUNCTION(ion_Symbol_Table_System)
        php_ion_symbol_table_ctor(obj);
        ion_symbol_table_lock(obj->tab);
 }
-static ZEND_FUNCTION(ion_Symbol_Table_PHP)
+static ZEND_METHOD(ion_Symbol_PHP, asTable)
 {
        ZEND_PARSE_PARAMETERS_NONE();
 
@@ -410,14 +410,15 @@ static ZEND_METHOD(ion_Timestamp, __construct)
 
        zend_long precision;
        zend_object *precision_obj = NULL, *format_obj = NULL;
-       zend_string *fmt = NULL, *dt = NULL;
-       zval *tz = NULL;
+       zend_string *fmt = NULL, *dt = NULL, *tz = NULL;
+       zend_object *tz_obj = NULL;
+       zval z_tz_tmp, *z_tz_ptr = NULL;
        ZEND_PARSE_PARAMETERS_START(1, 4)
                Z_PARAM_OBJ_OF_CLASS_OR_LONG(precision_obj, ce_Timestamp_Precision, precision)
                Z_PARAM_OPTIONAL
                Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(format_obj, ce_Timestamp_Format, fmt)
                Z_PARAM_STR_OR_NULL(dt)
-               Z_PARAM_ZVAL(tz)
+               Z_PARAM_OBJ_OF_CLASS_OR_STR_OR_NULL(tz_obj, php_date_get_timezone_ce(), tz)
        ZEND_PARSE_PARAMETERS_END();
 
        if (precision_obj) {
@@ -426,7 +427,21 @@ static ZEND_METHOD(ion_Timestamp, __construct)
        if (format_obj) {
                fmt = Z_STR_P(zend_enum_fetch_case_value(format_obj));
        }
-       php_ion_timestamp_ctor(obj, precision, fmt, dt, tz);
+       if (tz_obj) {
+               ZVAL_OBJ(z_tz_ptr = &z_tz_tmp, tz_obj);
+       } else if (tz) {
+               // there's no public API, so call timezone_open
+               zend_function *tz_open = zend_fetch_function_str(ZEND_STRL("timezone_open"));
+               if (tz_open) {
+                       zval z_arg;
+                       ZVAL_STR(&z_arg, tz);
+                       zend_call_known_function(tz_open, NULL, NULL, z_tz_ptr = &z_tz_tmp, 1, &z_arg, NULL);
+               }
+       }
+       php_ion_timestamp_ctor(obj, precision, fmt, dt, z_tz_ptr);
+       if (tz && z_tz_ptr) {
+               zval_ptr_dtor(z_tz_ptr);
+       }
 }
 static ZEND_METHOD(ion_Timestamp, __toString)
 {
@@ -597,12 +612,11 @@ static ZEND_METHOD(ion_Reader_Options, __construct)
 {
        php_ion_reader_options *opt = php_ion_obj(reader_options, Z_OBJ_P(ZEND_THIS));
        zend_bool ret_sys_val = false, skip_validation = false;
-       zend_long ch_nl = 0xa, max_depth = 10, max_ann = 10, max_ann_buf = 512,
-                       sym_thr = 0x4000, uval_thr = 0x4000, chunk_thr = 0x4000, alloc_pgsz = 0x10000;
+       zend_long max_depth = 10, max_ann = 10, ann_buf_siz = 0x4000, tmp_buf_siz = 0x4000;
 
        PTR_CHECK(opt);
 
-       ZEND_PARSE_PARAMETERS_START(0, 13)
+       ZEND_PARSE_PARAMETERS_START(0, 9)
                Z_PARAM_OPTIONAL
         // public readonly ?\ion\Catalog $catalog = null,
                Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt->cat, ce_Catalog)
@@ -612,22 +626,14 @@ static ZEND_METHOD(ion_Reader_Options, __construct)
                Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt->cb, zend_ce_closure);
         // public readonly bool $returnSystemValues = false,
                Z_PARAM_BOOL(ret_sys_val)
-        // public readonly int $newLine = 0xa,
-               Z_PARAM_LONG(ch_nl)
         // public readonly int $maxContainerDepth = 10,
                Z_PARAM_LONG(max_depth)
         // public readonly int $maxAnnotations = 10,
                Z_PARAM_LONG(max_ann)
-        // public readonly int $maxAnnotationBuffered = 512,
-               Z_PARAM_LONG(max_ann_buf)
-        // public readonly int $symbolThreshold = 0x4000,
-               Z_PARAM_LONG(sym_thr)
-        // public readonly int $userValueThreshold = 0x4000,
-               Z_PARAM_LONG(uval_thr)
-        // public readonly int $chunkThreshold = 0x4000,
-               Z_PARAM_LONG(chunk_thr)
-        // public readonly int $allocationPageSize = 0x10000,
-               Z_PARAM_LONG(alloc_pgsz)
+        // public readonly int $annotationBufferSize = 0x4000,
+               Z_PARAM_LONG(ann_buf_siz)
+        // public readonly int $tempBufferSize = 0x4000,
+               Z_PARAM_LONG(tmp_buf_siz)
         // public readonly bool $skipCharacterValidation = false,
                Z_PARAM_BOOL(skip_validation)
        ZEND_PARSE_PARAMETERS_END();
@@ -655,22 +661,14 @@ static ZEND_METHOD(ion_Reader_Options, __construct)
        }
        zend_update_property_bool(opt->std.ce, &opt->std, ZEND_STRL("returnSystemValues"),
                opt->opt.return_system_values = ret_sys_val);
-       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("newLine"),
-               opt->opt.new_line_char = (int) ch_nl);
        zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("maxContainerDepth"),
                opt->opt.max_container_depth = (SIZE) max_depth);
        zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("maxAnnotations"),
                opt->opt.max_annotation_count = (SIZE) max_ann);
-       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("maxAnnotationBuffered"),
-               opt->opt.max_annotation_buffered = (SIZE) max_ann_buf);
-       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("symbolThreshold"),
-               opt->opt.symbol_threshold = (SIZE) sym_thr);
-       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("userValueThreshold"),
-               opt->opt.user_value_threshold = (SIZE) uval_thr);
-       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("chunkThreshold"),
-               opt->opt.chunk_threshold = (SIZE) chunk_thr);
-       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("allocationPageSize"),
-               opt->opt.allocation_page_size = (SIZE) alloc_pgsz);
+       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("annotationBufferSize"),
+               opt->opt.max_annotation_buffered = (SIZE) ann_buf_siz);
+       zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("tempBufferSize"),
+               opt->opt.chunk_threshold = opt->opt.user_value_threshold = opt->opt.symbol_threshold = (SIZE) tmp_buf_siz);
        zend_update_property_long(opt->std.ce, &opt->std, ZEND_STRL("skipCharacterValidation"),
                opt->opt.skip_character_validation = (SIZE) skip_validation);
 }
@@ -1223,9 +1221,9 @@ static ZEND_METHOD(ion_Writer_Options, __construct)
        PTR_CHECK(obj);
 
        zend_bool binary = false, compact_floats = false, escape = false, pretty = false,
-                       tabs = true, small_cntr_inl = true, suppress_sys = false, flush = false;
-       zend_long indent = 2, max_depth = 10, max_ann = 10, temp = 0x4000, alloc = 0x10000;
-       ZEND_PARSE_PARAMETERS_START(0, 15)
+                       tabs = true, flush = false;
+       zend_long indent = 2, max_depth = 10, max_ann = 10, temp = 0x4000;
+       ZEND_PARSE_PARAMETERS_START(0, 12)
                Z_PARAM_OPTIONAL
                //public readonly ?\ion\Catalog $catalog = null,
                Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj->cat, ce_Catalog)
@@ -1243,10 +1241,6 @@ static ZEND_METHOD(ion_Writer_Options, __construct)
                Z_PARAM_BOOL(tabs)
                //public readonly int $indentSize = 2,
                Z_PARAM_LONG(indent)
-               //public readonly bool $smallContainersInline = true,
-               Z_PARAM_BOOL(small_cntr_inl)
-               //public readonly bool $suppressSystemValues = false,
-               Z_PARAM_BOOL(suppress_sys)
                //public readonly bool $flushEveryValue = false,
                Z_PARAM_BOOL(flush)
                //public readonly int $maxContainerDepth = 10,
@@ -1255,8 +1249,6 @@ static ZEND_METHOD(ion_Writer_Options, __construct)
                Z_PARAM_LONG(max_ann)
                //public readonly int $tempBufferSize = 0x4000,
                Z_PARAM_LONG(temp)
-               //public readonly int $allocationPageSize = 0x10000,
-               Z_PARAM_LONG(alloc)
        ZEND_PARSE_PARAMETERS_END();
 
        if (obj->cat) {
@@ -1283,10 +1275,6 @@ static ZEND_METHOD(ion_Writer_Options, __construct)
                        obj->opt.indent_with_tabs = tabs);
        zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("indentSize"),
                        obj->opt.indent_size = (SIZE) indent);
-       zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("smallContainersInline"),
-                       obj->opt.small_containers_in_line = small_cntr_inl);
-       zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("suppressSystemValues"),
-                       obj->opt.supress_system_values = suppress_sys);
        zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("flushEveryValue"),
                        obj->opt.flush_every_value = flush);
        zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("maxContainerDepth"),
@@ -1295,8 +1283,6 @@ static ZEND_METHOD(ion_Writer_Options, __construct)
                        obj->opt.max_annotation_count = (SIZE) max_ann);
        zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("tempBufferSize"),
                        obj->opt.temp_buffer_size = (SIZE) temp);
-       zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("allocationPageSize"),
-                       obj->opt.allocation_page_size = (SIZE) alloc);
 }
 static ZEND_METHOD(ion_Writer_Writer, writeNull)
 {
@@ -1757,7 +1743,7 @@ static ZEND_FUNCTION(ion_unserialize)
                php_ion_unserializer *ser = zo_ser ? &php_ion_obj(unserializer_php, zo_ser)->unserializer : NULL;
                php_ion_unserialize(ser, data, return_value);
        } else {
-               zend_call_method_with_1_params(zo_ser, NULL, NULL, "__invoke", return_value, data);
+               zend_call_method_with_1_params(zo_ser, NULL, NULL, "unserialize", return_value, data);
        }
 }
 
@@ -1831,8 +1817,8 @@ PHP_MINIT_FUNCTION(ion)
        ce_Symbol_Table_Shared = register_class_ion_Symbol_Table_Shared(ce_Symbol_Table);
        ce_Symbol_Table_Shared->create_object = create_ion_Symbol_Table;
        ce_Symbol_Enum = register_class_ion_Symbol_Enum();
-       ce_Symbol_Table_System = register_class_ion_Symbol_Table_System(ce_Symbol_Enum);
-       ce_Symbol_Table_PHP = register_class_ion_Symbol_Table_PHP(ce_Symbol_Enum);
+       ce_Symbol_Table_System = register_class_ion_Symbol_System(ce_Symbol_Enum);
+       ce_Symbol_Table_PHP = register_class_ion_Symbol_PHP(ce_Symbol_Enum);
 
        // Timestamp
        ce_Timestamp = register_class_ion_Timestamp(php_date_get_date_ce());