} \
}
+#define Z_PARAM_HASH_OR_INSTANCE_OF_NULL(za_dest, zo_inst, ce_inst) \
+ Z_PARAM_PROLOGUE(0, 0) { \
+ zval *_arr; \
+ if (zend_parse_arg_array(_arg, &(_arr), true, 0)) { \
+ za_dest = Z_ARRVAL_P(_arr); \
+ } else { \
+ zend_object *_obj = NULL; \
+ if (zend_parse_arg_obj(_arg, &_obj, ce, true)) { \
+ za_dest = _obj->handlers->get_properties(_obj); \
+ } else if (zend_parse_arg_obj(_arg, &(zo_inst), ce_inst, true)) { \
+ } else { \
+ _error = ce->name->val; \
+ _error_code = ZPP_ERROR_WRONG_CLASS_OR_NULL; \
+ break; \
+ } \
+ } \
+ }
+
static ZEND_METHOD(ion_Symbol_ImportLocation, __construct)
{
php_ion_symbol_iloc *obj = php_ion_obj(symbol_iloc, Z_OBJ_P(ZEND_THIS));
update_property_obj(Z_OBJ_P(ZEND_THIS), ZEND_STRL("type"), type);
zend_update_property_str(Z_OBJCE_P(ZEND_THIS), Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), value);
}
-static ZEND_METHOD(ion_Reader_Options, __construct)
+static ZEND_METHOD(ion_Reader_Reader, __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 max_depth = 10, max_ann = 10, ann_buf_siz = 0x4000, tmp_buf_siz = 0x4000;
+ php_ion_reader *obj = php_ion_obj(reader, Z_OBJ_P(ZEND_THIS));
- PTR_CHECK(opt);
+ PTR_CHECK(obj);
- ZEND_PARSE_PARAMETERS_START(0, 9)
+ zval *zstream = NULL;
+ zend_bool ret_sys_val = false, skip_validation = false;
+ zend_long max_depth = 10, max_ann = 10, ann_buf_siz = 0x4000, tmp_buf_siz = 0x4000;
+ ZEND_PARSE_PARAMETERS_START(1, 10)
+ Z_PARAM_PROLOGUE(0, 0)
+ if (!instanceof_function(obj->std.ce, ce_Reader_Buffer) &&
+ zend_parse_arg_resource(_arg, &zstream, 0)) {
+ obj->type = STREAM_READER;
+ php_stream_from_zval_no_verify(obj->stream.ptr, zstream);
+ PTR_CHECK(obj->stream.ptr);
+ GC_ADDREF(obj->stream.ptr->res);
+ } else if (!instanceof_function(obj->std.ce, ce_Reader_Stream) &&
+ zend_parse_arg_str(_arg, &obj->buffer, 0, _i)) {
+ obj->type = BUFFER_READER;
+ zend_string_addref(obj->buffer);
+ } else {
+ _error_code = ZPP_ERROR_WRONG_ARG;
+ _error = "of type string or resource";
+ break;
+ }
Z_PARAM_OPTIONAL
// public readonly ?\ion\Catalog $catalog = null,
- Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt->cat, ce_Catalog)
+ Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj->cat, ce_Catalog)
// public readonly ?\ion\Decimal\Context $decimalContext = null,
- Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt->dec_ctx, ce_Decimal_Context)
+ Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj->dec_ctx, ce_Decimal_Context)
// public readonly ?\Closure $onContextChange = null,
- Z_PARAM_OBJ_OF_CLASS_OR_NULL(opt->cb, zend_ce_closure);
+ Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj->cb, zend_ce_closure);
// public readonly bool $returnSystemValues = false,
Z_PARAM_BOOL(ret_sys_val)
// public readonly int $maxContainerDepth = 10,
Z_PARAM_BOOL(skip_validation)
ZEND_PARSE_PARAMETERS_END();
- if (opt->cb) {
- zval zcb;
- ZVAL_OBJ(&zcb, opt->cb);
- zend_fcall_info_init(&zcb, 0, &opt->ccn.fci, &opt->ccn.fcc, NULL, NULL);
- opt->opt.context_change_notifier.context = &opt->ccn;
- update_property_obj(&opt->std, ZEND_STRL("onContextChange"), opt->cb);
- } else {
- zend_update_property_null(NULL, &opt->std, ZEND_STRL("onContextChange"));
- }
- if (opt->cat) {
- update_property_obj(&opt->std, ZEND_STRL("catalog"), opt->cat);
- opt->opt.pcatalog = php_ion_obj(catalog, opt->cat)->cat;
- } else {
- zend_update_property_null(NULL, &opt->std, ZEND_STRL("catalog"));
- }
- if (opt->dec_ctx) {
- update_property_obj(&opt->std, ZEND_STRL("decimalContext"), opt->dec_ctx);
- opt->opt.decimal_context = &php_ion_obj(decimal_ctx, opt->dec_ctx)->ctx;
- } else {
- zend_update_property_null(NULL, &opt->std, ZEND_STRL("decimalContext"));
- }
- 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("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("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);
+ obj->options.return_system_values = ret_sys_val;
+ obj->options.max_container_depth = (SIZE) max_depth;
+ obj->options.max_annotation_count = (SIZE) max_ann;
+ obj->options.max_annotation_buffered = (SIZE) ann_buf_siz;
+ obj->options.chunk_threshold = (SIZE) tmp_buf_siz;
+ obj->options.user_value_threshold = (SIZE) tmp_buf_siz;
+ obj->options.symbol_threshold = (SIZE) tmp_buf_siz;
+ obj->options.skip_character_validation = skip_validation;
+
+ php_ion_reader_ctor(obj);
}
static ZEND_METHOD(ion_Reader_Reader, hasChildren)
{
ZEND_PARSE_PARAMETERS_NONE();
int32_t count, max;
- if (obj->opt) {
- max = php_ion_obj(reader_options, obj->opt)->opt.max_annotation_count;
+ if (obj->options.max_annotation_count) {
+ max = obj->options.max_annotation_count;
} else {
max = 10;
}
ZEND_PARSE_PARAMETERS_NONE();
int32_t count, max;
- if (obj->opt) {
- max = php_ion_obj(reader_options, obj->opt)->opt.max_annotation_count;
+ if (obj->options.max_annotation_count) {
+ max = obj->options.max_annotation_count;
} else {
max = 10;
}
ZEND_PARSE_PARAMETERS_NONE();
- php_ion_reader_read_timestamp(obj->reader, obj->opt ? &php_ion_obj(reader_options, obj->opt)->opt : NULL, return_value);
+ php_ion_reader_read_timestamp(obj->reader, &obj->options, return_value);
}
static ZEND_METHOD(ion_Reader_Reader, readSymbol)
{
ION_CHECK(ion_reader_get_value_length(obj->reader, &len));
RETURN_LONG(len);
}
-static ZEND_METHOD(ion_Reader_Buffer_Reader, __construct)
-{
- php_ion_reader *obj = php_ion_obj(reader, Z_OBJ_P(ZEND_THIS));
- PTR_CHECK(obj);
-
- zend_string *zstr;
- zval *za_opt = NULL;
- ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_STR(zstr)
- Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(obj->opt, ce_Reader_Options, ce_Reader_Options, za_opt)
- ZEND_PARSE_PARAMETERS_END();
- if (za_opt) {
- update_property_obj_ex(ce_Reader_Reader, &obj->std, ZEND_STRL("options"), obj->opt);
- OBJ_RELEASE(obj->opt);
- }
-
- obj->type = BUFFER_READER;
- obj->buffer = zend_string_copy(zstr);
- php_ion_reader_ctor(obj);
-}
static ZEND_METHOD(ion_Reader_Buffer_Reader, getBuffer)
{
php_ion_reader *obj = php_ion_obj(reader, Z_OBJ_P(ZEND_THIS));
RETURN_STR_COPY(obj->buffer);
}
-static ZEND_METHOD(ion_Reader_Stream_Reader, __construct)
-{
- php_ion_reader *obj = php_ion_obj(reader, Z_OBJ_P(ZEND_THIS));
- PTR_CHECK(obj);
-
- zval *zstream, *za_opt = NULL;
- ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_RESOURCE(zstream)
- Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(obj->opt, ce_Reader_Options, ce_Reader_Options, za_opt)
- ZEND_PARSE_PARAMETERS_END();
- if (za_opt) {
- update_property_obj_ex(ce_Reader_Reader, &obj->std, ZEND_STRL("options"), obj->opt);
- OBJ_RELEASE(obj->opt);
- }
-
- obj->type = STREAM_READER;
- php_stream_from_zval_no_verify(obj->stream.ptr, zstream);
-
- php_ion_reader_ctor(obj);
-}
static ZEND_METHOD(ion_Reader_Stream_Reader, getStream)
{
php_ion_reader *obj = php_ion_obj(reader, Z_OBJ_P(ZEND_THIS));
PTR_CHECK(obj->stream.ptr);
Z_ADDREF_P(zstream);
}
-static ZEND_METHOD(ion_Writer_Options, __construct)
+
+static void _ion_Writer_Writer___construct(bool stream_writer, INTERNAL_FUNCTION_PARAMETERS)
{
- php_ion_writer_options *obj = php_ion_obj(writer_options, Z_OBJ_P(ZEND_THIS));
+ php_ion_writer *obj = php_ion_obj(writer, Z_OBJ_P(ZEND_THIS));
PTR_CHECK(obj);
zend_bool binary = false, compact_floats = false, escape = false, pretty = false,
tabs = true, flush = false;
zend_long indent = 2, max_depth = 10, max_ann = 10, temp = 0x4000;
- ZEND_PARSE_PARAMETERS_START(0, 12)
+ ZEND_PARSE_PARAMETERS_START(0 + stream_writer, 12 + stream_writer)
+ if (!stream_writer) {
+ obj->type = BUFFER_WRITER;
+ } else {
+ Z_PARAM_PROLOGUE(0, 0)
+ obj->type = STREAM_WRITER;
+ zval *zstream = NULL;
+ if (zend_parse_arg_resource(_arg, &zstream, 0)) {
+ php_stream_from_zval_no_verify(obj->stream.ptr, zstream);
+ PTR_CHECK(obj->stream.ptr);
+ GC_ADDREF(obj->stream.ptr->res);
+ } else {
+ _error_code = Z_EXPECTED_RESOURCE;
+ _error = "of type resource";
+ break;
+ }
+ }
Z_PARAM_OPTIONAL
//public readonly ?\ion\Catalog $catalog = null,
Z_PARAM_OBJ_OF_CLASS_OR_NULL(obj->cat, ce_Catalog)
Z_PARAM_LONG(temp)
ZEND_PARSE_PARAMETERS_END();
- if (obj->cat) {
- update_property_obj(&obj->std, ZEND_STRL("catalog"), obj->cat);
- obj->opt.pcatalog = php_ion_obj(catalog, obj->cat)->cat;
- } else {
- zend_update_property_null(NULL, &obj->std, ZEND_STRL("catalog"));
- }
- if (obj->dec_ctx) {
- update_property_obj(&obj->std, ZEND_STRL("decimalContext"), obj->dec_ctx);
- obj->opt.decimal_context = &php_ion_obj(decimal_ctx, obj->dec_ctx)->ctx;
- } else {
- zend_update_property_null(NULL, &obj->std, ZEND_STRL("decimalContext"));
- }
- zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("outputBinary"),
- obj->opt.output_as_binary = binary);
- zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("compactFloats"),
- obj->opt.compact_floats = compact_floats);
- zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("escapeNonAscii"),
- obj->opt.escape_all_non_ascii = escape);
- zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("prettyPrint"),
- obj->opt.pretty_print = pretty);
- zend_update_property_bool(obj->std.ce, &obj->std, ZEND_STRL("indentTabs"),
- 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("flushEveryValue"),
- obj->opt.flush_every_value = flush);
- zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("maxContainerDepth"),
- obj->opt.max_container_depth = (SIZE) max_depth);
- zend_update_property_long(obj->std.ce, &obj->std, ZEND_STRL("maxAnnotations"),
- 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);
+ obj->options.output_as_binary = binary;
+ obj->options.compact_floats = compact_floats;
+ obj->options.escape_all_non_ascii = escape;
+ obj->options.pretty_print = pretty;
+ obj->options.indent_with_tabs = tabs;
+ obj->options.indent_size = (SIZE) indent;
+ obj->options.flush_every_value = flush;
+ obj->options.max_container_depth = (SIZE) max_depth;
+ obj->options.max_annotation_count = (SIZE) max_ann;
+ obj->options.temp_buffer_size = (SIZE) temp;
+
+ php_ion_writer_ctor(obj);
+}
+
+static ZEND_METHOD(ion_Writer_Writer, __construct)
+{
+ _ion_Writer_Writer___construct(false, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
static ZEND_METHOD(ion_Writer_Writer, writeNull)
{
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;
- }
+ if (obj->options.decimal_context) {
+ ctx = obj->options.decimal_context;
}
ION_CHECK(ion_decimal_from_string(&dec, dec_str->val, ctx));
ION_CHECK(ion_writer_write_ion_decimal(obj->writer, &dec));
Z_PARAM_OBJ_OF_CLASS_OR_STR(ts_obj, ce_Timestamp, ts_str)
ZEND_PARSE_PARAMETERS_END();
- decContext *ctx = NULL;
- if (obj->opt) {
- ctx = php_ion_obj(reader_options, obj->opt)->opt.decimal_context;
- }
-
+ decContext *ctx = obj->options.decimal_context;
ION_TIMESTAMP tmp = {0};
if (ts_str) {
SIZE used;
}
static ZEND_METHOD(ion_Writer_Buffer_Writer, __construct)
{
- php_ion_writer *obj = php_ion_obj(writer, Z_OBJ_P(ZEND_THIS));
- PTR_CHECK(obj);
-
- zval *za_opt = NULL;
- ZEND_PARSE_PARAMETERS_START(0, 1)
- Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(obj->opt, ce_Writer_Options, ce_Writer_Options, za_opt)
- ZEND_PARSE_PARAMETERS_END();
-
- obj->type = BUFFER_WRITER;
- php_ion_writer_ctor(obj);
- if (za_opt) {
- OBJ_RELEASE(obj->opt);
- }
+ _ion_Writer_Writer___construct(false, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
static ZEND_METHOD(ion_Writer_Buffer_Writer, getBuffer)
{
}
static ZEND_METHOD(ion_Writer_Stream_Writer, __construct)
{
- php_ion_writer *obj = php_ion_obj(writer, Z_OBJ_P(ZEND_THIS));
- PTR_CHECK(obj);
-
- zval *zstream, *za_opt = NULL;
- ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_RESOURCE(zstream)
- Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(obj->opt, ce_Writer_Options, ce_Writer_Options, za_opt)
- ZEND_PARSE_PARAMETERS_END();
-
- obj->type = STREAM_WRITER;
- php_stream_from_zval_no_verify(obj->stream.ptr, zstream);
-
- php_ion_writer_ctor(obj);
- if (za_opt) {
- OBJ_RELEASE(obj->opt);
- }
+ _ion_Writer_Writer___construct(true, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
static ZEND_METHOD(ion_Writer_Stream_Writer, getStream)
{
{
zend_object *obj = Z_OBJ_P(ZEND_THIS);
- zval *data, *za_opt = NULL;
+ zval *data;
zend_object *zo_wri = NULL;
+ zend_array *za_named = NULL;
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_ZVAL(data)
Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(zo_wri, ce_Writer, ce_Writer_Options, za_opt)
+ Z_PARAM_PROLOGUE(0, 0)
+ if (!zend_parse_arg_obj(_arg, &zo_wri, ce_Writer, true)) {
+ if (!zend_parse_arg_array_ht(_arg, &za_named, false, false, false)) {
+ _error_code = ZPP_ERROR_WRONG_ARG;
+ _error = "of type array or \\ion\\Writer";
+ break;
+ }
+ zo_wri = create_ion_Writer_Writer(ce_Writer_Buffer_Writer);
+ call_constructor(zo_wri, 0, NULL, za_named);
+ ION_CATCH(OBJ_RELEASE(zo_wri));
+ }
ZEND_PARSE_PARAMETERS_END();
php_ion_serializer *ser = php_ion_obj(serializer, obj);
php_ion_serialize(ser, data, return_value);
ser->wri = NULL;
- if (za_opt) {
+ if (za_named) {
OBJ_RELEASE(zo_wri);
}
}
static ZEND_FUNCTION(ion_serialize)
{
- zval *data, *za_ser = NULL;
+ zval *data;
zend_object *zo_ser = NULL;
+ zend_array *za_named = NULL;
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_ZVAL(data)
Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(zo_ser, ce_Serializer, ce_Serializer_Serializer, za_ser)
+ Z_PARAM_PROLOGUE(0, 0)
+ if (!zend_parse_arg_obj(_arg, &zo_ser, ce_Serializer, true)) {
+ if (!zend_parse_arg_array_ht(_arg, &za_named, false, false, false)) {
+ _error_code = ZPP_ERROR_WRONG_ARG;
+ _error = "of type array or \\ion\\Writer";
+ break;
+ }
+ zo_ser = create_ion_Serializer_Serializer(NULL);
+ call_constructor(zo_ser, 0, NULL, za_named);
+ ION_CATCH(OBJ_RELEASE(zo_ser));
+ }
ZEND_PARSE_PARAMETERS_END();
if (!zo_ser || zo_ser->ce == ce_Serializer_Serializer) {
// default, fast path
- php_ion_serializer *ser = zo_ser ? php_ion_obj(serializer, zo_ser) : NULL;
- php_ion_serialize(ser, data, return_value);
+ php_ion_serialize(php_ion_obj(serializer, zo_ser), data, return_value);
} else {
zend_call_method_with_1_params(zo_ser, NULL, NULL, "serialize", return_value, data);
}
- if (za_ser) {
+ if (za_named) {
OBJ_RELEASE(zo_ser);
}
}
}
static ZEND_METHOD(ion_Unserializer_Unserializer, unserialize)
{
- zend_object *obj = Z_OBJ_P(ZEND_THIS);
-
- zval *data, *za_opt = NULL;
- zend_object *zo_rdr = NULL;
- ZEND_PARSE_PARAMETERS_START(1, 2)
+ zval *data;
+ ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(data)
- Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(zo_rdr, ce_Reader, ce_Reader_Options, za_opt)
ZEND_PARSE_PARAMETERS_END();
- php_ion_unserializer *ser = php_ion_obj(unserializer, obj);
- ser->rdr = zo_rdr;
- php_ion_unserialize(ser, data, return_value);
- ser->rdr = NULL;
-
- if (za_opt) {
- OBJ_RELEASE(zo_rdr);
- }
+ php_ion_unserialize(php_ion_obj(unserializer, Z_OBJ_P(ZEND_THIS)), data, return_value);
}
static ZEND_FUNCTION(ion_unserialize)
{
- zval *data, *za_ser = NULL;
+ zval *data;
zend_object *zo_ser = NULL;
+ zend_array *za_named = NULL;
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_ZVAL(data)
Z_PARAM_OPTIONAL
- Z_PARAM_OBJ_OF_CLASS_OR_NAMED_OR_NULL(zo_ser, ce_Unserializer, ce_Unserializer_Unserializer, za_ser)
+ Z_PARAM_PROLOGUE(0, 0)
+ if (!zend_parse_arg_obj(_arg, &zo_ser, ce_Unserializer, true)) {
+ if (!zend_parse_arg_array_ht(_arg, &za_named, false, false, false)) {
+ _error_code = ZPP_ERROR_WRONG_ARG;
+ _error = "of type array of \\ion\\Unserializer";
+ break;
+ }
+ zo_ser = create_ion_Unserializer_Unserializer(NULL);
+ call_constructor(zo_ser, 0, NULL, za_named);
+ ION_CATCH(OBJ_RELEASE(zo_ser));
+ }
ZEND_PARSE_PARAMETERS_END();
if (!zo_ser || zo_ser->ce == ce_Unserializer_Unserializer) {
// default, fast path
- php_ion_unserializer *ser = zo_ser ? php_ion_obj(unserializer, zo_ser) : NULL;
- php_ion_unserialize(ser, data, return_value);
+ php_ion_unserialize(php_ion_obj(unserializer, zo_ser), data, return_value);
} else {
zend_call_method_with_1_params(zo_ser, NULL, NULL, "unserialize", return_value, data);
}
- if (za_ser) {
+ if (za_named) {
OBJ_RELEASE(zo_ser);
}
}
// Reader
ce_Reader = register_class_ion_Reader(spl_ce_RecursiveIterator);
- php_ion_register(reader_options, Reader_Options);
php_ion_register(reader, Reader_Reader, ce_Reader);
ce_Reader_Buffer = register_class_ion_Reader_Buffer(ce_Reader);
ce_Reader_Buffer_Reader = register_class_ion_Reader_Buffer_Reader(ce_Reader_Reader, ce_Reader_Buffer);
// Writer
ce_Writer = register_class_ion_Writer();
- php_ion_register(writer_options, Writer_Options);
php_ion_register(writer, Writer_Writer, ce_Writer);
ce_Writer_Buffer = register_class_ion_Writer_Buffer(ce_Writer);
ce_Writer_Buffer_Writer = register_class_ion_Writer_Buffer_Writer(ce_Writer_Writer, ce_Writer_Buffer);
* Serializer interface, used to customize ion\serialize()'s behavior.
*/
interface Serializer {
- public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|array|null $writer = null) : mixed;
+ public function serialize(mixed $data, Writer|array|null $writer = null) : mixed;
}
/**
* Unserializer interface, used to customize ion\unserialize()'s behavior.
*/
interface Unserializer {
- /** @param \ion\Reader|string|resource $data */
+ /** @param Reader|string|resource $data */
public function unserialize($data) : mixed;
}
namespace ion\Reader;
/**
- * Reader options.
+ * Base implementation of ION readers.
*/
-class Options {
+abstract class Reader implements \ion\Reader {
+ /**
+ * @param string|resource $data The string or resource to read from.
+ */
public function __construct(
+ $data,
/**
* ION catalog to use for symbol lookup.
*/
*/
public readonly bool $skipCharacterValidation = false,
) {}
-}
-
-/**
- * Base implementation of ION readers.
- */
-abstract class Reader implements \ion\Reader {
- /**
- * Reader options.
- */
- public readonly ?Options $options;
public function hasChildren() : bool {}
public function getChildren() : \ion\Reader {}
*/
interface Buffer extends \ion\Reader {
/**
- * Get the buffer read from.
+ * Get the buffer being read from.
*
* @return string The buffer read from.
*/
*/
interface Stream extends \ion\Reader {
/**
- * Get the stream read from.
+ * Get the stream being read from.
*
* @return resource The stream read from.
*/
* ION buffer reader.
*/
class Reader extends \ion\Reader\Reader implements \ion\Reader\Buffer {
- /**
- * Create a new string buffer reader.
- *
- * @param string $buffer The buffer to read from.
- * @param \ion\Reader\Options|array|null $options Reader options.
- */
- public function __construct(
- string $buffer,
- \ion\Reader\Options|array|null $options = null,
- ) {}
public function getBuffer() : string {}
}
* ION stream reader.
*/
class Reader extends \ion\Reader\Reader implements \ion\Reader\Stream {
- /**
- * Create a new stream reader.
- *
- * @param resource $stream The stream to read from.
- * @param \ion\Reader\Options|array|null $options Reader options.
- */
- public function __construct(
- $stream,
- \ion\Reader\Options|array|null $options = null,
- ) {}
/**
* Get the stream read from.
namespace ion\Writer;
/**
- * ION writer options.
+ * Base implementation of common functionality of ION writers.
*/
-class Options {
+abstract class Writer implements \ion\Writer {
/**
- * Create custom ION writer options.
+ * Create custom ION writer.
*/
public function __construct(
/**
*/
public readonly int $tempBufferSize = 0x4000,
) {}
-}
-/**
- * Base implementation of common functionality of ION writers.
- */
-abstract class Writer implements \ion\Writer {
public function writeNull() : void {}
public function writeTypedNull(\ion\Type $type) : void {}
public function writeBool(bool $value) : void {}
namespace ion\Writer\Buffer;
/**
- * IO buffer writer.
+ * ION buffer writer.
*/
class Writer extends \ion\Writer\Writer implements \ion\Writer\Buffer {
- /**
- * Create a new buffer writer.
- *
- * @param \ion\Writer\Options|array|null $options Writer options.
- */
- public function __construct(
- \ion\Writer\Options|array|null $options = null,
- ) {}
public function getBuffer() : string {}
public function resetBuffer() : void {}
* Create a new stream writer.
*
* @param resource $stream The stream to write to.
- * @param \ion\Writer\Options|array|null $options Writer options.
*/
public function __construct(
$stream,
- \ion\Writer\Options|array|null $options = null,
+ /**
+ * ION catalog to use for symbol lookup.
+ */
+ public readonly ?\ion\Catalog $catalog = null,
+ /**
+ * Decimal context to use.
+ */
+ public readonly ?\ion\Decimal\Context $decimalContext = null,
+ /**
+ * Whether to output binary ION.
+ */
+ public readonly bool $outputBinary = false,
+ /**
+ * Whether to write doubles which fit in 32 bits as floats.
+ */
+ public readonly bool $compactFloats = false,
+ /**
+ * Whether to slash-escape all non ASCII bytes.
+ */
+ public readonly bool $escapeNonAscii = false,
+ /**
+ * Whether to produce pretty-printed output.
+ */
+ public readonly bool $prettyPrint = false,
+ /**
+ * Whether to indent with tabs, when pretty-printing.
+ */
+ public readonly bool $indentTabs = true,
+ /**
+ * The number of spaces to use for indentation instead of tabs, when pretty-printing.
+ */
+ public readonly int $indentSize = 2,
+ /**
+ * Whether to immediately flush every value written.
+ */
+ public readonly bool $flushEveryValue = false,
+ /**
+ * Maximum depth of nested containers.
+ */
+ public readonly int $maxContainerDepth = 10,
+ /**
+ * The maximum number of annotations allowed on a single value.
+ */
+ public readonly int $maxAnnotations = 10,
+ /**
+ * Temporary buffer size.
+ */
+ public readonly int $tempBufferSize = 0x4000,
) {}
/**
* @return resource
public readonly ?string $callCustomSerialize = null,
) {}
- public function serialize(mixed $data, \ion\Writer|\ion\Writer\Options|array|null $writer = null) : mixed {}
+ public function serialize(mixed $data, \ion\Writer|array|null $writer = null) : mixed {}
}
namespace ion\Unserializer;
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 771b0ba1db693b7506ff427a667d029630caca09 */
+ * Stub hash: 8b6aeb4c5c0a8a5af0f5a55cbf09fb2846032c07 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ion_serialize, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Serializer_serialize, 0, 1, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_MIXED, 0)
- ZEND_ARG_OBJ_TYPE_MASK(0, writer, ion\\Writer|ion\\Writer\\Options, MAY_BE_ARRAY|MAY_BE_NULL, "null")
+ ZEND_ARG_OBJ_TYPE_MASK(0, writer, ion\\Writer, MAY_BE_ARRAY|MAY_BE_NULL, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ion_Unserializer_unserialize, 0, 1, IS_MIXED, 0)
ZEND_ARG_OBJ_TYPE_MASK(0, round, ion\\Decimal\\Context\\Rounding, MAY_BE_LONG, "ion\\Decimal\\Context\\Rounding::HalfEven")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Reader_Options___construct, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Reader_Reader___construct, 0, 0, 1)
+ ZEND_ARG_INFO(0, data)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, catalog, ion\\Catalog, 1, "null")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, decimalContext, ion\\Decimal\\Context, 1, "null")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, onContextChange, Closure, 1, "null")
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
ZEND_END_ARG_INFO()
-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_TYPE_MASK(0, options, ion\\Reader\\Options, MAY_BE_ARRAY|MAY_BE_NULL, "null")
-ZEND_END_ARG_INFO()
-
#define arginfo_class_ion_Reader_Buffer_Reader_getBuffer arginfo_class_ion_Symbol___toString
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Reader_Stream_Reader___construct, 0, 0, 1)
- ZEND_ARG_INFO(0, stream)
- ZEND_ARG_OBJ_TYPE_MASK(0, options, ion\\Reader\\Options, MAY_BE_ARRAY|MAY_BE_NULL, "null")
-ZEND_END_ARG_INFO()
-
#define arginfo_class_ion_Reader_Stream_Reader_getStream arginfo_class_ion_Catalog___construct
#define arginfo_class_ion_Reader_Stream_Reader_resetStream arginfo_class_ion_Reader_Stream_resetStream
#define arginfo_class_ion_Reader_Stream_Reader_resetStreamWithLength arginfo_class_ion_Reader_Stream_resetStreamWithLength
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Writer_Options___construct, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Writer_Writer___construct, 0, 0, 0)
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, catalog, ion\\Catalog, 1, "null")
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, decimalContext, ion\\Decimal\\Context, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, outputBinary, _IS_BOOL, 0, "false")
#define arginfo_class_ion_Writer_Stream_getStream arginfo_class_ion_Catalog___construct
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Writer_Buffer_Writer___construct, 0, 0, 0)
- ZEND_ARG_OBJ_TYPE_MASK(0, options, ion\\Writer\\Options, MAY_BE_ARRAY|MAY_BE_NULL, "null")
-ZEND_END_ARG_INFO()
-
#define arginfo_class_ion_Writer_Buffer_Writer_getBuffer arginfo_class_ion_Symbol___toString
#define arginfo_class_ion_Writer_Buffer_Writer_resetBuffer arginfo_class_ion_Writer_writeNull
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Writer_Stream_Writer___construct, 0, 0, 1)
ZEND_ARG_INFO(0, stream)
- ZEND_ARG_OBJ_TYPE_MASK(0, options, ion\\Writer\\Options, MAY_BE_ARRAY|MAY_BE_NULL, "null")
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, catalog, ion\\Catalog, 1, "null")
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, decimalContext, ion\\Decimal\\Context, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, outputBinary, _IS_BOOL, 0, "false")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, compactFloats, _IS_BOOL, 0, "false")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, escapeNonAscii, _IS_BOOL, 0, "false")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, prettyPrint, _IS_BOOL, 0, "false")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, indentTabs, _IS_BOOL, 0, "true")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, indentSize, IS_LONG, 0, "2")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flushEveryValue, _IS_BOOL, 0, "false")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxContainerDepth, IS_LONG, 0, "10")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxAnnotations, IS_LONG, 0, "10")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tempBufferSize, IS_LONG, 0, "0x4000")
ZEND_END_ARG_INFO()
#define arginfo_class_ion_Writer_Stream_Writer_getStream arginfo_class_ion_Catalog___construct
static ZEND_METHOD(ion_Decimal_Context, Dec64);
static ZEND_METHOD(ion_Decimal_Context, Dec128);
static ZEND_METHOD(ion_Decimal_Context, DecMax);
-static ZEND_METHOD(ion_Reader_Options, __construct);
+static ZEND_METHOD(ion_Reader_Reader, __construct);
static ZEND_METHOD(ion_Reader_Reader, hasChildren);
static ZEND_METHOD(ion_Reader_Reader, getChildren);
static ZEND_METHOD(ion_Reader_Reader, rewind);
static ZEND_METHOD(ion_Reader_Reader, seek);
static ZEND_METHOD(ion_Reader_Reader, getValueOffset);
static ZEND_METHOD(ion_Reader_Reader, getValueLength);
-static ZEND_METHOD(ion_Reader_Buffer_Reader, __construct);
static ZEND_METHOD(ion_Reader_Buffer_Reader, getBuffer);
-static ZEND_METHOD(ion_Reader_Stream_Reader, __construct);
static ZEND_METHOD(ion_Reader_Stream_Reader, getStream);
static ZEND_METHOD(ion_Reader_Stream_Reader, resetStream);
static ZEND_METHOD(ion_Reader_Stream_Reader, resetStreamWithLength);
-static ZEND_METHOD(ion_Writer_Options, __construct);
+static ZEND_METHOD(ion_Writer_Writer, __construct);
static ZEND_METHOD(ion_Writer_Writer, writeNull);
static ZEND_METHOD(ion_Writer_Writer, writeTypedNull);
static ZEND_METHOD(ion_Writer_Writer, writeBool);
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_Buffer_Writer, __construct);
static ZEND_METHOD(ion_Writer_Buffer_Writer, getBuffer);
static ZEND_METHOD(ion_Writer_Buffer_Writer, resetBuffer);
static ZEND_METHOD(ion_Writer_Stream_Writer, __construct);
};
-static const zend_function_entry class_ion_Reader_Options_methods[] = {
- ZEND_ME(ion_Reader_Options, __construct, arginfo_class_ion_Reader_Options___construct, ZEND_ACC_PUBLIC)
- ZEND_FE_END
-};
-
-
static const zend_function_entry class_ion_Reader_Reader_methods[] = {
+ ZEND_ME(ion_Reader_Reader, __construct, arginfo_class_ion_Reader_Reader___construct, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Reader, hasChildren, arginfo_class_ion_Reader_Reader_hasChildren, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Reader, getChildren, arginfo_class_ion_Reader_Reader_getChildren, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Reader, rewind, arginfo_class_ion_Reader_Reader_rewind, ZEND_ACC_PUBLIC)
static const zend_function_entry class_ion_Reader_Buffer_Reader_methods[] = {
- ZEND_ME(ion_Reader_Buffer_Reader, __construct, arginfo_class_ion_Reader_Buffer_Reader___construct, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Buffer_Reader, getBuffer, arginfo_class_ion_Reader_Buffer_Reader_getBuffer, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_ion_Reader_Stream_Reader_methods[] = {
- ZEND_ME(ion_Reader_Stream_Reader, __construct, arginfo_class_ion_Reader_Stream_Reader___construct, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Stream_Reader, getStream, arginfo_class_ion_Reader_Stream_Reader_getStream, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Stream_Reader, resetStream, arginfo_class_ion_Reader_Stream_Reader_resetStream, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Reader_Stream_Reader, resetStreamWithLength, arginfo_class_ion_Reader_Stream_Reader_resetStreamWithLength, ZEND_ACC_PUBLIC)
};
-static const zend_function_entry class_ion_Writer_Options_methods[] = {
- ZEND_ME(ion_Writer_Options, __construct, arginfo_class_ion_Writer_Options___construct, ZEND_ACC_PUBLIC)
- ZEND_FE_END
-};
-
-
static const zend_function_entry class_ion_Writer_Writer_methods[] = {
+ ZEND_ME(ion_Writer_Writer, __construct, arginfo_class_ion_Writer_Writer___construct, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Writer_Writer, writeNull, arginfo_class_ion_Writer_Writer_writeNull, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Writer_Writer, writeTypedNull, arginfo_class_ion_Writer_Writer_writeTypedNull, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Writer_Writer, writeBool, arginfo_class_ion_Writer_Writer_writeBool, ZEND_ACC_PUBLIC)
static const zend_function_entry class_ion_Writer_Buffer_Writer_methods[] = {
- ZEND_ME(ion_Writer_Buffer_Writer, __construct, arginfo_class_ion_Writer_Buffer_Writer___construct, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Writer_Buffer_Writer, getBuffer, arginfo_class_ion_Writer_Buffer_Writer_getBuffer, ZEND_ACC_PUBLIC)
ZEND_ME(ion_Writer_Buffer_Writer, resetBuffer, arginfo_class_ion_Writer_Buffer_Writer_resetBuffer, ZEND_ACC_PUBLIC)
ZEND_FE_END
return class_entry;
}
-static zend_class_entry *register_class_ion_Reader_Options(void)
+static zend_class_entry *register_class_ion_Reader_Reader(zend_class_entry *class_entry_ion_Reader)
{
zend_class_entry ce, *class_entry;
- INIT_NS_CLASS_ENTRY(ce, "ion\\Reader", "Options", class_ion_Reader_Options_methods);
+ INIT_NS_CLASS_ENTRY(ce, "ion\\Reader", "Reader", class_ion_Reader_Reader_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
+ class_entry->ce_flags |= ZEND_ACC_ABSTRACT;
+ zend_class_implements(class_entry, 1, class_entry_ion_Reader);
zend_string *property_catalog_class_ion_Catalog = zend_string_init("ion\\Catalog", sizeof("ion\\Catalog")-1, 1);
zval property_catalog_default_value;
return class_entry;
}
-static zend_class_entry *register_class_ion_Reader_Reader(zend_class_entry *class_entry_ion_Reader)
-{
- zend_class_entry ce, *class_entry;
-
- INIT_NS_CLASS_ENTRY(ce, "ion\\Reader", "Reader", class_ion_Reader_Reader_methods);
- class_entry = zend_register_internal_class_ex(&ce, NULL);
- class_entry->ce_flags |= ZEND_ACC_ABSTRACT;
- zend_class_implements(class_entry, 1, class_entry_ion_Reader);
-
- zend_string *property_options_class_ion_Reader_Options = zend_string_init("ion\\Reader\\Options", sizeof("ion\\Reader\\Options")-1, 1);
- zval property_options_default_value;
- ZVAL_UNDEF(&property_options_default_value);
- zend_string *property_options_name = zend_string_init("options", sizeof("options") - 1, 1);
- zend_declare_typed_property(class_entry, property_options_name, &property_options_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_options_class_ion_Reader_Options, 0, MAY_BE_NULL));
- zend_string_release(property_options_name);
-
- return class_entry;
-}
-
static zend_class_entry *register_class_ion_Reader_Buffer(zend_class_entry *class_entry_ion_Reader)
{
zend_class_entry ce, *class_entry;
return class_entry;
}
-static zend_class_entry *register_class_ion_Writer_Options(void)
+static zend_class_entry *register_class_ion_Writer_Writer(zend_class_entry *class_entry_ion_Writer)
{
zend_class_entry ce, *class_entry;
- INIT_NS_CLASS_ENTRY(ce, "ion\\Writer", "Options", class_ion_Writer_Options_methods);
+ INIT_NS_CLASS_ENTRY(ce, "ion\\Writer", "Writer", class_ion_Writer_Writer_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
+ class_entry->ce_flags |= ZEND_ACC_ABSTRACT;
+ zend_class_implements(class_entry, 1, class_entry_ion_Writer);
zend_string *property_catalog_class_ion_Catalog = zend_string_init("ion\\Catalog", sizeof("ion\\Catalog")-1, 1);
zval property_catalog_default_value;
return class_entry;
}
-static zend_class_entry *register_class_ion_Writer_Writer(zend_class_entry *class_entry_ion_Writer)
-{
- zend_class_entry ce, *class_entry;
-
- INIT_NS_CLASS_ENTRY(ce, "ion\\Writer", "Writer", class_ion_Writer_Writer_methods);
- class_entry = zend_register_internal_class_ex(&ce, NULL);
- class_entry->ce_flags |= ZEND_ACC_ABSTRACT;
- zend_class_implements(class_entry, 1, class_entry_ion_Writer);
-
- return class_entry;
-}
-
static zend_class_entry *register_class_ion_Writer_Buffer(zend_class_entry *class_entry_ion_Writer)
{
zend_class_entry ce, *class_entry;
class_entry = zend_register_internal_class_ex(&ce, class_entry_ion_Writer_Writer);
zend_class_implements(class_entry, 1, class_entry_ion_Writer_Stream);
+ zend_string *property_catalog_class_ion_Catalog = zend_string_init("ion\\Catalog", sizeof("ion\\Catalog")-1, 1);
+ zval property_catalog_default_value;
+ ZVAL_UNDEF(&property_catalog_default_value);
+ zend_string *property_catalog_name = zend_string_init("catalog", sizeof("catalog") - 1, 1);
+ zend_declare_typed_property(class_entry, property_catalog_name, &property_catalog_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_catalog_class_ion_Catalog, 0, MAY_BE_NULL));
+ zend_string_release(property_catalog_name);
+
+ zend_string *property_decimalContext_class_ion_Decimal_Context = zend_string_init("ion\\Decimal\\Context", sizeof("ion\\Decimal\\Context")-1, 1);
+ zval property_decimalContext_default_value;
+ ZVAL_UNDEF(&property_decimalContext_default_value);
+ zend_string *property_decimalContext_name = zend_string_init("decimalContext", sizeof("decimalContext") - 1, 1);
+ zend_declare_typed_property(class_entry, property_decimalContext_name, &property_decimalContext_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_decimalContext_class_ion_Decimal_Context, 0, MAY_BE_NULL));
+ zend_string_release(property_decimalContext_name);
+
+ zval property_outputBinary_default_value;
+ ZVAL_UNDEF(&property_outputBinary_default_value);
+ zend_string *property_outputBinary_name = zend_string_init("outputBinary", sizeof("outputBinary") - 1, 1);
+ zend_declare_typed_property(class_entry, property_outputBinary_name, &property_outputBinary_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL));
+ zend_string_release(property_outputBinary_name);
+
+ zval property_compactFloats_default_value;
+ ZVAL_UNDEF(&property_compactFloats_default_value);
+ zend_string *property_compactFloats_name = zend_string_init("compactFloats", sizeof("compactFloats") - 1, 1);
+ zend_declare_typed_property(class_entry, property_compactFloats_name, &property_compactFloats_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL));
+ zend_string_release(property_compactFloats_name);
+
+ zval property_escapeNonAscii_default_value;
+ ZVAL_UNDEF(&property_escapeNonAscii_default_value);
+ zend_string *property_escapeNonAscii_name = zend_string_init("escapeNonAscii", sizeof("escapeNonAscii") - 1, 1);
+ zend_declare_typed_property(class_entry, property_escapeNonAscii_name, &property_escapeNonAscii_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL));
+ zend_string_release(property_escapeNonAscii_name);
+
+ zval property_prettyPrint_default_value;
+ ZVAL_UNDEF(&property_prettyPrint_default_value);
+ zend_string *property_prettyPrint_name = zend_string_init("prettyPrint", sizeof("prettyPrint") - 1, 1);
+ zend_declare_typed_property(class_entry, property_prettyPrint_name, &property_prettyPrint_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL));
+ zend_string_release(property_prettyPrint_name);
+
+ zval property_indentTabs_default_value;
+ ZVAL_UNDEF(&property_indentTabs_default_value);
+ zend_string *property_indentTabs_name = zend_string_init("indentTabs", sizeof("indentTabs") - 1, 1);
+ zend_declare_typed_property(class_entry, property_indentTabs_name, &property_indentTabs_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL));
+ zend_string_release(property_indentTabs_name);
+
+ zval property_indentSize_default_value;
+ ZVAL_UNDEF(&property_indentSize_default_value);
+ zend_string *property_indentSize_name = zend_string_init("indentSize", sizeof("indentSize") - 1, 1);
+ zend_declare_typed_property(class_entry, property_indentSize_name, &property_indentSize_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+ zend_string_release(property_indentSize_name);
+
+ zval property_flushEveryValue_default_value;
+ ZVAL_UNDEF(&property_flushEveryValue_default_value);
+ zend_string *property_flushEveryValue_name = zend_string_init("flushEveryValue", sizeof("flushEveryValue") - 1, 1);
+ zend_declare_typed_property(class_entry, property_flushEveryValue_name, &property_flushEveryValue_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL));
+ zend_string_release(property_flushEveryValue_name);
+
+ zval property_maxContainerDepth_default_value;
+ ZVAL_UNDEF(&property_maxContainerDepth_default_value);
+ zend_string *property_maxContainerDepth_name = zend_string_init("maxContainerDepth", sizeof("maxContainerDepth") - 1, 1);
+ zend_declare_typed_property(class_entry, property_maxContainerDepth_name, &property_maxContainerDepth_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+ zend_string_release(property_maxContainerDepth_name);
+
+ zval property_maxAnnotations_default_value;
+ ZVAL_UNDEF(&property_maxAnnotations_default_value);
+ zend_string *property_maxAnnotations_name = zend_string_init("maxAnnotations", sizeof("maxAnnotations") - 1, 1);
+ zend_declare_typed_property(class_entry, property_maxAnnotations_name, &property_maxAnnotations_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+ zend_string_release(property_maxAnnotations_name);
+
+ zval property_tempBufferSize_default_value;
+ ZVAL_UNDEF(&property_tempBufferSize_default_value);
+ zend_string *property_tempBufferSize_name = zend_string_init("tempBufferSize", sizeof("tempBufferSize") - 1, 1);
+ zend_declare_typed_property(class_entry, property_tempBufferSize_name, &property_tempBufferSize_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+ zend_string_release(property_tempBufferSize_name);
+
return class_entry;
}
*ce_Exception,
*ce_LOB,
*ce_Reader,
- *ce_Reader_Options,
*ce_Reader_Reader,
*ce_Reader_Buffer,
*ce_Reader_Stream,
*ce_Unserializer,
*ce_Unserializer_Unserializer,
*ce_Writer,
- *ce_Writer_Options,
*ce_Writer_Buffer,
*ce_Writer_Buffer_Writer,
*ce_Writer_Stream,
php_ion_decl(catalog, Catalog);
-typedef struct php_ion_reader_options_ccn_ctx {
+typedef struct php_ion_reader_ccn_ctx {
zend_object *obj;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
-} php_ion_reader_options_ccn_ctx;
-
-typedef struct php_ion_reader_options {
- ION_READER_OPTIONS opt;
- php_ion_reader_options_ccn_ctx ccn;
- zend_object *cat, *dec_ctx, *cb, std;
-} php_ion_reader_options;
-
-static void php_ion_reader_options_dtor(php_ion_reader_options *obj)
-{
- if (obj->cb) {
- zend_fcall_info_args_clear(&obj->ccn.fci, true);
- }
-}
+} php_ion_reader_ccn_ctx;
+/*
static void php_ion_reader_options_copy(php_ion_reader_options *new_obj, php_ion_reader_options *old_obj)
{
zend_objects_clone_members(&new_obj->std, &old_obj->std);
new_obj->opt.context_change_notifier.context = &new_obj->ccn;
}
}
-
-php_ion_decl(reader_options, Reader_Options);
+*/
typedef struct php_ion_reader {
ION_READER *reader;
ION_STRING buf;
} stream;
};
- zend_object *opt, std;
+
+ ION_READER_OPTIONS options;
+ php_ion_reader_ccn_ctx ccn;
+ zend_object *cat, *dec_ctx, *cb, std;
} php_ion_reader;
static iERR php_ion_reader_stream_handler(struct _ion_user_stream *user)
iERR e = IERR_OK;
if (context) {
- php_ion_reader_options_ccn_ctx *ctx = context;
+ php_ion_reader_ccn_ctx *ctx = context;
zval zobj;
ZVAL_OBJ(&zobj, ctx->obj);
static void php_ion_reader_ctor(php_ion_reader *obj)
{
iERR err;
- php_ion_reader_options *opt = php_ion_obj(reader_options, obj->opt);
- if (!opt) {
- obj->opt = object_construct(ce_Reader_Options, 0, NULL, NULL);
- update_property_obj_ex(ce_Reader_Reader, &obj->std, ZEND_STRL("options"), obj->opt);
- OBJ_RELEASE(obj->opt);
- } else if (opt->opt.context_change_notifier.context) {
- php_ion_reader_options_ccn_ctx *ctx = opt->opt.context_change_notifier.context;
- ctx->obj = &obj->std;
- opt->opt.context_change_notifier.notify = on_context_change;
+ if (obj->cb) {
+ zval zcb;
+ ZVAL_OBJ(&zcb, obj->cb);
+ zend_fcall_info_init(&zcb, 0, &obj->ccn.fci, &obj->ccn.fcc, NULL, NULL);
+ obj->ccn.obj = &obj->std;
+ obj->options.context_change_notifier.context = &obj->ccn;
+ obj->options.context_change_notifier.notify = on_context_change;
+ update_property_obj_ex(ce_Reader_Reader,&obj->std, ZEND_STRL("onContextChange"), obj->cb);
+ } else {
+ zend_update_property_null(ce_Reader_Reader, &obj->std, ZEND_STRL("onContextChange"));
+ }
+ if (obj->cat) {
+ update_property_obj_ex(ce_Reader_Reader,&obj->std, ZEND_STRL("catalog"), obj->cat);
+ obj->options.pcatalog = php_ion_obj(catalog, obj->cat)->cat;
+ } else {
+ zend_update_property_null(ce_Reader_Reader, &obj->std, ZEND_STRL("catalog"));
}
+ if (obj->dec_ctx) {
+ update_property_obj_ex(ce_Reader_Reader,&obj->std, ZEND_STRL("decimalContext"), obj->dec_ctx);
+ obj->options.decimal_context = &php_ion_obj(decimal_ctx, obj->dec_ctx)->ctx;
+ } else {
+ zend_update_property_null(ce_Reader_Reader, &obj->std, ZEND_STRL("decimalContext"));
+ }
+
+ zend_update_property_bool(ce_Reader_Reader, &obj->std, ZEND_STRL("returnSystemValues"),
+ obj->options.return_system_values);
+ zend_update_property_long(ce_Reader_Reader, &obj->std, ZEND_STRL("maxContainerDepth"),
+ obj->options.max_container_depth);
+ zend_update_property_long(ce_Reader_Reader, &obj->std, ZEND_STRL("maxAnnotations"),
+ obj->options.max_annotation_count);
+ zend_update_property_long(ce_Reader_Reader, &obj->std, ZEND_STRL("annotationBufferSize"),
+ obj->options.max_annotation_buffered);
+ zend_update_property_long(ce_Reader_Reader, &obj->std, ZEND_STRL("tempBufferSize"),
+ obj->options.chunk_threshold);
+ zend_update_property_bool(ce_Reader_Reader, &obj->std, ZEND_STRL("skipCharacterValidation"),
+ obj->options.skip_character_validation);
+
if (obj->type == STREAM_READER) {
- PTR_CHECK(obj->stream.ptr);
- GC_ADDREF(obj->stream.ptr->res);
-
- obj->stream.buf.length = opt && opt->opt.chunk_threshold ? opt->opt.chunk_threshold : 0x4000;
+ obj->stream.buf.length = obj->options.chunk_threshold ? obj->options.chunk_threshold : 0x4000;
obj->stream.buf.value = emalloc(obj->stream.buf.length);
- err = ion_reader_open_stream(&obj->reader, obj, php_ion_reader_stream_handler, opt ? &opt->opt : NULL);
-
+ err = ion_reader_open_stream(&obj->reader, obj, php_ion_reader_stream_handler, &obj->options);
} else {
- err = ion_reader_open_buffer(&obj->reader, (BYTE *) obj->buffer->val, (SIZE) obj->buffer->len, opt ? &opt->opt : NULL);
+ err = ion_reader_open_buffer(&obj->reader, (BYTE *) obj->buffer->val, (SIZE) obj->buffer->len, &obj->options);
}
ION_CHECK(err);
if (obj->reader) {
ion_reader_close(obj->reader);
}
+ if (obj->cb) {
+ zend_fcall_info_args_clear(&obj->ccn.fci, true);
+ }
if (obj->type == STREAM_READER) {
if (obj->stream.buf.value) {
efree(obj->stream.buf.value);
php_ion_decl_noclone(reader, Reader_Reader);
#define clone_ion_Reader_Reader NULL
-typedef struct php_ion_writer_options {
- ION_WRITER_OPTIONS opt;
- zend_object *cat, *dec_ctx, std;
-} php_ion_writer_options;
-
-static void php_ion_writer_options_copy(php_ion_writer_options *new_obj, php_ion_writer_options *old_obj)
-{
- zend_objects_clone_members(&new_obj->std, &old_obj->std);
-
- new_obj->opt = old_obj->opt;
- new_obj->cat = old_obj->cat;
- new_obj->dec_ctx = old_obj->dec_ctx;
-}
-
-static void php_ion_writer_options_dtor(php_ion_writer_options *obj)
-{
-}
-
-php_ion_decl(writer_options, Writer_Options);
-
typedef struct php_ion_writer {
ION_WRITER *writer;
enum {
php_stream *ptr;
} stream;
};
- zend_object *opt, std;
+
+ ION_WRITER_OPTIONS options;
+ zend_object *cat, *dec_ctx, std;
} php_ion_writer;
return IERR_OK;
}
-static void php_ion_writer_stream_init(php_ion_writer *obj, php_ion_writer_options *opt)
+static void php_ion_writer_stream_init(php_ion_writer *obj)
{
- PTR_CHECK(obj->stream.ptr);
- GC_ADDREF(obj->stream.ptr->res);
-
- obj->stream.buf.length = opt ? opt->opt.temp_buffer_size : 0x1000;
+ obj->stream.buf.length = obj->options.temp_buffer_size ? obj->options.temp_buffer_size : 0x1000;
obj->stream.buf.value = emalloc(obj->stream.buf.length);
}
return IERR_OK;
}
-static void php_ion_writer_options_init_shared_imports(php_ion_writer_options *opt)
+static void php_ion_writer_init_shared_imports(php_ion_writer *obj)
{
- php_ion_catalog *cat = php_ion_obj(catalog, opt->cat);
+ php_ion_catalog *cat = php_ion_obj(catalog, obj->cat);
OBJ_CHECK(cat);
- ION_CHECK(ion_writer_options_initialize_shared_imports(&opt->opt));
+ ION_CHECK(ion_writer_options_initialize_shared_imports(&obj->options));
ION_COLLECTION *col = php_ion_catalog_collection(cat);
if (!ION_COLLECTION_IS_EMPTY(col)) {
ION_SYMBOL_TABLE **ptr;
ION_COLLECTION_NEXT(cur, ptr);
if (*ptr) {
- ION_CHECK(ion_writer_options_add_shared_imports_symbol_tables(&opt->opt, ptr, 1));
+ ION_CHECK(ion_writer_options_add_shared_imports_symbol_tables(&obj->options, ptr, 1));
}
}
}
static void php_ion_writer_ctor(php_ion_writer *obj)
{
- php_ion_writer_options *opt = NULL;
-
- if (obj->opt) {
- update_property_obj(&obj->std, ZEND_STRL("options"), obj->opt);
- opt = php_ion_obj(writer_options, obj->opt);
- if (opt->cat) {
- php_ion_writer_options_init_shared_imports(opt);
- }
+ if (obj->dec_ctx) {
+ update_property_obj_ex(ce_Writer_Writer, &obj->std, ZEND_STRL("decimalContext"), obj->dec_ctx);
+ obj->options.decimal_context = &php_ion_obj(decimal_ctx, obj->dec_ctx)->ctx;
} else {
- obj->opt = object_construct(ce_Writer_Options, 0, NULL, NULL);
- update_property_obj_ex(ce_Writer_Options, &obj->std, ZEND_STRL("options"), obj->opt);
- OBJ_RELEASE(obj->opt);
+ zend_update_property_null(ce_Writer_Writer, &obj->std, ZEND_STRL("decimalContext"));
}
+ if (obj->cat) {
+ update_property_obj_ex(ce_Writer_Writer, &obj->std, ZEND_STRL("catalog"), obj->cat);
+ obj->options.pcatalog = php_ion_obj(catalog, obj->cat)->cat;
+ php_ion_writer_init_shared_imports(obj);
+ } else {
+ zend_update_property_null(ce_Writer_Writer, &obj->std, ZEND_STRL("catalog"));
+ }
+
+ zend_update_property_bool(ce_Writer_Writer, &obj->std, ZEND_STRL("outputBinary"),
+ obj->options.output_as_binary);
+ zend_update_property_bool(ce_Writer_Writer, &obj->std, ZEND_STRL("compactFloats"),
+ obj->options.compact_floats);
+ zend_update_property_bool(ce_Writer_Writer, &obj->std, ZEND_STRL("escapeNonAscii"),
+ obj->options.escape_all_non_ascii);
+ zend_update_property_bool(ce_Writer_Writer, &obj->std, ZEND_STRL("prettyPrint"),
+ obj->options.pretty_print);
+ zend_update_property_bool(ce_Writer_Writer, &obj->std, ZEND_STRL("indentTabs"),
+ obj->options.indent_with_tabs);
+ zend_update_property_long(ce_Writer_Writer, &obj->std, ZEND_STRL("indentSize"),
+ obj->options.indent_size);
+ zend_update_property_bool(ce_Writer_Writer, &obj->std, ZEND_STRL("flushEveryValue"),
+ obj->options.flush_every_value);
+ zend_update_property_long(ce_Writer_Writer, &obj->std, ZEND_STRL("maxContainerDepth"),
+ obj->options.max_container_depth);
+ zend_update_property_long(ce_Writer_Writer, &obj->std, ZEND_STRL("maxAnnotations"),
+ obj->options.max_annotation_count);
+ zend_update_property_long(ce_Writer_Writer, &obj->std, ZEND_STRL("tempBufferSize"),
+ obj->options.temp_buffer_size);
ION_STREAM_HANDLER h;
if (obj->type == STREAM_WRITER) {
h = php_ion_writer_stream_handler;
- php_ion_writer_stream_init(obj, opt);
+ php_ion_writer_stream_init(obj);
} else {
h = php_ion_writer_buffer_handler;
php_ion_writer_buffer_init(obj);
}
- ION_CHECK(ion_writer_open_stream(&obj->writer, h, obj, opt ? &opt->opt : NULL));
+ ION_CHECK(ion_writer_open_stream(&obj->writer, h, obj, &obj->options));
OBJ_CHECK(obj);
}
if (obj->writer) {
ion_writer_close(obj->writer);
}
- if (obj->opt) {
- php_ion_writer_options *opt = php_ion_obj(writer_options, obj->opt);
- if (opt->cat) {
- ion_writer_options_close_shared_imports(&opt->opt);
- }
+ if (obj->cat) {
+ ion_writer_options_close_shared_imports(&obj->options);
}
if (obj->type == STREAM_WRITER) {
if (obj->stream.buf.value) {
} else if (special_ce == ce_Timestamp) {
ION_TIMESTAMP its;
php_ion_timestamp *pts = php_ion_obj(timestamp, zobject);
- decContext *ctx = php_ion_obj(writer_options, php_ion_obj(writer, ser->wri)->opt)->opt.decimal_context;
+ decContext *ctx = php_ion_obj(writer, ser->wri)->options.decimal_context;
ION_CHECK(ion_writer_write_timestamp(php_ion_obj(writer, ser->wri)->writer, ion_timestamp_from_php(&its, pts, ctx)));
} else {
assert(special_ce == ce_LOB);
ION_CATCH();
}
- if (!ser->wri || !instanceof_function(ser->wri->ce, ce_Writer)) {
+ if (!ser->wri) {
zo_wri = create_ion_Writer_Writer(ce_Writer_Buffer_Writer);
- php_ion_writer *wri = php_ion_obj(writer, zo_wri);
- wri->type = BUFFER_WRITER;
- if (ser->wri && instanceof_function(ser->wri->ce, ce_Writer_Options)) {
- wri->opt = ser->wri;
- }
- php_ion_writer_ctor(wri);
+ php_ion_writer_ctor(php_ion_obj(writer, zo_wri));
ser->wri = zo_wri;
}
- if (!EG(exception)) {
- php_ion_serialize_ex(ser, zv);
- }
+ php_ion_serialize_ex(ser, zv);
/* make sure to flush when done, else str.s might not contain everything until the writer is closed */
if (can_serialize_fast(ser)) {
if (zo_wri) {
OBJ_RELEASE(zo_wri);
+ ser->wri = NULL;
}
if (zo_ser) {
OBJ_RELEASE(zo_ser);
case tid_TIMESTAMP_INT:
if (can_unserialize_fast(ser)) {
php_ion_reader *reader = php_ion_obj(reader, ser->rdr);
- php_ion_reader_read_timestamp(reader->reader, &php_ion_obj(reader_options, reader->opt)->opt, return_value);
+ php_ion_reader_read_timestamp(reader->reader, &reader->options, return_value);
} else {
zend_call_method_with_0_params(&ser->std, NULL, NULL, "readTimestamp", return_value);
}
static php_ion_reader *create_unserialize_reader(zval *zdata)
{
- zend_object *zo_reader;
- php_ion_reader *reader = NULL;
ZVAL_DEREF(zdata);
- if (Z_TYPE_P(zdata) == IS_RESOURCE) {
- zo_reader = create_ion_Reader_Reader(ce_Reader_Stream_Reader);
- reader = php_ion_obj(reader, zo_reader);
- reader->type = STREAM_READER;
- php_stream_from_zval_no_verify(reader->stream.ptr, zdata);
- } else if (Z_TYPE_P(zdata) <= IS_STRING) {
- zo_reader = create_ion_Reader_Reader(ce_Reader_Buffer_Reader);
- reader = php_ion_obj(reader, zo_reader);
- reader->type = BUFFER_READER;
- reader->buffer = zval_get_string(zdata);
- } else if (Z_TYPE_P(zdata) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zdata), ce_Reader)) {
+ if (Z_TYPE_P(zdata) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zdata), ce_Reader)) {
Z_ADDREF_P(zdata);
- reader = php_ion_obj(reader, Z_OBJ_P(zdata));
+ return php_ion_obj(reader, Z_OBJ_P(zdata));
} else {
- zend_throw_exception_ex(ce_Exception, IERR_INVALID_ARG,
- "Invalid source to unserialize: expected string or resource, got %s",
- zend_zval_type_name(zdata));
- }
+ zend_object *zo_reader = NULL;
+ php_ion_reader *reader = NULL;
+
+ if (Z_TYPE_P(zdata) == IS_RESOURCE) {
+ zo_reader = create_ion_Reader_Reader(ce_Reader_Stream_Reader);
+ reader = php_ion_obj(reader, zo_reader);
+ reader->type = STREAM_READER;
+ php_stream_from_zval_no_verify(reader->stream.ptr, zdata);
+ PTR_CHECK_RETURN(NULL, reader->stream.ptr, OBJ_RELEASE(zo_reader));
+ GC_ADDREF(reader->stream.ptr->res);
+ php_ion_reader_ctor(reader);
+ } else if (Z_TYPE_P(zdata) <= IS_STRING) {
+ zo_reader = create_ion_Reader_Reader(ce_Reader_Buffer_Reader);
+ reader = php_ion_obj(reader, zo_reader);
+ reader->type = BUFFER_READER;
+ reader->buffer = zval_get_string(zdata);
+ ION_CATCH_RETURN(NULL, OBJ_RELEASE(zo_reader));
+ php_ion_reader_ctor(reader);
+ } else {
+ zend_throw_exception_ex(ce_Exception, IERR_INVALID_ARG,
+ "Invalid source to unserialize: expected string or resource, got %s",
+ zend_zval_type_name(zdata));
+ }
- return reader;
+ ION_CATCH_RETURN(NULL, if (zo_reader) {
+ OBJ_RELEASE(zo_reader);
+ });
+ return reader;
+ }
}
void php_ion_unserialize(php_ion_unserializer *ser, zval *zdata, zval *return_value)
{
- zend_object *zo_opt = NULL, *zo_ser = NULL;
+ zend_object *zo_ser = NULL;
if (!ser) {
zo_ser = create_ion_Unserializer_Unserializer(NULL);
php_ion_reader *reader = create_unserialize_reader(zdata);
if (reader) {
- if (ser->rdr && instanceof_function(ser->rdr->ce, ce_Reader_Options)) {
- zo_opt = reader->opt = ser->rdr;
- }
- php_ion_reader_ctor(reader);
ser->rdr = &reader->std;
if (!EG(exception)) {
php_ion_unserialize_ex(ser, return_value);
}
OBJ_RELEASE(&reader->std);
+ ser->rdr = NULL;
}
- if (zo_opt) {
- OBJ_RELEASE(zo_opt);
- }
if (zo_ser) {
OBJ_RELEASE(zo_ser);
}
+++ /dev/null
---TEST--
-ion\Reader\Options
---EXTENSIONS--
-ion
---FILE--
-TEST
-<?php
-$o = new ion\Reader\Options;
-var_dump($o, clone $o);
-
-$o = new ion\Reader\Options(
- catalog: new ion\Catalog,
- decimalContext: ion\Decimal\Context::Dec32(),
- onContextChange: function(ion\Reader $r) {},
- returnSystemValues: true,
- skipCharacterValidation: true,
-);
-var_dump($o, clone $o);
-?>
-DONE
---EXPECTF--
-TEST
-object(ion\Reader\Options)#%d (9) {
- ["catalog"]=>
- NULL
- ["decimalContext"]=>
- NULL
- ["onContextChange"]=>
- NULL
- ["returnSystemValues"]=>
- bool(false)
- ["maxContainerDepth"]=>
- int(10)
- ["maxAnnotations"]=>
- int(10)
- ["annotationBufferSize"]=>
- int(16384)
- ["tempBufferSize"]=>
- int(16384)
- ["skipCharacterValidation"]=>
- bool(false)
-}
-object(ion\Reader\Options)#%d (9) {
- ["catalog"]=>
- NULL
- ["decimalContext"]=>
- NULL
- ["onContextChange"]=>
- NULL
- ["returnSystemValues"]=>
- bool(false)
- ["maxContainerDepth"]=>
- int(10)
- ["maxAnnotations"]=>
- int(10)
- ["annotationBufferSize"]=>
- int(16384)
- ["tempBufferSize"]=>
- int(16384)
- ["skipCharacterValidation"]=>
- bool(false)
-}
-object(ion\Reader\Options)#%d (9) {
- ["catalog"]=>
- object(ion\Catalog)#%d (1) {
- ["symbolTables":"ion\Catalog":private]=>
- array(0) {
- }
- }
- ["decimalContext"]=>
- object(ion\Decimal\Context)#%d (5) {
- ["digits"]=>
- int(7)
- ["eMax"]=>
- int(96)
- ["eMin"]=>
- int(-95)
- ["round"]=>
- int(3)
- ["clamp"]=>
- bool(true)
- }
- ["onContextChange"]=>
- object(Closure)#%d (1) {
- ["parameter"]=>
- array(1) {
- ["$r"]=>
- string(10) "<required>"
- }
- }
- ["returnSystemValues"]=>
- bool(true)
- ["maxContainerDepth"]=>
- int(10)
- ["maxAnnotations"]=>
- int(10)
- ["annotationBufferSize"]=>
- int(16384)
- ["tempBufferSize"]=>
- int(16384)
- ["skipCharacterValidation"]=>
- bool(true)
-}
-object(ion\Reader\Options)#%d (9) {
- ["catalog"]=>
- object(ion\Catalog)#%d (1) {
- ["symbolTables":"ion\Catalog":private]=>
- array(0) {
- }
- }
- ["decimalContext"]=>
- object(ion\Decimal\Context)#%d (5) {
- ["digits"]=>
- int(7)
- ["eMax"]=>
- int(96)
- ["eMin"]=>
- int(-95)
- ["round"]=>
- int(3)
- ["clamp"]=>
- bool(true)
- }
- ["onContextChange"]=>
- object(Closure)#%d (1) {
- ["parameter"]=>
- array(1) {
- ["$r"]=>
- string(10) "<required>"
- }
- }
- ["returnSystemValues"]=>
- bool(true)
- ["maxContainerDepth"]=>
- int(10)
- ["maxAnnotations"]=>
- int(10)
- ["annotationBufferSize"]=>
- int(16384)
- ["tempBufferSize"]=>
- int(16384)
- ["skipCharacterValidation"]=>
- bool(true)
-}
-DONE
TEST
<?php
-$w = new ion\Writer\Buffer\Writer(new ion\Writer\Options(outputBinary: true));
+$w = new ion\Writer\Buffer\Writer(outputBinary: true);
$w->writeSymbol("local1");
$w->writeSymbol("local1");
$c = new ion\Catalog;
$c->add(new ion\Symbol\Table\Shared("shared", 1, ["shared1", "shared2"]));
-$w = new ion\Writer\Buffer\Writer(new ion\Writer\Options(catalog: $c, outputBinary: true));
+$w = new ion\Writer\Buffer\Writer(catalog: $c, outputBinary: true);
$w->writeSymbol("shared1");
$w->writeSymbol("shared1");
}
$u = new ion\Unserializer\Unserializer(multiSequence: true);
-var_dump($u->unserialize(new ion\Reader\Buffer\Reader($w->getBuffer(), [
- "catalog" => $c,
- "onContextChange" => fn(ion\Reader $r) => print("on_context_change\n")
-])));
+var_dump($u->unserialize(new ion\Reader\Buffer\Reader($w->getBuffer(),
+ catalog: $c,
+ onContextChange: fn(ion\Reader $r) => print("on_context_change\n")
+)));
?>
DONE
TEST
<?php
-$w = new ion\Writer\Stream\Writer(STDOUT,
- new ion\Writer\Options(flushEveryValue: true));
+$w = new ion\Writer\Stream\Writer(STDOUT, flushEveryValue: true);
$w->writeNull();
echo "\n";
+++ /dev/null
---TEST--
-ion\Writer\Options
---EXTENSIONS--
-ion
---FILE--
-TEST
-<?php
-$o = new ion\Writer\Options;
-var_dump($o, clone $o);
-
-$o = new ion\Writer\Options(
- catalog: new ion\Catalog,
- decimalContext: ion\Decimal\Context::Dec64(),
- outputBinary: true,
- maxContainerDepth: 20,
- tempBufferSize: 0x20000
-);
-var_dump($o, clone $o);
-?>
-DONE
---EXPECTF--
-TEST
-object(ion\Writer\Options)#%d (12) {
- ["catalog"]=>
- NULL
- ["decimalContext"]=>
- NULL
- ["outputBinary"]=>
- bool(false)
- ["compactFloats"]=>
- bool(false)
- ["escapeNonAscii"]=>
- bool(false)
- ["prettyPrint"]=>
- bool(false)
- ["indentTabs"]=>
- bool(true)
- ["indentSize"]=>
- int(2)
- ["flushEveryValue"]=>
- bool(false)
- ["maxContainerDepth"]=>
- int(10)
- ["maxAnnotations"]=>
- int(10)
- ["tempBufferSize"]=>
- int(16384)
-}
-object(ion\Writer\Options)#%d (12) {
- ["catalog"]=>
- NULL
- ["decimalContext"]=>
- NULL
- ["outputBinary"]=>
- bool(false)
- ["compactFloats"]=>
- bool(false)
- ["escapeNonAscii"]=>
- bool(false)
- ["prettyPrint"]=>
- bool(false)
- ["indentTabs"]=>
- bool(true)
- ["indentSize"]=>
- int(2)
- ["flushEveryValue"]=>
- bool(false)
- ["maxContainerDepth"]=>
- int(10)
- ["maxAnnotations"]=>
- int(10)
- ["tempBufferSize"]=>
- int(16384)
-}
-object(ion\Writer\Options)#%d (12) {
- ["catalog"]=>
- object(ion\Catalog)#%d (1) {
- ["symbolTables":"ion\Catalog":private]=>
- array(0) {
- }
- }
- ["decimalContext"]=>
- object(ion\Decimal\Context)#%d (5) {
- ["digits"]=>
- int(16)
- ["eMax"]=>
- int(384)
- ["eMin"]=>
- int(-383)
- ["round"]=>
- int(3)
- ["clamp"]=>
- bool(true)
- }
- ["outputBinary"]=>
- bool(true)
- ["compactFloats"]=>
- bool(false)
- ["escapeNonAscii"]=>
- bool(false)
- ["prettyPrint"]=>
- bool(false)
- ["indentTabs"]=>
- bool(true)
- ["indentSize"]=>
- int(2)
- ["flushEveryValue"]=>
- bool(false)
- ["maxContainerDepth"]=>
- int(20)
- ["maxAnnotations"]=>
- int(10)
- ["tempBufferSize"]=>
- int(131072)
-}
-object(ion\Writer\Options)#%d (12) {
- ["catalog"]=>
- object(ion\Catalog)#%d (1) {
- ["symbolTables":"ion\Catalog":private]=>
- array(0) {
- }
- }
- ["decimalContext"]=>
- object(ion\Decimal\Context)#%d (5) {
- ["digits"]=>
- int(16)
- ["eMax"]=>
- int(384)
- ["eMin"]=>
- int(-383)
- ["round"]=>
- int(3)
- ["clamp"]=>
- bool(true)
- }
- ["outputBinary"]=>
- bool(true)
- ["compactFloats"]=>
- bool(false)
- ["escapeNonAscii"]=>
- bool(false)
- ["prettyPrint"]=>
- bool(false)
- ["indentTabs"]=>
- bool(true)
- ["indentSize"]=>
- int(2)
- ["flushEveryValue"]=>
- bool(false)
- ["maxContainerDepth"]=>
- int(20)
- ["maxAnnotations"]=>
- int(10)
- ["tempBufferSize"]=>
- int(131072)
-}
-DONE
<?php
class AutoUtf8 extends ion\Serializer\Serializer {
- public function serialize(mixed $data, \ion\Writer\Options|\ion\Writer|array|null $writer = null): mixed {
+ public function serialize(mixed $data, \ion\Writer|array|null $writer = null): mixed {
return parent::serialize($data, new class extends \ion\Writer\Buffer\Writer {
private function iterate(string $s) : Generator {
for ($i = 0; $i < grapheme_strlen($s); ++$i) {
<?php
class NoDecimals extends ion\Serializer\Serializer {
- public function serialize(mixed $data, \ion\Writer\Options|\ion\Writer|array|null $writer = null): mixed {
+ public function serialize(mixed $data, \ion\Writer|array|null $writer = null): mixed {
return parent::serialize($data, new class extends \ion\Writer\Buffer\Writer {
public function writeDecimal(\ion\Decimal|string $value): void {
if ($value instanceof \ion\Decimal) {