coverage++
authorMichael Wallner <mike@php.net>
Wed, 12 Jan 2022 15:03:52 +0000 (16:03 +0100)
committerMichael Wallner <mike@php.net>
Wed, 12 Jan 2022 15:03:52 +0000 (16:03 +0100)
14 files changed:
Makefile.frag
config.m4
ion.c
ion.stub.php
ion_arginfo.h
ion_private.h
tests/Catalog.phpt
tests/Decimal/Context.phpt
tests/Symbol/Table.phpt
tests/Timestamp.phpt
tests/Writer.phpt [new file with mode: 0644]
tests/Writer/Options.phpt
tests/serialize/multisequence.phpt [new file with mode: 0644]
tests/unserialize/multisequence.phpt [new file with mode: 0644]

index 6a88b58ebb60f385b773fd2b8ef9ed6814ab5901..409798028a8fc8065ec459147cbbd45e788a8134 100644 (file)
@@ -7,7 +7,7 @@ $(builddir)/ion-c/build:
        mkdir -p $@
        +cd $@ && CFLAGS=-w CXXFLAGS=-w \
        $(CMAKE) -Wno-dev --log-level=ERROR \
-               -DCMAKE_BUILD_TYPE=Release \
+               -DCMAKE_BUILD_TYPE=$(LIB_IONC_BUILD) \
                -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
                $(srcdir)/ion-c
 
index 28b6ee227585d5a617a411a542690e6cfda41ce6..ad903f9a2b73ca15c0385087637b2c4e5a716963 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -51,6 +51,12 @@ AC_DEFUN([ION_BUNDLE], [dnl
     EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM -L$builddir/ionc -L$builddir/decNumber"
   fi
 
+  if test "$PHP_DEBUG" = 1; then
+    LIB_IONC_BUILD=Debug
+  else
+    LIB_IONC_BUILD=Release
+  fi
+  PHP_SUBST(LIB_IONC_BUILD)
   PHP_ADD_MAKEFILE_FRAGMENT()
 ])
 AC_DEFUN([ION_CHECK_LIB], [dnl
diff --git a/ion.c b/ion.c
index 28d5a5cdc3356a15198b7248e02361e5c83bec64..f101f4c6c8a5f21b23af2ad2cbd6b40171b4173b 100644 (file)
--- a/ion.c
+++ b/ion.c
@@ -1225,7 +1225,7 @@ static ZEND_METHOD(ion_Writer_Options, __construct)
        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, 16)
+       ZEND_PARSE_PARAMETERS_START(0, 15)
                Z_PARAM_OPTIONAL
                //public readonly ?\ion\Catalog $catalog = null,
                Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj->cat, ce_Catalog)
@@ -1376,8 +1376,17 @@ static ZEND_METHOD(ion_Writer_Writer, writeDecimal)
        ZEND_PARSE_PARAMETERS_END();
 
        if (dec_str) {
-               ION_STRING s;
-               ION_CHECK(ion_writer_write_string(obj->writer, ion_string_from_zend(&s, dec_str)));
+               decContext *ctx = &php_ion_globals.decimal.ctx;
+               ION_DECIMAL dec = {0};
+
+               if (obj->opt) {
+                       php_ion_writer_options *opt_obj = php_ion_obj(writer_options, obj->opt);
+                       if (opt_obj->opt.decimal_context) {
+                               ctx = opt_obj->opt.decimal_context;
+                       }
+               }
+               ION_CHECK(ion_decimal_from_string(&dec, dec_str->val, ctx));
+               ION_CHECK(ion_writer_write_ion_decimal(obj->writer, &dec));
        } else {
                php_ion_decimal *dec = php_ion_obj(decimal, dec_obj);
                ION_CHECK(ion_writer_write_ion_decimal(obj->writer, &dec->dec));
@@ -1598,12 +1607,6 @@ static ZEND_METHOD(ion_Writer_Writer, finish)
        ION_CHECK(ion_writer_finish(obj->writer, &flushed));
        RETURN_LONG(flushed);
 }
