Sync with 5.1.0
[deliverable/titan.core.git] / compiler2 / Type_codegen.cc
index cea911281e8eb7c7fa0ebaa2155d362ea2f12b7a..6e9679c59e1533de899ac8ec038a60e33daff7fb 100644 (file)
@@ -2688,6 +2688,9 @@ void Type::generate_json_schema(JSON_Tokenizer& json, bool embedded, bool as_val
       // use the JSON string type and add a pattern to only allow bits or hex digits
       json.put_next_token(JSON_TOKEN_NAME, "type");
       json.put_next_token(JSON_TOKEN_STRING, "\"string\"");
+      json.put_next_token(JSON_TOKEN_NAME, "subType");
+      json.put_next_token(JSON_TOKEN_STRING, (last->typetype == T_OSTR) ? "\"octetstring\"" :
+        ((last->typetype == T_HSTR) ? "\"hexstring\"" : "\"bitstring\""));
       json.put_next_token(JSON_TOKEN_NAME, "pattern");
       json.put_next_token(JSON_TOKEN_STRING, 
         (last->typetype == T_OSTR) ? "\"^([0-9A-Fa-f][0-9A-Fa-f])*$\"" :
@@ -2742,6 +2745,15 @@ void Type::generate_json_schema(JSON_Tokenizer& json, bool embedded, bool as_val
         Free(enum_str);
       }
       json.put_next_token(JSON_TOKEN_ARRAY_END);
+      // list the numeric values for the enumerated items
+      json.put_next_token(JSON_TOKEN_NAME, "numericValues");
+      json.put_next_token(JSON_TOKEN_ARRAY_START);
+      for (size_t i = 0; i < u.enums.eis->get_nof_eis(); ++i) {
+        char* num_val_str = mprintf("%lli", get_ei_byIndex(i)->get_value()->get_val_Int()->get_val());
+        json.put_next_token(JSON_TOKEN_NUMBER, num_val_str);
+        Free(num_val_str);
+      }
+      json.put_next_token(JSON_TOKEN_ARRAY_END);
       break;
     case T_SEQOF:
     case T_SETOF:
This page took 0.023291 seconds and 5 git commands to generate.