ION_TYPE typ;
ION_CHECK(ion_reader_read_null(obj->reader, &typ));
- RETURN_OBJ_COPY(php_ion_type_fetch(typ));
+ RETURN_IONTYPE(typ);
}
static ZEND_METHOD(ion_Reader_Reader, readBool)
{
Z_PARAM_OBJ_OF_CLASS(typ_obj, ce_Type)
ZEND_PARSE_PARAMETERS_END();
- php_ion_type *typ = php_ion_obj(type, typ_obj);
- OBJ_CHECK(typ);
- ION_CHECK(ion_writer_write_typed_null(obj->writer, php_ion_obj(type, typ)->typ));
+ ION_CHECK(ion_writer_write_typed_null(obj->writer, ion_type_from_enum(typ_obj)));
}
static ZEND_METHOD(ion_Writer_Writer, writeBool)
{
Z_PARAM_OBJ_OF_CLASS(typ_obj, ce_Type)
ZEND_PARSE_PARAMETERS_END();
- php_ion_type *typ = php_ion_obj(type, typ_obj);
- OBJ_CHECK(typ);
- ION_CHECK(ion_writer_start_lob(obj->writer, php_ion_obj(type, typ)->typ));
+ ION_CHECK(ion_writer_start_lob(obj->writer, ion_type_from_enum(typ_obj)));
}
static ZEND_METHOD(ion_Writer_Writer, appendLob)
{
Z_PARAM_OBJ_OF_CLASS(typ_obj, ce_Type)
ZEND_PARSE_PARAMETERS_END();
- php_ion_type *typ = php_ion_obj(type, typ_obj);
- OBJ_CHECK(typ);
- ION_CHECK(ion_writer_start_container(obj->writer, php_ion_obj(type, typ)->typ));
+ ION_CHECK(ion_writer_start_container(obj->writer, ion_type_from_enum(typ_obj)));
}
static ZEND_METHOD(ion_Writer_Writer, finishContainer)
{
ce_Timestamp_Precision = register_class_ion_Timestamp_Precision();
// Type
- php_ion_register(type, Type);
+ ce_Type = register_class_ion_Type();
// Writer
ce_Writer = register_class_ion_Writer();
zend_update_property(obj->ce, obj, n, l, &zobj);
}
-typedef struct php_ion_type {
- ION_TYPE typ;
- zend_object std;
-} php_ion_type;
-
-php_ion_decl(type, Type);
-
#define RETURN_IONTYPE(typ) do { \
zend_object *__zo = php_ion_type_fetch(typ); \
if (UNEXPECTED(!__zo)) { \
return zend_enum_get_case(ce_Type, Z_STR_P(ztype));
}
+static inline ION_TYPE ion_type_from_enum(zend_object *zo)
+{
+ return Z_LVAL_P(zend_enum_fetch_case_value(zo));
+}
+
typedef struct php_ion_symbol_iloc {
ION_SYMBOL_IMPORT_LOCATION loc;
zend_string *name;