// // This file is generated by fmtgen from "libaegis/ustate.def". // If you want to change the contents of this file // you need to edit libaegis/ustate.def // or you need to enhance fmtgen. // #include #include #include #include #include #include #include #include #include #include #include #include #include void ustate_own_changes_list_write(const output::pointer &fp, const char *name, ustate_own_changes_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("ustate_own_changes_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) { integer_write(fp, (const char *)0, this_thing->list[j], 1); fp->fputs(",\n"); } fp->fputs("]"); if (name) fp->fputs(";\n"); trace(("}\n")); } void ustate_own_changes_list_write_xml(const output::pointer &fp, const char *name, ustate_own_changes_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("ustate_own_changes_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) { integer_write_xml(fp, "integer", this_thing->list[j], 1); } fp->fputs("fputs(name); fp->fputs(">\n"); trace(("}\n")); } static void * ustate_own_changes_list_alloc(void) { ustate_own_changes_list_ty *result; trace(("ustate_own_changes_list_alloc()\n{\n")); result = (ustate_own_changes_list_ty *)mem_alloc(sizeof(ustate_own_changes_list_ty)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static void ustate_own_changes_list_free(void *that) { ustate_own_changes_list_ty *this_thing; size_t j; this_thing = (ustate_own_changes_list_ty *)that; if (!this_thing) return; trace(("ustate_own_changes_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) ; delete [] this_thing->list; mem_free(this_thing); trace(("}\n")); } static void * ustate_own_changes_list_parse(void *that, meta_type **type_pp) { ustate_own_changes_list_ty *this_thing; void *addr; this_thing = (ustate_own_changes_list_ty *)that; trace(("ustate_own_changes_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 = &integer_type; trace_pointer(*type_pp); if (this_thing->length >= this_thing->maximum) { this_thing->maximum = this_thing->maximum * 2 + 16; long *new_list = new long [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 ustate_own_changes_list_convert(void *that) { ustate_own_changes_list_ty *this_thing; size_t j; rpt_value::pointer vp; this_thing = *(ustate_own_changes_list_ty **)that; if (!this_thing) return rpt_value::pointer(); trace(("ustate_own_changes_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 = integer_type.convert(&this_thing->list[j]); assert(vp); p->append(vp); } trace(("}\n")); trace(("return %08lX;\n", (long)result.get())); return result; } ustate_own_changes_list_ty * ustate_own_changes_list_copy(ustate_own_changes_list_ty *from) { size_t j; ustate_own_changes_list_ty *result; if (!from) return 0; trace(("ustate_own_changes_list_copy(from = %08lX)\n{\n", (long)from)); result = (ustate_own_changes_list_ty *)ustate_own_changes_list_alloc(); assert(from->length <= from->maximum); assert(!from->list == !from->maximum); for (j = 0; j < from->length; ++j) { long mp; long *mpp; meta_type *bogus; mp = from->list[j]; mpp = (long*)ustate_own_changes_list_parse(result, &bogus); *mpp = integer_copy(mp); } trace(("return %8.8lX\n", (long)result)); trace(("}\n")); return result; } ustate_own_changes_list_ty * ustate_own_changes_list_clone(ustate_own_changes_list_ty *from) { return ustate_own_changes_list_copy(from); } #ifdef DEBUG void ustate_own_changes_list_trace_real(const char *name, const ustate_own_changes_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) { long mp = value->list[j]; trace_long_real("", &mp); } trace_printf("]"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG meta_type ustate_own_changes_list_type = { "ustate_own_changes_list", ustate_own_changes_list_alloc, ustate_own_changes_list_free, 0, // enum_parse ustate_own_changes_list_parse, 0, // struct_parse 0, // fuzzy ustate_own_changes_list_convert, generic_struct_is_set, }; void ustate_own_write(const output::pointer &fp, const char *name, ustate_own_ty *this_thing) { if (!this_thing) return; trace(("ustate_own_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(((ustate_own_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((ustate_own_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); ustate_own_changes_list_write(fp, "changes", this_thing->changes); fp->fputs("}"); if (name) fp->fputs(";\n"); trace(("}\n")); } void ustate_own_write_xml(const output::pointer &fp, const char *name, ustate_own_ty *this_thing) { if (!this_thing) return; trace(("ustate_own_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); assert(((ustate_own_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((ustate_own_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); ustate_own_changes_list_write_xml(fp, "changes", this_thing->changes); fp->fputs("fputs(name); fp->fputs(">\n"); } static void * ustate_own_alloc(void) { ustate_own_ty *this_thing; trace(("ustate_own_alloc()\n{\n")); this_thing = (ustate_own_ty *)mem_alloc(sizeof(ustate_own_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->changes = (ustate_own_changes_list_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } ustate_own_ty * ustate_own_copy(ustate_own_ty *this_thing) { trace(("ustate_own_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } ustate_own_ty * ustate_own_clone(ustate_own_ty *this_thing) { if (!this_thing) return 0; trace(("ustate_own_clone()\n{\n")); ustate_own_ty *result = (ustate_own_ty *)ustate_own_alloc(); result->project_name = str_copy(this_thing->project_name); result->changes = ustate_own_changes_list_clone(this_thing->changes); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void ustate_own_trace_real(const char *name, const ustate_own_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); ustate_own_changes_list_trace_real("changes", value->changes); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void ustate_own_free(void *that) { ustate_own_ty *this_thing; this_thing = (ustate_own_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("ustate_own_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); ustate_own_changes_list_free(this_thing->changes); mem_free(this_thing); trace(("}\n")); } static type_table_ty ustate_own_table[] = { { "project_name", offsetof(ustate_own_ty, project_name), &string_type, ustate_own_project_name_mask, 0, // redefinition not ok 0, // fast_name }, { "changes", offsetof(ustate_own_ty, changes), &ustate_own_changes_list_type, ustate_own_changes_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * ustate_own_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("ustate_own_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((ustate_own_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, ustate_own_table, SIZEOF(ustate_own_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * ustate_own_fuzzy(string_ty *name) { string_ty *result; trace(("ustate_own_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, ustate_own_table, SIZEOF(ustate_own_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer ustate_own_convert(void *this_thing) { trace(("ustate_own_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((ustate_own_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, ustate_own_table, SIZEOF(ustate_own_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type ustate_own_type = { "ustate_own", ustate_own_alloc, ustate_own_free, 0, // enum_parse 0, // list_parse ustate_own_parse, ustate_own_fuzzy, ustate_own_convert, generic_struct_is_set, }; void ustate_own_list_write(const output::pointer &fp, const char *name, ustate_own_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("ustate_own_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) { ustate_own_write(fp, (const char *)0, this_thing->list[j]); fp->fputs(",\n"); } fp->fputs("]"); if (name) fp->fputs(";\n"); trace(("}\n")); } void ustate_own_list_write_xml(const output::pointer &fp, const char *name, ustate_own_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("ustate_own_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) { ustate_own_write_xml(fp, "ustate_own", this_thing->list[j]); } fp->fputs("fputs(name); fp->fputs(">\n"); trace(("}\n")); } static void * ustate_own_list_alloc(void) { ustate_own_list_ty *result; trace(("ustate_own_list_alloc()\n{\n")); result = (ustate_own_list_ty *)mem_alloc(sizeof(ustate_own_list_ty)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static void ustate_own_list_free(void *that) { ustate_own_list_ty *this_thing; size_t j; this_thing = (ustate_own_list_ty *)that; if (!this_thing) return; trace(("ustate_own_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) ustate_own_free(this_thing->list[j]); delete [] this_thing->list; mem_free(this_thing); trace(("}\n")); } static void * ustate_own_list_parse(void *that, meta_type **type_pp) { ustate_own_list_ty *this_thing; void *addr; this_thing = (ustate_own_list_ty *)that; trace(("ustate_own_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 = &ustate_own_type; trace_pointer(*type_pp); if (this_thing->length >= this_thing->maximum) { this_thing->maximum = this_thing->maximum * 2 + 16; ustate_own_ty * *new_list = new ustate_own_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 ustate_own_list_convert(void *that) { ustate_own_list_ty *this_thing; size_t j; rpt_value::pointer vp; this_thing = *(ustate_own_list_ty **)that; if (!this_thing) return rpt_value::pointer(); trace(("ustate_own_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 = ustate_own_type.convert(&this_thing->list[j]); assert(vp); p->append(vp); } trace(("}\n")); trace(("return %08lX;\n", (long)result.get())); return result; } ustate_own_list_ty * ustate_own_list_copy(ustate_own_list_ty *from) { size_t j; ustate_own_list_ty *result; if (!from) return 0; trace(("ustate_own_list_copy(from = %08lX)\n{\n", (long)from)); result = (ustate_own_list_ty *)ustate_own_list_alloc(); assert(from->length <= from->maximum); assert(!from->list == !from->maximum); for (j = 0; j < from->length; ++j) { ustate_own_ty * mp; ustate_own_ty * *mpp; meta_type *bogus; mp = from->list[j]; mpp = (ustate_own_ty **)ustate_own_list_parse(result, &bogus); *mpp = ustate_own_copy(mp); } trace(("return %8.8lX\n", (long)result)); trace(("}\n")); return result; } ustate_own_list_ty * ustate_own_list_clone(ustate_own_list_ty *from) { return ustate_own_list_copy(from); } #ifdef DEBUG void ustate_own_list_trace_real(const char *name, const ustate_own_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) { ustate_own_ty * mp = value->list[j]; ustate_own_trace_real("", mp); } trace_printf("]"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG meta_type ustate_own_list_type = { "ustate_own_list", ustate_own_list_alloc, ustate_own_list_free, 0, // enum_parse ustate_own_list_parse, 0, // struct_parse 0, // fuzzy ustate_own_list_convert, generic_struct_is_set, }; void ustate_write(const output::pointer &fp, ustate_ty *this_thing) { if (!this_thing) return; trace(("ustate_write(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((ustate_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((ustate_ty *)this_thing)->reference_count)); ustate_own_list_write(fp, "own", this_thing->own); trace(("}\n")); } void ustate_write_xml(const output::pointer &fp, ustate_ty *this_thing) { if (!this_thing) return; trace(("ustate_write_xml(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((ustate_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((ustate_ty *)this_thing)->reference_count)); fp->fputs("\n"); ustate_own_list_write_xml(fp, "own", this_thing->own); fp->fputs("\n"); } static void * ustate_alloc(void) { ustate_ty *this_thing; trace(("ustate_alloc()\n{\n")); this_thing = (ustate_ty *)mem_alloc(sizeof(ustate_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->own = (ustate_own_list_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } ustate_ty * ustate_copy(ustate_ty *this_thing) { trace(("ustate_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } ustate_ty * ustate_clone(ustate_ty *this_thing) { if (!this_thing) return 0; trace(("ustate_clone()\n{\n")); ustate_ty *result = (ustate_ty *)ustate_alloc(); result->own = ustate_own_list_clone(this_thing->own); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void ustate_trace_real(const char *name, const ustate_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); ustate_own_list_trace_real("own", value->own); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void ustate_free(void *that) { ustate_ty *this_thing; this_thing = (ustate_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("ustate_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } ustate_own_list_free(this_thing->own); mem_free(this_thing); trace(("}\n")); } static type_table_ty ustate_table[] = { { "own", offsetof(ustate_ty, own), &ustate_own_list_type, ustate_own_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * ustate_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("ustate_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((ustate_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, ustate_table, SIZEOF(ustate_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * ustate_fuzzy(string_ty *name) { string_ty *result; trace(("ustate_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, ustate_table, SIZEOF(ustate_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer ustate_convert(void *this_thing) { trace(("ustate_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((ustate_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, ustate_table, SIZEOF(ustate_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type ustate_type = { "ustate", ustate_alloc, ustate_free, 0, // enum_parse 0, // list_parse ustate_parse, ustate_fuzzy, ustate_convert, generic_struct_is_set, }; ustate_ty * ustate_read_file(const nstring &filename) { return ustate_read_file(filename.get_ref()); } ustate_ty * ustate_read_file(string_ty *filename) { ustate_ty *result; trace(("ustate_read_file(filename = \"%s\")\n{\n", (filename ? filename->str_text : ""))); os_become_must_be_active(); result = (ustate_ty *)parse(filename, &ustate_type); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } void ustate_write_file(const nstring &filename, ustate_ty *value, bool comp) { ustate_write_file(filename.get_ref(), value, comp); } void ustate_write_file(string_ty *filename, ustate_ty *value, int needs_compression) { trace(("ustate_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); ustate_write(fp, value); type_enum_option_clear(); trace(("}\n")); } void ustate__rpt_init(void) { trace(("ustate__rpt_init()\n{\n")); trace(("}\n")); }