-static ZEND_METHOD(ion_Writer_Writer, writeOne)
-{
-}
-static ZEND_METHOD(ion_Writer_Writer, writeAll)
-{
-}
 static ZEND_METHOD(ion_Writer_Buffer_Writer, __construct)
 {
        php_ion_writer *obj = php_ion_obj(writer, Z_OBJ_P(ZEND_THIS));
index 7818dde981e403198b45754e5e72935e38deb68b..750ee9c0bf6dd5166eeb1bf4011d3cc3e6d9a64a 100644 (file)
@@ -465,8 +465,8 @@ interface Writer {
     public function flush() : int;
     public function finish() : int;
 
-    public function writeOne(Reader $reader) : void;
-    public function writeAll(Reader $reader) : void;
+    // public function writeOne(Reader $reader) : void;
+    // public function writeAll(Reader $reader) : void;
 
     // public function getCatalog() : Catalog;
     // public function setCatalog(Catalog $catalog) : void;
@@ -504,8 +504,8 @@ abstract class Writer implements \ion\Writer {
     public function flush() : int {}
     public function finish() : int {}
 
-    public function writeOne(\ion\Reader $reader) : void {}
-    public function writeAll(\ion\Reader $reader) : void {}
+    // public function writeOne(\ion\Reader $reader) : void {}
+    // public function writeAll(\ion\Reader $reader) : void {}
 }
 
 namespace ion\Writer;
index 5015b690788c3574b2d93f359b3c03eaf4118752..d23af5cc53101a6dffcfba17ae522c07481ad613 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: aafe212ff9dd7fd15753fa5b6a3c127a51073241 */
+ * Stub hash: 3308325e021d22db87092646b58d431f8f988532 */
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_ion_Symbol_Table_PHP, 0, 0, ion\\Symbol\\Table, 0)
 ZEND_END_ARG_INFO()
@@ -16,6 +16,21 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ion_unserialize, 0, 1, IS_MIXED,
        ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, unserializer, ion\\Unserializer, 1, "null")
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Symbol___construct, 0, 0, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_STRING, 1, "null")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sid, IS_LONG, 0, "-1")
+       ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, importLocation, ion\\Symbol\\ImportLocation, 1, "null")
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Symbol_equals, 0, 1, _IS_BOOL, 0)
+       ZEND_ARG_OBJ_INFO(0, symbol, ion\\Symbol, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Symbol___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_ion_Symbol_toString arginfo_class_ion_Symbol___toString
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Symbol_ImportLocation___construct, 0, 0, 2)
        ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, location, IS_LONG, 0)
@@ -27,34 +42,19 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Symbol_Enum_toSID, 0, 0, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Symbol_Enum_toString, 0, 0, IS_STRING, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_class_ion_Symbol_Enum_toString arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Symbol_Table_System_toSymbol arginfo_class_ion_Symbol_Enum_toSymbol
 
 #define arginfo_class_ion_Symbol_Table_System_toSID arginfo_class_ion_Symbol_Enum_toSID
 
-#define arginfo_class_ion_Symbol_Table_System_toString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Symbol_Table_System_toString arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Symbol_Table_PHP_toSymbol arginfo_class_ion_Symbol_Enum_toSymbol
 
 #define arginfo_class_ion_Symbol_Table_PHP_toSID arginfo_class_ion_Symbol_Enum_toSID
 
-#define arginfo_class_ion_Symbol_Table_PHP_toString arginfo_class_ion_Symbol_Enum_toString
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Symbol___construct, 0, 0, 0)
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_STRING, 1, "null")
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sid, IS_LONG, 0, "-1")
-       ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, importLocation, ion\\Symbol\\ImportLocation, 1, "null")
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Symbol_equals, 0, 1, _IS_BOOL, 0)
-       ZEND_ARG_OBJ_INFO(0, symbol, ion\\Symbol, 0)
-ZEND_END_ARG_INFO()
-
-#define arginfo_class_ion_Symbol___toString arginfo_class_ion_Symbol_Enum_toString
-
-#define arginfo_class_ion_Symbol_toString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Symbol_Table_PHP_toString arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Symbol_Table_getMaxId arginfo_class_ion_Symbol_Enum_toSID
 
@@ -150,9 +150,9 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Decimal_isInt, 0, 0, _IS_BOOL, 0)
 ZEND_END_ARG_INFO()
 
-#define arginfo_class_ion_Decimal___toString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Decimal___toString arginfo_class_ion_Symbol___toString
 
-#define arginfo_class_ion_Decimal_toString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Decimal_toString arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Decimal_toInt arginfo_class_ion_Symbol_Enum_toSID
 
@@ -163,7 +163,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Timestamp___construct, 0, 0, 1)
        ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, timezone, DateTimeZone, 1, "null")
 ZEND_END_ARG_INFO()
 
-#define arginfo_class_ion_Timestamp___toString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Timestamp___toString arginfo_class_ion_Symbol___toString
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ion_Reader_getType, 0, 0, ion\\Type, 0)
 ZEND_END_ARG_INFO()
@@ -178,7 +178,7 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Reader_isInStruct arginfo_class_ion_Decimal_isInt
 
-#define arginfo_class_ion_Reader_getFieldName arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_getFieldName arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Reader_getFieldNameSymbol arginfo_class_ion_Symbol_Enum_toSymbol
 
@@ -215,14 +215,14 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Reader_readSymbol arginfo_class_ion_Symbol_Enum_toSymbol
 
-#define arginfo_class_ion_Reader_readString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_readString arginfo_class_ion_Symbol___toString
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Reader_readStringPart, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_INFO(1, string)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0x1000")
 ZEND_END_ARG_INFO()
 
