- BOOL has_annotations;
- int32_t ann_index = 0, ann_count = 0;
- ION_STRING annotation = {0};
- ION_CHECK(ion_reader_has_any_annotations(obj->reader, &has_annotations));
- if (has_annotations) {
- ION_CHECK(ion_reader_get_annotation_count(obj->reader, &ann_count));
- next_annotation();
+ case 'p':
+ if (ser->annotations.object_prop) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid multiple object property annotations");
+ return;
+ }
+ ser->annotations.object_prop = true;
+
+ ION_STRING prop_class;
+ ION_CHECK(ion_reader_get_an_annotation(ser->reader, ++i, &prop_class));
+ ser->annotations.property_class = zend_string_from_ion(&prop_class);
+
+ zval zptmp;
+ ZVAL_STR(&zptmp, ser->annotations.property_class);
+ zend_hash_next_index_insert(ser->tmp, &zptmp);
+ break;
+
+ case 'E':
+ case 'S':
+ case 'O':
+ case 'C':
+ case 'o':
+ case 'c':
+ if (ser->annotations.object_type) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid multiple object type annotations: %c::%c",
+ ser->annotations.object_type, *ann_str.value);
+ return;
+ }
+ if ('o' != (ser->annotations.object_type = *ann_str.value)) {
+ ION_STRING class_name;
+ ION_CHECK(ion_reader_get_an_annotation(ser->reader, ++i, &class_name));
+ ser->annotations.object_class = zend_string_from_ion(&class_name);
+
+ zval zctmp;
+ ZVAL_STR(&zctmp, ser->annotations.object_class);
+ zend_hash_next_index_insert(ser->tmp, &zctmp);
+ }
+ break;
+ }
+
+ // sanity checks
+ if (ser->annotations.object_type && ser->annotations.object_type != 'o' && !ser->annotations.object_class) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid object annotation without class name: %c::", ser->annotations.object_type);
+ return;
+ }
+ if (ser->annotations.object_type == 'o' && ser->annotations.object_class) {
+ zend_throw_exception_ex(spl_ce_RuntimeException, IERR_INVALID_SYNTAX,
+ "Invalid object annotation with class name: o::%s", ser->annotations.object_class->val);
+ return;
+ }