Int64Type* Int64Type_init2(Int64Type *self, float boost, bool_t indexed, bool_t stored, bool_t sortable) { return (Int64Type*)NumType_init2((NumericType*)self, boost, indexed, stored, sortable); }
NumericType* NumType_load(NumericType *self, Obj *dump) { UNUSED_VAR(self); Hash *source = (Hash*)CERTIFY(dump, HASH); // Get a VTable CharBuf *class_name = (CharBuf*)Hash_Fetch_Str(source, "_class", 6); CharBuf *type_spec = (CharBuf*)Hash_Fetch_Str(source, "type", 4); VTable *vtable = NULL; if (class_name != NULL && Obj_Is_A((Obj*)class_name, CHARBUF)) { vtable = VTable_singleton(class_name, NULL); } else if (type_spec != NULL && Obj_Is_A((Obj*)type_spec, CHARBUF)) { if (CB_Equals_Str(type_spec, "i32_t", 5)) { vtable = INT32TYPE; } else if (CB_Equals_Str(type_spec, "i64_t", 5)) { vtable = INT64TYPE; } else if (CB_Equals_Str(type_spec, "f32_t", 5)) { vtable = FLOAT32TYPE; } else if (CB_Equals_Str(type_spec, "f64_t", 5)) { vtable = FLOAT64TYPE; } else { THROW(ERR, "Unrecognized type string: '%o'", type_spec); } } CERTIFY(vtable, VTABLE); NumericType *loaded = (NumericType*)VTable_Make_Obj(vtable); // Extract boost. Obj *boost_dump = Hash_Fetch_Str(source, "boost", 5); float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f; // Find boolean properties. Obj *indexed_dump = Hash_Fetch_Str(source, "indexed", 7); Obj *stored_dump = Hash_Fetch_Str(source, "stored", 6); Obj *sort_dump = Hash_Fetch_Str(source, "sortable", 8); bool_t indexed = indexed_dump ? (bool_t)Obj_To_I64(indexed_dump) : true; bool_t stored = stored_dump ? (bool_t)Obj_To_I64(stored_dump) : true; bool_t sortable = sort_dump ? (bool_t)Obj_To_I64(sort_dump) : false; return NumType_init2(loaded, boost, indexed, stored, sortable); }
NumericType* NumType_Load_IMP(NumericType *self, Obj *dump) { UNUSED_VAR(self); Hash *source = (Hash*)CERTIFY(dump, HASH); // Get a Class String *class_name = (String*)Hash_Fetch_Utf8(source, "_class", 6); String *type_spec = (String*)Hash_Fetch_Utf8(source, "type", 4); Class *klass = NULL; if (class_name != NULL && Obj_is_a((Obj*)class_name, STRING)) { klass = Class_singleton(class_name, NULL); } else if (type_spec != NULL && Obj_is_a((Obj*)type_spec, STRING)) { if (Str_Equals_Utf8(type_spec, "i32_t", 5)) { klass = INT32TYPE; } else if (Str_Equals_Utf8(type_spec, "i64_t", 5)) { klass = INT64TYPE; } else if (Str_Equals_Utf8(type_spec, "f32_t", 5)) { klass = FLOAT32TYPE; } else if (Str_Equals_Utf8(type_spec, "f64_t", 5)) { klass = FLOAT64TYPE; } else { THROW(ERR, "Unrecognized type string: '%o'", type_spec); } } CERTIFY(klass, CLASS); NumericType *loaded = (NumericType*)Class_Make_Obj(klass); // Extract boost. Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5); float boost = boost_dump ? (float)Json_obj_to_f64(boost_dump) : 1.0f; // Find boolean properties. Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7); Obj *stored_dump = Hash_Fetch_Utf8(source, "stored", 6); Obj *sort_dump = Hash_Fetch_Utf8(source, "sortable", 8); bool indexed = indexed_dump ? Json_obj_to_bool(indexed_dump) : true; bool stored = stored_dump ? Json_obj_to_bool(stored_dump) : true; bool sortable = sort_dump ? Json_obj_to_bool(sort_dump) : false; return NumType_init2(loaded, boost, indexed, stored, sortable); }
NumericType* NumType_init(NumericType *self) { return NumType_init2(self, 1.0, true, true, false); }
Float32Type* Float32Type_init2(Float32Type *self, float boost, bool indexed, bool stored, bool sortable) { return (Float32Type*)NumType_init2((NumericType*)self, boost, indexed, stored, sortable); }