-#define arginfo_class_ion_Reader_readLob arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_readLob arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Reader_readLobPart arginfo_class_ion_Reader_readStringPart
 
@@ -282,7 +282,7 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Reader_Reader_isInStruct arginfo_class_ion_Decimal_isInt
 
-#define arginfo_class_ion_Reader_Reader_getFieldName arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_Reader_getFieldName arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Reader_Reader_getFieldNameSymbol arginfo_class_ion_Symbol_Enum_toSymbol
 
@@ -310,11 +310,11 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Reader_Reader_readSymbol arginfo_class_ion_Symbol_Enum_toSymbol
 
-#define arginfo_class_ion_Reader_Reader_readString arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_Reader_readString arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Reader_Reader_readStringPart arginfo_class_ion_Reader_readStringPart
 
-#define arginfo_class_ion_Reader_Reader_readLob arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_Reader_readLob arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Reader_Reader_readLobPart arginfo_class_ion_Reader_readStringPart
 
@@ -328,14 +328,14 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Reader_Reader_getValueLength arginfo_class_ion_Symbol_Enum_toSID
 
-#define arginfo_class_ion_Reader_Buffer_getBuffer arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_Buffer_getBuffer arginfo_class_ion_Symbol___toString
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Reader_Buffer_Reader___construct, 0, 0, 1)
        ZEND_ARG_TYPE_INFO(0, buffer, IS_STRING, 0)
        ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, options, ion\\Reader\\Options, 1, "null")
 ZEND_END_ARG_INFO()
 
-#define arginfo_class_ion_Reader_Buffer_Reader_getBuffer arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Reader_Buffer_Reader_getBuffer arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Reader_Stream_getStream arginfo_class_ion_Symbol_Table_Local___construct
 
@@ -441,12 +441,6 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Writer_finish arginfo_class_ion_Symbol_Enum_toSID
 
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Writer_writeOne, 0, 1, IS_VOID, 0)
-       ZEND_ARG_OBJ_INFO(0, reader, ion\\Reader, 0)
-ZEND_END_ARG_INFO()
-
-#define arginfo_class_ion_Writer_writeAll arginfo_class_ion_Writer_writeOne
-
 #define arginfo_class_ion_Writer_Writer_writeNull arginfo_class_ion_Reader_Reader_rewind
 
 #define arginfo_class_ion_Writer_Writer_writeTypedNull arginfo_class_ion_Writer_writeTypedNull
@@ -489,11 +483,7 @@ ZEND_END_ARG_INFO()
 
 #define arginfo_class_ion_Writer_Writer_finish arginfo_class_ion_Symbol_Enum_toSID
 
-#define arginfo_class_ion_Writer_Writer_writeOne arginfo_class_ion_Writer_writeOne
-
-#define arginfo_class_ion_Writer_Writer_writeAll arginfo_class_ion_Writer_writeOne
-
-#define arginfo_class_ion_Writer_Buffer_getBuffer arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Writer_Buffer_getBuffer arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Writer_Buffer_resetBuffer arginfo_class_ion_Reader_Reader_rewind
 
@@ -501,7 +491,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Writer_Buffer_Writer___construct, 0, 0,
        ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, options, ion\\Writer\\Options, 1, "null")
 ZEND_END_ARG_INFO()
 
-#define arginfo_class_ion_Writer_Buffer_Writer_getBuffer arginfo_class_ion_Symbol_Enum_toString
+#define arginfo_class_ion_Writer_Buffer_Writer_getBuffer arginfo_class_ion_Symbol___toString
 
 #define arginfo_class_ion_Writer_Buffer_Writer_resetBuffer arginfo_class_ion_Reader_Reader_rewind
 
@@ -545,10 +535,10 @@ static ZEND_FUNCTION(ion_Symbol_Table_PHP);
 static ZEND_FUNCTION(ion_Symbol_Table_System);
 static ZEND_FUNCTION(ion_serialize);
 static ZEND_FUNCTION(ion_unserialize);
-static ZEND_METHOD(ion_Symbol_ImportLocation, __construct);
 static ZEND_METHOD(ion_Symbol, __construct);
 static ZEND_METHOD(ion_Symbol, equals);
 static ZEND_METHOD(ion_Symbol, __toString);
+static ZEND_METHOD(ion_Symbol_ImportLocation, __construct);
 static ZEND_METHOD(ion_Symbol_Table_Local, __construct);
 static ZEND_METHOD(ion_Symbol_Table_Local, import);
 static ZEND_METHOD(ion_Symbol_Table_Shared, __construct);
@@ -635,8 +625,6 @@ static ZEND_METHOD(ion_Writer_Writer, writeAnnotation);
 static ZEND_METHOD(ion_Writer_Writer, getDepth);
 static ZEND_METHOD(ion_Writer_Writer, flush);
 static ZEND_METHOD(ion_Writer_Writer, finish);
