// // This file is generated by fmtgen from "libaegis/rptidx.def". // If you want to change the contents of this file // you need to edit libaegis/rptidx.def // or you need to enhance fmtgen. // #include #include #include #include #include #include #include #include #include #include #include #include void rptidx_where_write(const output::pointer &fp, const char *name, rptidx_where_ty *this_thing) { if (!this_thing) return; trace(("rptidx_where_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(((rptidx_where_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((rptidx_where_ty *)this_thing)->reference_count)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } fp->fputs("{\n"); string_write(fp, "name", this_thing->name); string_write(fp, "description", this_thing->description); string_write(fp, "filename", this_thing->filename); fp->fputs("}"); if (name) fp->fputs(";\n"); trace(("}\n")); } void rptidx_where_write_xml(const output::pointer &fp, const char *name, rptidx_where_ty *this_thing) { if (!this_thing) return; trace(("rptidx_where_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); assert(((rptidx_where_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((rptidx_where_ty *)this_thing)->reference_count)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); string_write_xml(fp, "name", this_thing->name); string_write_xml(fp, "description", this_thing->description); string_write_xml(fp, "filename", this_thing->filename); fp->fputs("fputs(name); fp->fputs(">\n"); } static void * rptidx_where_alloc(void) { rptidx_where_ty *this_thing; trace(("rptidx_where_alloc()\n{\n")); this_thing = (rptidx_where_ty *)mem_alloc(sizeof(rptidx_where_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->name = (string_ty *)0; this_thing->description = (string_ty *)0; this_thing->filename = (string_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } rptidx_where_ty * rptidx_where_copy(rptidx_where_ty *this_thing) { trace(("rptidx_where_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } rptidx_where_ty * rptidx_where_clone(rptidx_where_ty *this_thing) { if (!this_thing) return 0; trace(("rptidx_where_clone()\n{\n")); rptidx_where_ty *result = (rptidx_where_ty *)rptidx_where_alloc(); result->name = str_copy(this_thing->name); result->description = str_copy(this_thing->description); result->filename = str_copy(this_thing->filename); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void rptidx_where_trace_real(const char *name, const rptidx_where_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); trace_string_real("name", value->name); trace_string_real("description", value->description); trace_string_real("filename", value->filename); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void rptidx_where_free(void *that) { rptidx_where_ty *this_thing; this_thing = (rptidx_where_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("rptidx_where_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } str_free(this_thing->name); str_free(this_thing->description); str_free(this_thing->filename); mem_free(this_thing); trace(("}\n")); } static type_table_ty rptidx_where_table[] = { { "name", offsetof(rptidx_where_ty, name), &string_type, rptidx_where_name_mask, 0, // redefinition not ok 0, // fast_name }, { "description", offsetof(rptidx_where_ty, description), &string_type, rptidx_where_description_mask, 0, // redefinition not ok 0, // fast_name }, { "filename", offsetof(rptidx_where_ty, filename), &string_type, rptidx_where_filename_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * rptidx_where_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("rptidx_where_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((rptidx_where_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, rptidx_where_table, SIZEOF(rptidx_where_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * rptidx_where_fuzzy(string_ty *name) { string_ty *result; trace(("rptidx_where_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, rptidx_where_table, SIZEOF(rptidx_where_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer rptidx_where_convert(void *this_thing) { trace(("rptidx_where_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((rptidx_where_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, rptidx_where_table, SIZEOF(rptidx_where_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type rptidx_where_type = { "rptidx_where", rptidx_where_alloc, rptidx_where_free, 0, // enum_parse 0, // list_parse rptidx_where_parse, rptidx_where_fuzzy, rptidx_where_convert, generic_struct_is_set, }; #include void rptidx_where_list_write(const output::pointer &fp, const char *name, rptidx_where_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("rptidx_where_list_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); fp->fputs("[\n"); for (j = 0; j < this_thing->length; ++j) { rptidx_where_write(fp, (const char *)0, this_thing->list[j]); fp->fputs(",\n"); } fp->fputs("]"); if (name) fp->fputs(";\n"); trace(("}\n")); } void rptidx_where_list_write_xml(const output::pointer &fp, const char *name, rptidx_where_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("rptidx_where_list_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); for (j = 0; j < this_thing->length; ++j) { rptidx_where_write_xml(fp, "rptidx_where", this_thing->list[j]); } fp->fputs("fputs(name); fp->fputs(">\n"); trace(("}\n")); } static void * rptidx_where_list_alloc(void) { rptidx_where_list_ty *result; trace(("rptidx_where_list_alloc()\n{\n")); result = (rptidx_where_list_ty *)mem_alloc(sizeof(rptidx_where_list_ty)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static void rptidx_where_list_free(void *that) { rptidx_where_list_ty *this_thing; size_t j; this_thing = (rptidx_where_list_ty *)that; if (!this_thing) return; trace(("rptidx_where_list_free(this_thing = %08lX)\n{\n", (long)this_thing)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); for (j = 0; j < this_thing->length; ++j) rptidx_where_free(this_thing->list[j]); delete [] this_thing->list; mem_free(this_thing); trace(("}\n")); } static void * rptidx_where_list_parse(void *that, meta_type **type_pp) { rptidx_where_list_ty *this_thing; void *addr; this_thing = (rptidx_where_list_ty *)that; trace(("rptidx_where_list_parse(this_thing = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)type_pp)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); *type_pp = &rptidx_where_type; trace_pointer(*type_pp); if (this_thing->length >= this_thing->maximum) { this_thing->maximum = this_thing->maximum * 2 + 16; rptidx_where_ty * *new_list = new rptidx_where_ty * [this_thing->maximum]; for (size_t j = 0; j < this_thing->length; ++j) new_list[j] = this_thing->list[j]; delete [] this_thing->list; this_thing->list = new_list; } addr = &this_thing->list[this_thing->length++]; trace(("return %08lX;\n", (long)addr)); trace(("}\n")); return addr; } static rpt_value::pointer rptidx_where_list_convert(void *that) { rptidx_where_list_ty *this_thing; size_t j; rpt_value::pointer vp; this_thing = *(rptidx_where_list_ty **)that; if (!this_thing) return rpt_value::pointer(); trace(("rptidx_where_list_convert(this_thing = %08lX)\n{\n", (long)this_thing)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); rpt_value_list *p = new rpt_value_list(); rpt_value::pointer result(p); for (j = 0; j < this_thing->length; ++j) { vp = rptidx_where_type.convert(&this_thing->list[j]); assert(vp); p->append(vp); } trace(("}\n")); trace(("return %08lX;\n", (long)result.get())); return result; } rptidx_where_list_ty * rptidx_where_list_copy(rptidx_where_list_ty *from) { size_t j; rptidx_where_list_ty *result; if (!from) return 0; trace(("rptidx_where_list_copy(from = %08lX)\n{\n", (long)from)); result = (rptidx_where_list_ty *)rptidx_where_list_alloc(); assert(from->length <= from->maximum); assert(!from->list == !from->maximum); for (j = 0; j < from->length; ++j) { rptidx_where_ty * mp; rptidx_where_ty * *mpp; meta_type *bogus; mp = from->list[j]; mpp = (rptidx_where_ty **)rptidx_where_list_parse(result, &bogus); *mpp = rptidx_where_copy(mp); } trace(("return %8.8lX\n", (long)result)); trace(("}\n")); return result; } rptidx_where_list_ty * rptidx_where_list_clone(rptidx_where_list_ty *from) { return rptidx_where_list_copy(from); } #ifdef DEBUG void rptidx_where_list_trace_real(const char *name, const rptidx_where_list_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("[\n"); trace_printf("// length = %ld\n", (long)value->length); trace_printf("// maximum = %ld\n", (long)value->maximum); assert(value->length <= value->maximum); assert(!value->list == !value->maximum); for (size_t j = 0; j < value->length; ++j) { rptidx_where_ty * mp = value->list[j]; rptidx_where_trace_real("", mp); } trace_printf("]"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG meta_type rptidx_where_list_type = { "rptidx_where_list", rptidx_where_list_alloc, rptidx_where_list_free, 0, // enum_parse rptidx_where_list_parse, 0, // struct_parse 0, // fuzzy rptidx_where_list_convert, generic_struct_is_set, }; void rptidx_write(const output::pointer &fp, rptidx_ty *this_thing) { if (!this_thing) return; trace(("rptidx_write(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((rptidx_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((rptidx_ty *)this_thing)->reference_count)); rptidx_where_list_write(fp, "where", this_thing->where); trace(("}\n")); } void rptidx_write_xml(const output::pointer &fp, rptidx_ty *this_thing) { if (!this_thing) return; trace(("rptidx_write_xml(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((rptidx_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((rptidx_ty *)this_thing)->reference_count)); fp->fputs("\n"); rptidx_where_list_write_xml(fp, "where", this_thing->where); fp->fputs("\n"); } static void * rptidx_alloc(void) { rptidx_ty *this_thing; trace(("rptidx_alloc()\n{\n")); this_thing = (rptidx_ty *)mem_alloc(sizeof(rptidx_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->where = (rptidx_where_list_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } rptidx_ty * rptidx_copy(rptidx_ty *this_thing) { trace(("rptidx_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } rptidx_ty * rptidx_clone(rptidx_ty *this_thing) { if (!this_thing) return 0; trace(("rptidx_clone()\n{\n")); rptidx_ty *result = (rptidx_ty *)rptidx_alloc(); result->where = rptidx_where_list_clone(this_thing->where); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void rptidx_trace_real(const char *name, const rptidx_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); rptidx_where_list_trace_real("where", value->where); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void rptidx_free(void *that) { rptidx_ty *this_thing; this_thing = (rptidx_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("rptidx_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } rptidx_where_list_free(this_thing->where); mem_free(this_thing); trace(("}\n")); } static type_table_ty rptidx_table[] = { { "where", offsetof(rptidx_ty, where), &rptidx_where_list_type, rptidx_where_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * rptidx_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("rptidx_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((rptidx_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, rptidx_table, SIZEOF(rptidx_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * rptidx_fuzzy(string_ty *name) { string_ty *result; trace(("rptidx_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, rptidx_table, SIZEOF(rptidx_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer rptidx_convert(void *this_thing) { trace(("rptidx_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((rptidx_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, rptidx_table, SIZEOF(rptidx_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type rptidx_type = { "rptidx", rptidx_alloc, rptidx_free, 0, // enum_parse 0, // list_parse rptidx_parse, rptidx_fuzzy, rptidx_convert, generic_struct_is_set, }; rptidx_ty * rptidx_read_file(const nstring &filename) { return rptidx_read_file(filename.get_ref()); } rptidx_ty * rptidx_read_file(string_ty *filename) { rptidx_ty *result; trace(("rptidx_read_file(filename = \"%s\")\n{\n", (filename ? filename->str_text : ""))); os_become_must_be_active(); result = (rptidx_ty *)parse(filename, &rptidx_type); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } void rptidx_write_file(const nstring &filename, rptidx_ty *value, bool comp) { rptidx_write_file(filename.get_ref(), value, comp); } void rptidx_write_file(string_ty *filename, rptidx_ty *value, int needs_compression) { trace(("rptidx_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); rptidx_write(fp, value); type_enum_option_clear(); trace(("}\n")); } void rptidx__rpt_init(void) { trace(("rptidx__rpt_init()\n{\n")); trace(("}\n")); }