+
+void write_constant(FILE*fi, constant_t*value, char*id, char*prefix)
+{
+ if(NS_TYPE(value->type)) {
+ fprintf(fi, "%s", prefix);
+ fprintf(fi, "static namespace_t %s_constant_ns = {0x%02x, \"%s\"};\n", id, value->ns->access, value->ns->name);
+ } else if(value->type == CONSTANT_STRING) {
+ fprintf(fi, "%s", prefix);
+ fprintf(fi, "static string_t %s_constant_s = {\"%s\", %d};\n", id, value->s->str, value->s->len);
+ }
+ fprintf(fi, "%s", prefix);
+ fprintf(fi, "static constant_t %s_constant = ", id);
+ fprintf(fi, "{type: %d", value->type);
+ if(NS_TYPE(value->type)) {
+ fprintf(fi, ", &%s_constant_ns", id);
+ } else if(value->type == CONSTANT_INT) {
+ fprintf(fi, ",i: %d,", value->type);
+ } else if(value->type == CONSTANT_UINT) {
+ fprintf(fi, ",u: %u", value->u);
+ } else if(value->type == CONSTANT_FLOAT) {
+ if(!isnan(value->f) && !isinf(value->f))
+ fprintf(fi, ", %f", value->f);
+ } else if(value->type == CONSTANT_STRING) {
+ fprintf(fi, ", &%s_constant_s", id);
+ }
+ fprintf(fi, "};\n");
+}
+