// // This file is generated by fmtgen from "libaegis/fattr.def". // If you want to change the contents of this file // you need to edit libaegis/fattr.def // or you need to enhance fmtgen. // #include #include #include #include #include #include #include #include #include #include #include #include void fattr_write(const output::pointer &fp, fattr_ty *this_thing) { if (!this_thing) return; trace(("fattr_write(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((fattr_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((fattr_ty *)this_thing)->reference_count)); attributes_list_write(fp, "attribute", this_thing->attribute); trace(("}\n")); } void fattr_write_xml(const output::pointer &fp, fattr_ty *this_thing) { if (!this_thing) return; trace(("fattr_write_xml(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((fattr_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((fattr_ty *)this_thing)->reference_count)); fp->fputs("\n"); attributes_list_write_xml(fp, "attribute", this_thing->attribute); fp->fputs("\n"); } static void * fattr_alloc(void) { fattr_ty *this_thing; trace(("fattr_alloc()\n{\n")); this_thing = (fattr_ty *)mem_alloc(sizeof(fattr_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->attribute = (attributes_list_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } fattr_ty * fattr_copy(fattr_ty *this_thing) { trace(("fattr_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } fattr_ty * fattr_clone(fattr_ty *this_thing) { if (!this_thing) return 0; trace(("fattr_clone()\n{\n")); fattr_ty *result = (fattr_ty *)fattr_alloc(); result->attribute = attributes_list_clone(this_thing->attribute); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void fattr_trace_real(const char *name, const fattr_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); attributes_list_trace_real("attribute", value->attribute); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void fattr_free(void *that) { fattr_ty *this_thing; this_thing = (fattr_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("fattr_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } attributes_list_type.free(this_thing->attribute); mem_free(this_thing); trace(("}\n")); } static type_table_ty fattr_table[] = { { "attribute", offsetof(fattr_ty, attribute), &attributes_list_type, fattr_attribute_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * fattr_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("fattr_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((fattr_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, fattr_table, SIZEOF(fattr_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * fattr_fuzzy(string_ty *name) { string_ty *result; trace(("fattr_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, fattr_table, SIZEOF(fattr_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer fattr_convert(void *this_thing) { trace(("fattr_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((fattr_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, fattr_table, SIZEOF(fattr_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type fattr_type = { "fattr", fattr_alloc, fattr_free, 0, // enum_parse 0, // list_parse fattr_parse, fattr_fuzzy, fattr_convert, generic_struct_is_set, }; fattr_ty * fattr_read_file(const nstring &filename) { return fattr_read_file(filename.get_ref()); } fattr_ty * fattr_read_file(string_ty *filename) { fattr_ty *result; trace(("fattr_read_file(filename = \"%s\")\n{\n", (filename ? filename->str_text : ""))); os_become_must_be_active(); result = (fattr_ty *)parse(filename, &fattr_type); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } void fattr_write_file(const nstring &filename, fattr_ty *value, bool comp) { fattr_write_file(filename.get_ref(), value, comp); } void fattr_write_file(string_ty *filename, fattr_ty *value, int needs_compression) { trace(("fattr_write_file(filename = \"%s\", value = %08lX)\n{\n", (filename ? filename->str_text : ""), (long)value)); if (filename) os_become_must_be_active(); output::pointer fp; if (needs_compression) { fp = output_file::binary_open(filename); fp = output_gzip::create(fp); } else { fp = output_file::text_open(filename); } fp = output_indent::create(fp); io_comment_emit(fp); fattr_write(fp, value); type_enum_option_clear(); trace(("}\n")); } void fattr__rpt_init(void) { trace(("fattr__rpt_init()\n{\n")); trace(("}\n")); }