// // This file is generated by fmtgen from "libaegis/gstate.def". // If you want to change the contents of this file // you need to edit libaegis/gstate.def // or you need to enhance fmtgen. // #include #include #include #include #include #include #include #include #include #include #include #include void gstate_where_write(const output::pointer &fp, const char *name, gstate_where_ty *this_thing) { if (!this_thing) return; trace(("gstate_where_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(((gstate_where_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((gstate_where_ty *)this_thing)->reference_count)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } fp->fputs("{\n"); string_write(fp, "project_name", this_thing->project_name); string_write(fp, "directory", this_thing->directory); string_write(fp, "alias_for", this_thing->alias_for); fp->fputs("}"); if (name) fp->fputs(";\n"); trace(("}\n")); } void gstate_where_write_xml(const output::pointer &fp, const char *name, gstate_where_ty *this_thing) { if (!this_thing) return; trace(("gstate_where_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); assert(((gstate_where_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((gstate_where_ty *)this_thing)->reference_count)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); string_write_xml(fp, "project_name", this_thing->project_name); string_write_xml(fp, "directory", this_thing->directory); string_write_xml(fp, "alias_for", this_thing->alias_for); fp->fputs("fputs(name); fp->fputs(">\n"); } static void * gstate_where_alloc(void) { gstate_where_ty *this_thing; trace(("gstate_where_alloc()\n{\n")); this_thing = (gstate_where_ty *)mem_alloc(sizeof(gstate_where_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->project_name = (string_ty *)0; this_thing->directory = (string_ty *)0; this_thing->alias_for = (string_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } gstate_where_ty * gstate_where_copy(gstate_where_ty *this_thing) { trace(("gstate_where_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } gstate_where_ty * gstate_where_clone(gstate_where_ty *this_thing) { if (!this_thing) return 0; trace(("gstate_where_clone()\n{\n")); gstate_where_ty *result = (gstate_where_ty *)gstate_where_alloc(); result->project_name = str_copy(this_thing->project_name); result->directory = str_copy(this_thing->directory); result->alias_for = str_copy(this_thing->alias_for); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void gstate_where_trace_real(const char *name, const gstate_where_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); trace_string_real("project_name", value->project_name); trace_string_real("directory", value->directory); trace_string_real("alias_for", value->alias_for); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void gstate_where_free(void *that) { gstate_where_ty *this_thing; this_thing = (gstate_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(("gstate_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->project_name); str_free(this_thing->directory); str_free(this_thing->alias_for); mem_free(this_thing); trace(("}\n")); } static type_table_ty gstate_where_table[] = { { "project_name", offsetof(gstate_where_ty, project_name), &string_type, gstate_where_project_name_mask, 0, // redefinition not ok 0, // fast_name }, { "directory", offsetof(gstate_where_ty, directory), &string_type, gstate_where_directory_mask, 0, // redefinition not ok 0, // fast_name }, { "alias_for", offsetof(gstate_where_ty, alias_for), &string_type, gstate_where_alias_for_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * gstate_where_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("gstate_where_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((gstate_where_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, gstate_where_table, SIZEOF(gstate_where_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * gstate_where_fuzzy(string_ty *name) { string_ty *result; trace(("gstate_where_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, gstate_where_table, SIZEOF(gstate_where_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer gstate_where_convert(void *this_thing) { trace(("gstate_where_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((gstate_where_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, gstate_where_table, SIZEOF(gstate_where_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type gstate_where_type = { "gstate_where", gstate_where_alloc, gstate_where_free, 0, // enum_parse 0, // list_parse gstate_where_parse, gstate_where_fuzzy, gstate_where_convert, generic_struct_is_set, }; #include void gstate_where_list_write(const output::pointer &fp, const char *name, gstate_where_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("gstate_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) { gstate_where_write(fp, (const char *)0, this_thing->list[j]); fp->fputs(",\n"); } fp->fputs("]"); if (name) fp->fputs(";\n"); trace(("}\n")); } void gstate_where_list_write_xml(const output::pointer &fp, const char *name, gstate_where_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("gstate_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) { gstate_where_write_xml(fp, "gstate_where", this_thing->list[j]); } fp->fputs("fputs(name); fp->fputs(">\n"); trace(("}\n")); } static void * gstate_where_list_alloc(void) { gstate_where_list_ty *result; trace(("gstate_where_list_alloc()\n{\n")); result = (gstate_where_list_ty *)mem_alloc(sizeof(gstate_where_list_ty)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static void gstate_where_list_free(void *that) { gstate_where_list_ty *this_thing; size_t j; this_thing = (gstate_where_list_ty *)that; if (!this_thing) return; trace(("gstate_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) gstate_where_free(this_thing->list[j]); delete [] this_thing->list; mem_free(this_thing); trace(("}\n")); } static void * gstate_where_list_parse(void *that, meta_type **type_pp) { gstate_where_list_ty *this_thing; void *addr; this_thing = (gstate_where_list_ty *)that; trace(("gstate_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 = &gstate_where_type; trace_pointer(*type_pp); if (this_thing->length >= this_thing->maximum) { this_thing->maximum = this_thing->maximum * 2 + 16; gstate_where_ty * *new_list = new gstate_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 gstate_where_list_convert(void *that) { gstate_where_list_ty *this_thing; size_t j; rpt_value::pointer vp; this_thing = *(gstate_where_list_ty **)that; if (!this_thing) return rpt_value::pointer(); trace(("gstate_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 = gstate_where_type.convert(&this_thing->list[j]); assert(vp); p->append(vp); } trace(("}\n")); trace(("return %08lX;\n", (long)result.get())); return result; } gstate_where_list_ty * gstate_where_list_copy(gstate_where_list_ty *from) { size_t j; gstate_where_list_ty *result; if (!from) return 0; trace(("gstate_where_list_copy(from = %08lX)\n{\n", (long)from)); result = (gstate_where_list_ty *)gstate_where_list_alloc(); assert(from->length <= from->maximum); assert(!from->list == !from->maximum); for (j = 0; j < from->length; ++j) { gstate_where_ty * mp; gstate_where_ty * *mpp; meta_type *bogus; mp = from->list[j]; mpp = (gstate_where_ty **)gstate_where_list_parse(result, &bogus); *mpp = gstate_where_copy(mp); } trace(("return %8.8lX\n", (long)result)); trace(("}\n")); return result; } gstate_where_list_ty * gstate_where_list_clone(gstate_where_list_ty *from) { return gstate_where_list_copy(from); } #ifdef DEBUG void gstate_where_list_trace_real(const char *name, const gstate_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) { gstate_where_ty * mp = value->list[j]; gstate_where_trace_real("", mp); } trace_printf("]"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG meta_type gstate_where_list_type = { "gstate_where_list", gstate_where_list_alloc, gstate_where_list_free, 0, // enum_parse gstate_where_list_parse, 0, // struct_parse 0, // fuzzy gstate_where_list_convert, generic_struct_is_set, }; void gstate_write(const output::pointer &fp, gstate_ty *this_thing) { if (!this_thing) return; trace(("gstate_write(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((gstate_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((gstate_ty *)this_thing)->reference_count)); gstate_where_list_write(fp, "where", this_thing->where); trace(("}\n")); } void gstate_write_xml(const output::pointer &fp, gstate_ty *this_thing) { if (!this_thing) return; trace(("gstate_write_xml(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((gstate_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((gstate_ty *)this_thing)->reference_count)); fp->fputs("\n"); gstate_where_list_write_xml(fp, "where", this_thing->where); fp->fputs("\n"); } static void * gstate_alloc(void) { gstate_ty *this_thing; trace(("gstate_alloc()\n{\n")); this_thing = (gstate_ty *)mem_alloc(sizeof(gstate_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->where = (gstate_where_list_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } gstate_ty * gstate_copy(gstate_ty *this_thing) { trace(("gstate_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } gstate_ty * gstate_clone(gstate_ty *this_thing) { if (!this_thing) return 0; trace(("gstate_clone()\n{\n")); gstate_ty *result = (gstate_ty *)gstate_alloc(); result->where = gstate_where_list_clone(this_thing->where); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void gstate_trace_real(const char *name, const gstate_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); gstate_where_list_trace_real("where", value->where); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void gstate_free(void *that) { gstate_ty *this_thing; this_thing = (gstate_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("gstate_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } gstate_where_list_free(this_thing->where); mem_free(this_thing); trace(("}\n")); } static type_table_ty gstate_table[] = { { "where", offsetof(gstate_ty, where), &gstate_where_list_type, gstate_where_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * gstate_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("gstate_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((gstate_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, gstate_table, SIZEOF(gstate_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * gstate_fuzzy(string_ty *name) { string_ty *result; trace(("gstate_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, gstate_table, SIZEOF(gstate_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer gstate_convert(void *this_thing) { trace(("gstate_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((gstate_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, gstate_table, SIZEOF(gstate_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type gstate_type = { "gstate", gstate_alloc, gstate_free, 0, // enum_parse 0, // list_parse gstate_parse, gstate_fuzzy, gstate_convert, generic_struct_is_set, }; gstate_ty * gstate_read_file(const nstring &filename) { return gstate_read_file(filename.get_ref()); } gstate_ty * gstate_read_file(string_ty *filename) { gstate_ty *result; trace(("gstate_read_file(filename = \"%s\")\n{\n", (filename ? filename->str_text : ""))); os_become_must_be_active(); result = (gstate_ty *)parse(filename, &gstate_type); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } void gstate_write_file(const nstring &filename, gstate_ty *value, bool comp) { gstate_write_file(filename.get_ref(), value, comp); } void gstate_write_file(string_ty *filename, gstate_ty *value, int needs_compression) { trace(("gstate_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); gstate_write(fp, value); type_enum_option_clear(); trace(("}\n")); } void gstate__rpt_init(void) { trace(("gstate__rpt_init()\n{\n")); trace(("}\n")); }