ecere/sys/JSON: Fixed broken TimeStamp text serialization
authorJerome St-Louis <jerome@ecere.com>
Wed, 18 Mar 2015 01:32:19 +0000 (21:32 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:19:36 +0000 (20:19 -0400)
- Fixes issue introduced by 09a864da36eed0912aab7ebcb21e19c6b7a4b9a5

ecere/src/sys/JSON.ec
ide/src/debugger/Debugger.ec

index ec1d3e5..e9f9f1b 100644 (file)
@@ -61,7 +61,7 @@ public:
             {
                value.p = string;
             }
-            else if(type && (type.type == enumClass /*|| type.type == unitClass*/))
+            else if(type && (type.type == enumClass || type.type == unitClass))
             {
                if(((bool (*)(void *, void *, const char *))(void *)type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(type, &value.i, string))
                   result = success;
@@ -843,6 +843,7 @@ bool WriteNumber(File f, Class type, DataValue value, int indent)
 {
    char buffer[1024];
    bool needClass = false;
+   bool quote;
    buffer[0] = 0;
    if(type == class(double) || !strcmp(type.dataTypeString, "double"))
       ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.d, buffer, 0, &needClass);
@@ -864,7 +865,11 @@ bool WriteNumber(File f, Class type, DataValue value, int indent)
       ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.c, buffer, null, &needClass);
    else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
       ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
+
+   quote = (type.type == unitClass && ((buffer[0] != '.' && !isdigit(buffer[0])) || strchr(buffer, ' ')));
+   if(quote) f.Puts("\"");
    f.Puts(buffer);
+   if(quote) f.Puts("\"");
    return true;
 }
 
@@ -934,7 +939,7 @@ bool WriteValue(File f, Class type, DataValue value, int indent)
       else
          f.Puts("unset");
    }
-   else if(type.type == enumClass) // || type.type == unitClass)
+   else if(type.type == enumClass)
    {
       f.Puts("\"");
       WriteNumber(f, type, value, indent);
index d8f352e..6d19835 100644 (file)
@@ -2912,7 +2912,7 @@ class Debugger
                   {
                      Expression memberExp = exp.member.exp;
                      Identifier memberID = exp.member.member;
-                     Type type = memberExp.expType;
+                     Type type = memberExp ? memberExp.expType : null;
                      Class _class = (type && memberID) ? (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null) : null;
                      if(_class && memberID && memberID.string)
                         snprintf(watchmsg, sizeof(watchmsg), $"Missing property evaluation for \"%s\" in class \"%s\"", memberID.string, _class.name);