RETURN_BOOL(ion_decimal_is_integer(&obj->dec));
}
+ZEND_METHOD(ion_LOB, __construct)
+{
+ zend_string *value;
+ zend_object *type = NULL;
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_STR(value)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJ_OF_CLASS(type, ce_Type)
+ ZEND_PARSE_PARAMETERS_END();
+
+ if (!type) {
+ type = zend_enum_get_case_cstr(ce_Type, "CLob");
+ }
+ 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);
+}
ZEND_METHOD(ion_Reader_Options, __construct)
{
php_ion_reader_options *opt = php_ion_obj(reader_options, Z_OBJ_P(ZEND_THIS));
ce_Symbol_System_SID = register_class_ion_Symbol_System_SID();
ce_Collection = register_class_ion_Collection();
+ ce_LOB = register_class_ion_LOB();
php_ion_register(decimal, Decimal);
php_ion_register(decimal_ctx, Decimal_Context);
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 13de1401ca779d900a35c7be3ac484c8d4dde44d */
+ * Stub hash: f2b34e7e90a3fcb65ad470c6acce7cc31b804716 */
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)
#define arginfo_class_ion_Symbol_toString arginfo_class_ion_Symbol___toString
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_LOB___construct, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, type, ion\\Type, 0, "ion\\Type::CLob")
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ion_Decimal_Context___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bits, IS_LONG, 0, "128")
ZEND_END_ARG_INFO()
ZEND_METHOD(ion_Symbol, __construct);
ZEND_METHOD(ion_Symbol, equals);
ZEND_METHOD(ion_Symbol, __toString);
+ZEND_METHOD(ion_LOB, __construct);
ZEND_METHOD(ion_Decimal_Context, __construct);
ZEND_METHOD(ion_Decimal, __construct);
ZEND_METHOD(ion_Decimal, equals);
};
+static const zend_function_entry class_ion_LOB_methods[] = {
+ ZEND_ME(ion_LOB, __construct, arginfo_class_ion_LOB___construct, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
+
+
static const zend_function_entry class_ion_Decimal_Context_methods[] = {
ZEND_ME(ion_Decimal_Context, __construct, arginfo_class_ion_Decimal_Context___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
return class_entry;
}
+static zend_class_entry *register_class_ion_LOB(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_NS_CLASS_ENTRY(ce, "ion", "LOB", class_ion_LOB_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));
+ zend_string_release(property_value_name);
+
+ zend_string *property_type_class_ion_Type = zend_string_init("ion\\Type", sizeof("ion\\Type")-1, 1);
+ zval property_type_default_value;
+ ZVAL_UNDEF(&property_type_default_value);
+ zend_string *property_type_name = zend_string_init("type", sizeof("type") - 1, 1);
+ zend_declare_typed_property(class_entry, property_type_name, &property_type_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_type_class_ion_Type, 0, 0));
+ zend_string_release(property_type_name);
+
+ return class_entry;
+}
+
static zend_class_entry *register_class_ion_Decimal_Context(void)
{
zend_class_entry ce, *class_entry;
*ce_Collection,
*ce_Decimal,
*ce_Decimal_Context,
+ *ce_LOB,
*ce_Reader,
*ce_Reader_Options,
*ce_Reader_Reader,
}
}
+static inline 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);
+ 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)));
+ break;
+ case tid_CLOB_INT:
+ ION_CHECK(ion_writer_write_clob(ser->writer, (BYTE *) Z_STRVAL_P(value), Z_STRLEN_P(value)));
+ break;
+ default:
+ zend_throw_exception_ex(spl_ce_InvalidArgumentException, IERR_INVALID_ARG,
+ "Unsupported LOB type: ion\\Type::%s", Z_STRVAL_P(zend_enum_fetch_case_name(Z_OBJ_P(type))));
+ break;
+ }
+}
+
static inline bool can_call_magic_serialize(php_ion_serializer *ser, zend_class_entry *ce)
{
return ce->__serialize && ser->call_magic;
php_ion_timestamp *pts = php_ion_obj(timestamp, zobject);
decContext *ctx = ser->options ? ser->options->decimal_context : NULL;
ION_CHECK(ion_writer_write_timestamp(ser->writer, ion_timestamp_from_php(&its, pts, ctx)));
+ } else if (ce == ce_LOB) {
+ php_ion_serialize_object_lob(ser, zobject);
} else {
php_ion_serialize_object_std(ser, zobject);
}
}
ION_CHECK(err, zend_string_release(zstr));
if (zstr->len > read) {
+ zstr->val[read] = 0;
zstr = zend_string_truncate(zstr, read, 0);
}
RETURN_STR(zstr);