-static ZEND_METHOD(ion_Writer_Writer, writeOne);
-static ZEND_METHOD(ion_Writer_Writer, writeAll);
 static ZEND_METHOD(ion_Writer_Buffer_Writer, __construct);
 static ZEND_METHOD(ion_Writer_Buffer_Writer, getBuffer);
 static ZEND_METHOD(ion_Writer_Buffer_Writer, resetBuffer);
@@ -662,6 +650,15 @@ static const zend_function_entry class_ion_Type_methods[] = {
 };
 
 
+static const zend_function_entry class_ion_Symbol_methods[] = {
+       ZEND_ME(ion_Symbol, __construct, arginfo_class_ion_Symbol___construct, ZEND_ACC_PUBLIC)
+       ZEND_ME(ion_Symbol, equals, arginfo_class_ion_Symbol_equals, ZEND_ACC_PUBLIC)
+       ZEND_ME(ion_Symbol, __toString, arginfo_class_ion_Symbol___toString, ZEND_ACC_PUBLIC)
+       ZEND_MALIAS(ion_Symbol, toString, __toString, arginfo_class_ion_Symbol_toString, ZEND_ACC_PUBLIC)
+       ZEND_FE_END
+};
+
+
 static const zend_function_entry class_ion_Symbol_ImportLocation_methods[] = {
        ZEND_ME(ion_Symbol_ImportLocation, __construct, arginfo_class_ion_Symbol_ImportLocation___construct, ZEND_ACC_PUBLIC)
        ZEND_FE_END
@@ -692,15 +689,6 @@ static const zend_function_entry class_ion_Symbol_Table_PHP_methods[] = {
 };
 
 
-static const zend_function_entry class_ion_Symbol_methods[] = {
-       ZEND_ME(ion_Symbol, __construct, arginfo_class_ion_Symbol___construct, ZEND_ACC_PUBLIC)
-       ZEND_ME(ion_Symbol, equals, arginfo_class_ion_Symbol_equals, ZEND_ACC_PUBLIC)
-       ZEND_ME(ion_Symbol, __toString, arginfo_class_ion_Symbol___toString, ZEND_ACC_PUBLIC)
-       ZEND_MALIAS(ion_Symbol, toString, __toString, arginfo_class_ion_Symbol_toString, ZEND_ACC_PUBLIC)
-       ZEND_FE_END
-};
-
-
 static const zend_function_entry class_ion_Symbol_Table_methods[] = {
        ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Symbol_Table, getMaxId, arginfo_class_ion_Symbol_Table_getMaxId, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
        ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Symbol_Table, add, arginfo_class_ion_Symbol_Table_add, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
@@ -928,8 +916,6 @@ static const zend_function_entry class_ion_Writer_methods[] = {
        ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Writer, getDepth, arginfo_class_ion_Writer_getDepth, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
        ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Writer, flush, arginfo_class_ion_Writer_flush, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
        ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Writer, finish, arginfo_class_ion_Writer_finish, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
-       ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Writer, writeOne, arginfo_class_ion_Writer_writeOne, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
-       ZEND_ABSTRACT_ME_WITH_FLAGS(ion_Writer, writeAll, arginfo_class_ion_Writer_writeAll, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
        ZEND_FE_END
 };
 
@@ -956,8 +942,6 @@ static const zend_function_entry class_ion_Writer_Writer_methods[] = {
        ZEND_ME(ion_Writer_Writer, getDepth, arginfo_class_ion_Writer_Writer_getDepth, ZEND_ACC_PUBLIC)
        ZEND_ME(ion_Writer_Writer, flush, arginfo_class_ion_Writer_Writer_flush, ZEND_ACC_PUBLIC)
        ZEND_ME(ion_Writer_Writer, finish, arginfo_class_ion_Writer_Writer_finish, ZEND_ACC_PUBLIC)
-       ZEND_ME(ion_Writer_Writer, writeOne, arginfo_class_ion_Writer_Writer_writeOne, ZEND_ACC_PUBLIC)
-       ZEND_ME(ion_Writer_Writer, writeAll, arginfo_class_ion_Writer_Writer_writeAll, ZEND_ACC_PUBLIC)
        ZEND_FE_END
 };
 
@@ -1086,6 +1070,35 @@ static zend_class_entry *register_class_ion_Type(void)
        return class_entry;
 }
 
+static zend_class_entry *register_class_ion_Symbol(void)
+{
+       zend_class_entry ce, *class_entry;
+
+       INIT_NS_CLASS_ENTRY(ce, "ion", "Symbol", class_ion_Symbol_methods);
+       class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+       zval property_value_default_value;
+       ZVAL_UNDEF(&property_value_default_value);
+       zend_string *property_value_name = zend_string_init("value", sizeof("value") - 1, 1);
+       zend_declare_typed_property(class_entry, property_value_name, &property_value_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));
+       zend_string_release(property_value_name);
+
+       zval property_sid_default_value;
+       ZVAL_UNDEF(&property_sid_default_value);
+       zend_string *property_sid_name = zend_string_init("sid", sizeof("sid") - 1, 1);
+       zend_declare_typed_property(class_entry, property_sid_name, &property_sid_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+       zend_string_release(property_sid_name);
+
+       zend_string *property_importLocation_class_ion_Symbol_ImportLocation = zend_string_init("ion\\Symbol\\ImportLocation", sizeof("ion\\Symbol\\ImportLocation")-1, 1);
+       zval property_importLocation_default_value;
+       ZVAL_UNDEF(&property_importLocation_default_value);
+       zend_string *property_importLocation_name = zend_string_init("importLocation", sizeof("importLocation") - 1, 1);
+       zend_declare_typed_property(class_entry, property_importLocation_name, &property_importLocation_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_importLocation_class_ion_Symbol_ImportLocation, 0, MAY_BE_NULL));
+       zend_string_release(property_importLocation_name);
+
+       return class_entry;
+}
+
 static zend_class_entry *register_class_ion_Symbol_ImportLocation(void)
 {
        zend_class_entry ce, *class_entry;
@@ -1229,35 +1242,6 @@ static zend_class_entry *register_class_ion_Symbol_Table_PHP(zend_class_entry *c
        return class_entry;
 }
 
-static zend_class_entry *register_class_ion_Symbol(void)
-{
-       zend_class_entry ce, *class_entry;
-
-       INIT_NS_CLASS_ENTRY(ce, "ion", "Symbol", class_ion_Symbol_methods);
-       class_entry = zend_register_internal_class_ex(&ce, NULL);
-
-       zval property_value_default_value;
-       ZVAL_UNDEF(&property_value_default_value);
-       zend_string *property_value_name = zend_string_init("value", sizeof("value") - 1, 1);
-       zend_declare_typed_property(class_entry, property_value_name, &property_value_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL));
-       zend_string_release(property_value_name);
-
-       zval property_sid_default_value;
-       ZVAL_UNDEF(&property_sid_default_value);
-       zend_string *property_sid_name = zend_string_init("sid", sizeof("sid") - 1, 1);
-       zend_declare_typed_property(class_entry, property_sid_name, &property_sid_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
-       zend_string_release(property_sid_name);
-
-       zend_string *property_importLocation_class_ion_Symbol_ImportLocation = zend_string_init("ion\\Symbol\\ImportLocation", sizeof("ion\\Symbol\\ImportLocation")-1, 1);
-       zval property_importLocation_default_value;
-       ZVAL_UNDEF(&property_importLocation_default_value);
-       zend_string *property_importLocation_name = zend_string_init("importLocation", sizeof("importLocation") - 1, 1);
-       zend_declare_typed_property(class_entry, property_importLocation_name, &property_importLocation_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_importLocation_class_ion_Symbol_ImportLocation, 0, MAY_BE_NULL));
-       zend_string_release(property_importLocation_name);
-
-       return class_entry;
-}
-
 static zend_class_entry *register_class_ion_Symbol_Table(void)
 {
        zend_class_entry ce, *class_entry;
index c7212298f935527e19a43b597f10fb0efe616b52..722efe6bd4a4ca63ff9d05c9f20fb20cf0d68373 100644 (file)
@@ -404,7 +404,7 @@ LOCAL void *php_ion_obj_ex(void *obj, ptrdiff_t offset) {
 
 #define ION_CHECK_RETURN(r, err, ...) do { \
        iERR __err = err; \
-       if (__err) { \
+       if (UNEXPECTED(__err)) { \
                zend_throw_exception_ex(spl_ce_RuntimeException, __err, "%s: %s", ion_error_to_str(__err), #err); \
                __VA_ARGS__; \
                return r; \
@@ -415,14 +415,14 @@ LOCAL void *php_ion_obj_ex(void *obj, ptrdiff_t offset) {
        ION_CHECK_RETURN(, err, __VA_ARGS__)
 
 #define ION_CATCH(...) do { \
-       if (EG(exception)) { \
+       if (UNEXPECTED(EG(exception))) { \
                __VA_ARGS__; \
                return; \
        } \
 } while (0)
 
 #define PTR_CHECK_RETURN(ret, ptr, ...) do { \
-       if (!(ptr)) { \
+       if (UNEXPECTED(!(ptr))) { \
                zend_throw_error(NULL, "Uninitialized object"); \
                __VA_ARGS__; \
                return ret; \
@@ -455,15 +455,6 @@ LOCAL void update_property_obj(zend_object *obj, const char *n, size_t l, zend_o
        zend_update_property(obj->ce, obj, n, l, &zobj);
 }
 
-LOCAL zend_object *get_property_obj(zend_object *obj, const char *n, size_t l, int type)
-{
-       zval tmp, *zv = zend_read_property(obj->ce, obj, n, l, 0, &tmp);
-       if (zv && type & Z_TYPE_P(zv)) {
-               return Z_PTR_P(zv);
-       }
-       return NULL;
-}
-
 #define RETURN_IONTYPE(typ) do { \
        zend_object *__zo = php_ion_type_fetch(typ); \
        if (UNEXPECTED(!__zo)) { \
@@ -642,13 +633,17 @@ LOCAL void php_ion_symbol_table_ctor(php_ion_symbol_table *obj)
 {
        OBJ_CHECK(obj);
 
-       ION_STRING is;
-       if (IERR_OK == ion_symbol_table_get_name(obj->tab, &is)) {
-               zend_update_property_stringl(obj->std.ce, &obj->std, ZEND_STRL("name"), (char *) is.value, is.length);
-       }
-       int32_t iv;
-       if (IERR_OK == ion_symbol_table_get_version(obj->tab, &iv)) {
-               zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("version"), iv);
+       ION_SYMBOL_TABLE_TYPE typ = ist_EMPTY;
+       ion_symbol_table_get_type(obj->tab, &typ);
+       if (typ != ist_LOCAL) {
+               ION_STRING is;
+               if (IERR_OK == ion_symbol_table_get_name(obj->tab, &is)) {
+                       zend_update_property_stringl(obj->std.ce, &obj->std, ZEND_STRL("name"), (char *) is.value, is.length);
+               }
+               int32_t iv;
+               if (IERR_OK == ion_symbol_table_get_version(obj->tab, &iv)) {
+                       zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("version"), iv);
+               }
        }
 }
 
@@ -910,7 +905,7 @@ LOCAL zend_string *php_dt_format_from_precision(uint8_t precision)
        case ION_TS_YEAR:
                return php_ion_timestamp_format_fetch(g_intern_str.Year);
        default:
-               return zend_one_char_string['c'];
+               return ZSTR_CHAR('c');
        }
 }
 
@@ -1120,11 +1115,9 @@ LOCAL void php_ion_catalog_symbol_table_zval(php_ion_catalog *obj, ION_SYMBOL_TA
                }
        }
 
-       php_error_docref(NULL, E_NOTICE, "Previously unknown ion\\Symbol\\Table encountered: %s", key->val);
-
        object_init_ex(return_value, ce_Symbol_Table_Shared);
        php_ion_symbol_table *o_tab = php_ion_obj(symbol_table, Z_OBJ_P(return_value));
-       OBJ_CHECK(o_tab, zend_string_release(key));
+       o_tab->tab = tab;
        php_ion_symbol_table_ctor(o_tab);
 
        if (ztabs) {
@@ -1691,8 +1684,8 @@ LOCAL void php_ion_serialize_object_std(php_ion_serializer *ser, zend_object *zo
 
 LOCAL void php_ion_serialize_object_lob(php_ion_serializer *ser, zend_object *zobject)
 {
-       zval tmp_type, *type = zend_read_property(NULL, zobject, ZEND_STRL("type"), 0, &tmp_type);
-       zval tmp_value, *value = zend_read_property(NULL, zobject, ZEND_STRL("value"), 0, &tmp_value);
+       zval tmp_type, *type = zend_read_property_ex(NULL, zobject, ZSTR_KNOWN(ZEND_STR_TYPE), 0, &tmp_type);
+       zval tmp_value, *value = zend_read_property_ex(NULL, zobject, ZSTR_KNOWN(ZEND_STR_VALUE), 0, &tmp_value);
        switch (Z_LVAL_P(zend_enum_fetch_case_value(Z_OBJ_P(type)))) {
        case tid_BLOB_INT:
                ION_CHECK(ion_writer_write_blob(ser->writer, (BYTE *) Z_STRVAL_P(value), Z_STRLEN_P(value)));
@@ -2098,7 +2091,7 @@ LOCAL void php_ion_unserialize_field_name(php_ion_unserializer *ser, zend_string
                *key = zend_string_init(ptr, end - ptr, 0);
                break;
        case 1:
-               *key = zend_one_char_string[*name.value];
+               *key = ZSTR_CHAR(*name.value);
                break;
        default:
                if (is_prop) {
index 1ee713fd5b459a23ad1c335f9288ac3ef1bf1810..a30db7ef1957913b44716274b641f815f916de6f 100644 (file)
@@ -8,7 +8,7 @@ TEST
 
 $c = new ion\Catalog;
 var_dump(count($c));
-$c->add(ion\Symbol\Table\PHP());
+$c->add($php = ion\Symbol\Table\PHP());
 var_dump(count($c));
 $c->add(new ion\Symbol\Table\Shared("shared", 1, ["foo", "bar", "baz"]));
 var_dump(count($c));
@@ -23,7 +23,14 @@ var_dump($c->findBest("shared"));
 $c->remove("shared");
 var_dump(count($c));
 
-var_dump(clone $c);
+var_dump($d = clone $c);
+$c->remove($php);
+$c->remove($php);
+unset($c);
+var_dump(count($d));
+var_dump($d->find("PHP", 1));
+$d->remove($php);
+var_dump(count($d));
 ?>
 DONE
 --EXPECTF--
@@ -121,4 +128,15 @@ object(ion\Catalog)#%d (1) {
   array(0) {
   }
 }
+int(1)
+object(ion\Symbol\Table\Shared)#%d (3) {
+  ["name"]=>
+  string(3) "PHP"
+  ["version"]=>
+  int(1)
+  ["symbols":"ion\Symbol\Table\Shared":private]=>
+  array(0) {
+  }
+}
+int(0)
 DONE
index b3a9adad9565832eaa817b26e01aa52f281a642b..665dd534690508fd54c4954b2288405ba792c70b 100644 (file)
@@ -9,6 +9,7 @@ var_dump(ion\Decimal\Context::Dec32());
 var_dump(ion\Decimal\Context::Dec64());
 var_dump(ion\Decimal\Context::Dec128());
 var_dump(ion\Decimal\Context::DecMax());
+var_dump(ion\Decimal\Context::DecMax(ion\Decimal\Context\Rounding::Down05Up));
 var_dump(clone new ion\Decimal\Context(12, 999, -999, ion\Decimal\Context\Rounding::Down05Up, true));
 ?>
 DONE
@@ -62,6 +63,18 @@ object(ion\Decimal\Context)#%d (5) {
   ["clamp"]=>
   bool(false)
 }
+object(ion\Decimal\Context)#%d (5) {
+  ["digits"]=>
+  int(999999999)
+  ["eMax"]=>
+  int(999999999)
+  ["eMin"]=>
+  int(-999999999)
+  ["round"]=>
+  enum(ion\Decimal\Context\Rounding::Down05Up)
+  ["clamp"]=>
+  bool(false)
+}
 object(ion\Decimal\Context)#%d (5) {
   ["digits"]=>
   int(12)
index 12c70e9d8d3980ef89c4ad24f23420616cbeb8ef..9fdc8627682db22c91dabeab77fa9ecdf52ed792 100644 (file)
@@ -44,6 +44,9 @@ var_dump($local->add("sym4"));
 var_dump($local->find("sym4"));
 var_dump($local->findLocal("sym4"));
 var_dump($local->getMaxId());
+
+var_dump(clone $local);
+var_dump(clone $shared);
 ?>
 DONE
 --EXPECTF--
@@ -159,4 +162,21 @@ object(ion\Symbol)#%d (3) {
   NULL
 }
 int(23)
+object(ion\Symbol\Table\Local)#%d (2) {
+  ["imports":"ion\Symbol\Table\Local":private]=>
+  array(0) {
+  }
+  ["symbols":"ion\Symbol\Table\Local":private]=>
+  array(0) {
+  }
+}
+object(ion\Symbol\Table\Shared)#%d (3) {
+  ["name"]=>
+  string(6) "shared"
+  ["version"]=>
+  int(1)
+  ["symbols":"ion\Symbol\Table\Shared":private]=>
+  array(0) {
+  }
+}
 DONE
index e92905bbfd7229c5f47187cf7260359f82a96fd3..88ca90f0d1fdee7709b1dd6740acec2340e31a18 100644 (file)
@@ -21,6 +21,7 @@ var_dump($t=new Timestamp(Timestamp\Precision::Min, datetime:"2020-10-01"),(stri
 $t->setTimezone(new DateTimeZone("Europe/Helsinki"));
 var_dump((string) $t);
 var_dump($t=new Timestamp(Timestamp\Precision::Day, "!Y-m", "2000-10"),(string)$t);
+var_dump($t=new Timestamp(Timestamp\Precision::MinTZ, Timestamp\Format::MinTZ, "2000-10-20T11:11CET"),(string)$t);
 var_dump(ion\unserialize(ion\serialize(clone new ion\Timestamp(ion\Timestamp\Precision::Sec, DateTime::RFC3339, "1971-02-03T04:05:06Z"))));
 ?>
 DONE
@@ -80,6 +81,19 @@ object(ion\Timestamp)#%d (5) {
   string(3) "CET"
 }
 string(11) "2000-10-01T"
+object(ion\Timestamp)#%d (5) {
+  ["precision"]=>
+  int(151)
+  ["format"]=>
+  string(11) "Y-m-d\TH:iP"
+  ["date"]=>
+  string(26) "2000-10-20 11:11:00.000000"
+  ["timezone_type"]=>
+  int(2)
+  ["timezone"]=>
+  string(3) "CET"
+}
+string(22) "2000-10-20T11:11+01:00"
 object(ion\Timestamp)#%d (3) {
   ["precision"]=>
   int(55)
diff --git a/tests/Writer.phpt b/tests/Writer.phpt
new file mode 100644 (file)
index 0000000..816803c
--- /dev/null
@@ -0,0 +1,95 @@
+--TEST--
+ion\Writer
+--EXTENSIONS--
+ion
+--INI--
+date.timezone=UTC
+--FILE--
+TEST
+<?php
+
+$w = new ion\Writer\Stream\Writer(STDOUT,
+       new ion\Writer\Options(flushEveryValue: true));
+
+$w->writeNull();
+echo "\n";
+$w->writeTypedNull(ion\Type::Int);
+echo "\n";
+$w->writeBool(true);
+echo "\n";
+$w->writeBool(false);
+echo "\n";
+$w->writeInt(0);
+echo "\n";
+$w->writeInt(123);
+echo "\n";
+$w->writeInt(-123);
+echo "\n";
+$w->writeInt("12345678901234567890");
+echo "\n";
+$w->writeFloat(1e0);
+echo "\n";
+$w->writeFloat(-.0);
+echo "\n";
+$w->writeDecimal("1.23");
+echo "\n";
+$w->writeDecimal(new ion\Decimal(-123));
+echo "\n";
+$w->writeTimestamp("2001T");
+echo "\n";
+$w->writeTimestamp(new ion\Timestamp(ion\Timestamp\Precision::Frac));
+echo "\n";
+$w->writeSymbol("a");
+echo "\n";
+$w->writeSymbol(new ion\Symbol("b"));
+echo "\n";
+$w->writeString("abc");
+echo "\n";
+$w->writeCLob("clob");
+echo "\n";
+$w->writeBLob("blob");
+echo "\n";
+$w->startLob(ion\Type::CLob);
+$w->appendLob("clob");
+$w->finishLob();
+echo "\n";
+$w->startContainer(ion\Type::Struct);
+$w->writeFieldName("prop");
+$w->writeAnnotation(ion\Symbol\Table\PHP::Property->toSymbol());
+$w->writeInt($w->getDepth());
+$w->writeFieldName(new ion\Symbol("priv"));
+$w->writeAnnotation("a","b","c");
+$w->writeInt($w->getDepth());
+$w->finishContainer();
+echo "\n";
+$w->writeInt($w->getDepth());
+$w->finish();
+echo "\n";
+
+?>
+DONE
+--EXPECTF--
+TEST
+null
+ null.int
+ true
+ false
+ 0
+ 123
+ -123
+ 12345678901234567890
+ 1e+0
+ -0e0
+ 1.23
+ -123d0
+ 2001T
+ %r\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+%r-00:00
+ a
+ b
+ "abc"
+ {{"clob"}}
+ {{YmxvYg==}}
+ {{"clob"}}
+ {prop:p::1,priv:a::b::c::1}
+ 0
+DONE
index f6a066b8bfa6fb708a860dc2e8eaa369fabeeb89..b673ac71d9a5cf0a0ab50853db4ef98c3372efda 100644 (file)
@@ -13,6 +13,7 @@ $o = new ion\Writer\Options(
        decimalContext: ion\Decimal\Context::Dec64(),
        outputBinary: true,
        maxContainerDepth: 20,
+       allocationPageSize: 0x20000
 );
 var_dump($o, clone $o);
 ?>
@@ -128,7 +129,7 @@ object(ion\Writer\Options)#%d (15) {
   ["tempBufferSize"]=>
   int(16384)
   ["allocationPageSize"]=>
-  int(65536)
+  int(131072)
 }
 object(ion\Writer\Options)#%d (15) {
   ["catalog"]=>
@@ -175,6 +176,6 @@ object(ion\Writer\Options)#%d (15) {
   ["tempBufferSize"]=>
   int(16384)
   ["allocationPageSize"]=>
-  int(65536)
+  int(131072)
 }
 DONE
diff --git a/tests/serialize/multisequence.phpt b/tests/serialize/multisequence.phpt
new file mode 100644 (file)
index 0000000..f4f6d5b
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+ion\serialize/multi sequence
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+echo ion\serialize([1,2,3], new \ion\Serializer\PHP(multiSequence: true)), "\n";
+?>
+DONE
+--EXPECT--
+TEST
+1 2 3
+DONE
diff --git a/tests/unserialize/multisequence.phpt b/tests/unserialize/multisequence.phpt
new file mode 100644 (file)
index 0000000..e52e83e
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+ion\unserialize/multi sequence
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+var_dump(ion\unserialize("1 2 3", new \ion\Unserializer\PHP(multiSequence: true)));
+?>
+DONE
+--EXPECT--
+TEST
+array(3) {
+  [0]=>
+  int(1)
+  [1]=>
+  int(2)
+  [2]=>
+  int(3)
+}
+DONE