ecere/JSON;eCON: Splitting WriteJSONObject / WriteECONObject
authorJerome St-Louis <jerome@ecere.com>
Wed, 24 Feb 2016 20:30:08 +0000 (15:30 -0500)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 22:23:17 +0000 (18:23 -0400)
- Avoids changing WriteJSONObject() API and makes more sense

documentor/src/Documentor.ec
documentor/tools/ear-to-econ-ecdoc.ec
ecere/src/sys/JSON.ec
ecere/src/sys/JSONGlobalSettings.ec
ide/src/project/Project.ec

index f9dd351..0b7bb5e 100644 (file)
@@ -3008,9 +3008,9 @@ class HelpView : HTMLView
                if(f)
                {
                   if(cl)
-                     WriteJSONObject(f, class(ClassDoc), clDoc, 0, true);
+                     WriteECONObject(f, class(ClassDoc), clDoc, 0);
                   else
-                     WriteJSONObject(f, class(NamespaceDoc), nsDoc, 0, true);
+                     WriteECONObject(f, class(NamespaceDoc), nsDoc, 0);
                   delete f;
                }
                else
index 8921ea2..80d0eb5 100644 (file)
@@ -415,7 +415,7 @@ static void writeNamespaceDocFile(NamespaceDoc namespaceDoc, const char * path)
       f = FileOpen(filePath, write);
       if(f)
       {
-         WriteJSONObject(f, class(NamespaceDoc), namespaceDoc, 0, true);
+         WriteECONObject(f, class(NamespaceDoc), namespaceDoc, 0);
          delete f;
       }
       else
@@ -440,7 +440,7 @@ static void writeClassDocFile(ClassDoc classDoc, const char * path)
       f = FileOpen(filePath, write);
       if(f)
       {
-         WriteJSONObject(f, class(ClassDoc), classDoc, 0, true);
+         WriteECONObject(f, class(ClassDoc), classDoc, 0);
          delete f;
       }
       else
index abb949a..8310d1e 100644 (file)
@@ -1115,7 +1115,7 @@ public:
    }
 }
 
-bool WriteMap(File f, Class type, Map map, int indent, bool eCON)
+static bool WriteMap(File f, Class type, Map map, int indent, bool eCON)
 {
    if(map)
    {
@@ -1134,7 +1134,7 @@ bool WriteMap(File f, Class type, Map map, int indent, bool eCON)
          else
             isFirst = false;
          for(i = 0; i<indent; i++) f.Puts("   ");
-         _WriteJSONObject(f, mapNodeClass, n, indent, eCON, eCON ? true : false);
+         WriteONObject(f, mapNodeClass, n, indent, eCON, eCON ? true : false);
       }
       f.Puts("\n");
       indent--;
@@ -1146,7 +1146,7 @@ bool WriteMap(File f, Class type, Map map, int indent, bool eCON)
    return true;
 }
 
-bool WriteArray(File f, Class type, Container array, int indent, bool eCON)
+static bool WriteArray(File f, Class type, Container array, int indent, bool eCON)
 {
    if(array)
    {
@@ -1220,7 +1220,7 @@ bool WriteArray(File f, Class type, Container array, int indent, bool eCON)
    return true;
 }
 
-bool WriteNumber(File f, Class type, DataValue value, int indent, bool eCON)
+static bool WriteNumber(File f, Class type, DataValue value, int indent, bool eCON)
 {
    char buffer[1024];
    bool needClass = eCON;
@@ -1282,7 +1282,7 @@ public bool WriteColorAlpha(File f, Class type, DataValue value, int indent, boo
    return true;
 }
 
-bool WriteValue(File f, Class type, DataValue value, int indent, bool eCON)
+static bool WriteValue(File f, Class type, DataValue value, int indent, bool eCON)
 {
    if(!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *"))
    {
@@ -1420,7 +1420,7 @@ bool WriteValue(File f, Class type, DataValue value, int indent, bool eCON)
    }
    else if(type.type == normalClass || type.type == noHeadClass || type.type == structClass)
    {
-      _WriteJSONObject(f, type, value.p, indent, eCON, false);
+      WriteONObject(f, type, value.p, indent, eCON, false);
    }
    else if(eClass_IsDerived(type, class(ColorAlpha)))
    {
@@ -1439,18 +1439,29 @@ bool WriteValue(File f, Class type, DataValue value, int indent, bool eCON)
    return true;
 }
 
-public bool WriteJSONObject(File f, Class objectType, void * object, int indent, bool eCON)
+public bool WriteJSONObject(File f, Class objectType, void * object, int indent)
 {
    bool result = false;
    if(object)
    {
-      result = _WriteJSONObject(f, objectType, object, indent, eCON, false);
+      result = WriteONObject(f, objectType, object, indent, false, false);
       f.Puts("\n");
    }
    return result;
 }
 
-static bool _WriteJSONObject(File f, Class objectType, void * object, int indent, bool eCON, bool omitDefaultIdentifier)
+public bool WriteECONObject(File f, Class objectType, void * object, int indent)
+{
+   bool result = false;
+   if(object)
+   {
+      result = WriteONObject(f, objectType, object, indent, true, false);
+      f.Puts("\n");
+   }
+   return result;
+}
+
+static bool WriteONObject(File f, Class objectType, void * object, int indent, bool eCON, bool omitDefaultIdentifier)
 {
    if(object)
    {
@@ -1694,7 +1705,7 @@ static bool _WriteJSONObject(File f, Class objectType, void * object, int indent
    return true;
 }
 
-Class eSystem_SuperFindClass(const String name, Module alternativeModule)
+static Class eSystem_SuperFindClass(const String name, Module alternativeModule)
 {
    Class _class = eSystem_FindClass(__thisModule, name);
    if(!_class && alternativeModule)
@@ -1704,7 +1715,7 @@ Class eSystem_SuperFindClass(const String name, Module alternativeModule)
    return _class;
 }
 
-bool isSubclass(const String name, Class type)
+static bool isSubclass(const String name, Class type)
 {
    Class _class = eSystem_SuperFindClass(name, type.module);
    if(eClass_IsDerived(_class, type))
index 37a6528..89984ae 100644 (file)
@@ -42,7 +42,7 @@ public:
    SettingsIOResult ::Save(File f, GlobalSettings globalSettings)
    {
       SettingsIOResult result = error;
-      if(globalSettings && WriteJSONObject(f, globalSettings.data._class, globalSettings.data, 0, false))
+      if(globalSettings && WriteJSONObject(f, globalSettings.data._class, globalSettings.data, 0))
          result = success;
       return result;
    }
index 2b2d3ae..92bd356 100644 (file)
@@ -1230,7 +1230,7 @@ private:
          files.Remove(resNode);
          version = 0.2f;
 
-         WriteJSONObject(f, class(Project), this, 0, false);
+         WriteJSONObject(f, class(Project), this, 0);
 
          files.Add(resNode);