From 282f15f04af1c73852a3e620aafc89b5226546eb Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Tue, 1 Mar 2016 13:20:15 -0500 Subject: [PATCH] documentor; ecere/eCON: Avoiding more residual changes - Created a new class eCONParser for eCON - Fixed setting position for parameters - Various tweaks --- documentor/src/Documentor.ec | 207 ++++++++++++++++++++++++++----------------- ecere/src/sys/JSON.ec | 31 ++++--- 2 files changed, 142 insertions(+), 96 deletions(-) diff --git a/documentor/src/Documentor.ec b/documentor/src/Documentor.ec index b5b72d4..daa21ea 100644 --- a/documentor/src/Documentor.ec +++ b/documentor/src/Documentor.ec @@ -594,7 +594,6 @@ static void FigureFilePath(char * path, Module module, DocumentationType type, v static char * ReadDoc(Module module, DocumentationType type, void * object, DocumentationItem item, void * data) { String contents = null; - bool docRetrieved = false; NamespaceDoc nsDoc = null; ClassDoc clDoc = null; FunctionDoc fnDoc = null; @@ -617,16 +616,14 @@ static char * ReadDoc(Module module, DocumentationType type, void * object, Docu if(eClass_IsDerived(doc._class, class(ClassDoc))) { clDoc = (ClassDoc)doc; - docRetrieved = true; } else if(eClass_IsDerived(doc._class, class(NamespaceDoc))) { nsDoc = (NamespaceDoc)doc; - docRetrieved = true; } } - if(docRetrieved) + if(clDoc || nsDoc) { ItemDoc itDoc = null; if(type == functionDoc) @@ -743,9 +740,8 @@ ItemDoc getDoc(char * filePath, Module module, DocumentationType type, void * ob File f = FileOpen(filePath, read); if(f) { - JSONParser parser { f = f, eCON = true }; - JSONResult jsonResult; - jsonResult = parser.GetObject(cl ? class(ClassDoc) : class(NamespaceDoc), &doc); + eCONParser parser { f = f }; + JSONResult jsonResult = parser.GetObject(cl ? class(ClassDoc) : class(NamespaceDoc), &doc); delete parser; delete f; @@ -2728,7 +2724,6 @@ class HelpView : HTMLView DocumentationType type; DocumentationItem item; ItemDoc doc; - bool docRetrieved = false; NamespaceDoc nsDoc = null; ClassDoc clDoc = null; FunctionDoc fnDoc = null; @@ -2803,37 +2798,33 @@ class HelpView : HTMLView if(eClass_IsDerived(doc._class, class(ClassDoc))) { clDoc = (ClassDoc)doc; - docRetrieved = true; } else if(eClass_IsDerived(doc._class, class(NamespaceDoc))) { nsDoc = (NamespaceDoc)doc; - docRetrieved = true; } } - if(docRetrieved) + if(clDoc || nsDoc) { if(type == functionDoc) { const char * name = RSearchString(function.name, "::", strlen(function.name), true, false); if(name) name += 2; else name = function.name; - if(!nsDoc.functions && !empty) nsDoc.functions = { }; - fnDoc = nsDoc.functions[name]; - if(!fnDoc && !empty) + fnDoc = nsDoc.functions ? nsDoc.functions[name] : null; + if(!empty && !fnDoc) { - fnDoc = { }; - nsDoc.functions[name] = fnDoc; + if(!nsDoc.functions) nsDoc.functions = { }; + nsDoc.functions[name] = fnDoc = { }; } } else if(type == methodDoc) { - if(!clDoc.methods && !empty) clDoc.methods = { }; - mdDoc = clDoc.methods[method.name]; - if(!mdDoc && !empty) + mdDoc = clDoc.methods ? clDoc.methods[method.name] : null; + if(!empty && !mdDoc) { - mdDoc = { }; - clDoc.methods[method.name] = mdDoc; + if(!clDoc.methods && !empty) clDoc.methods = { }; + clDoc.methods[method.name] = mdDoc = { }; } } @@ -2873,28 +2864,44 @@ class HelpView : HTMLView break; case enumerationValue: { - ValueDoc itDoc; - if(!clDoc.values) clDoc.values = { }; - itDoc = clDoc.values[((NamedLink)data).name]; - if(!itDoc) + ValueDoc itDoc = clDoc.values ? clDoc.values[((NamedLink)data).name] : null; + if(!empty || itDoc) { - itDoc = { }; - clDoc.values[((NamedLink)data).name] = itDoc; + if(!empty && !itDoc) + { + if(!clDoc.values) clDoc.values = { }; + clDoc.values[((NamedLink)data).name] = itDoc = { }; + } + itDoc.description = contents; contents = null; + if(itDoc.isEmpty) + { + MapIterator it { map = clDoc.values }; + if(it.Index(((NamedLink)data).name, false)) + it.Remove(); + delete itDoc; + } } - itDoc.description = contents; contents = null; break; } case definition: { - DefineDoc itDoc; - if(!nsDoc.defines) nsDoc.defines = { }; - itDoc = nsDoc.defines[((Definition)data).name]; - if(!itDoc) + DefineDoc itDoc = nsDoc.defines ? nsDoc.defines[((Definition)data).name] : null; + if(!empty || itDoc) { - itDoc = { }; - nsDoc.defines[((Definition)data).name] = itDoc; + if(!empty && !itDoc) + { + if(!nsDoc.defines) nsDoc.defines = { }; + nsDoc.defines[((Definition)data).name] = itDoc = { }; + } + itDoc.description = contents; contents = null; + if(itDoc.isEmpty) + { + MapIterator it { map = nsDoc.defines }; + if(it.Index(((Definition)data).name, false)) + it.Remove(); + delete itDoc; + } } - itDoc.description = contents; contents = null; break; } case conversion: @@ -2902,70 +2909,95 @@ class HelpView : HTMLView ConversionDoc itDoc; const char * name = RSearchString(((Property)data).name, "::", strlen(((Property)data).name), true, false); if(name) name += 2; else name = ((Property)data).name; - if(!clDoc.conversions) clDoc.conversions = { }; - itDoc = clDoc.conversions[name]; - if(!itDoc) + itDoc = clDoc.conversions ? clDoc.conversions[name] : null; + if(!empty || itDoc) { - itDoc = { }; - clDoc.conversions[name] = itDoc; + if(!empty && !itDoc) + { + if(!clDoc.conversions) clDoc.conversions = { }; + clDoc.conversions[name] = itDoc = { }; + } + itDoc.description = contents; contents = null; + if(itDoc.isEmpty) + { + MapIterator it { map = clDoc.conversions }; + if(it.Index(name, false)) + it.Remove(); + delete itDoc; + } } - itDoc.description = contents; contents = null; break; } case memberDescription: { - FieldDoc itDoc; - if(!clDoc.fields) clDoc.fields = { }; - itDoc = clDoc.fields[((DataMember)data).name]; - if(!itDoc) + FieldDoc itDoc = clDoc.fields ? clDoc.fields[((DataMember)data).name] : null; + if(!empty || itDoc) { - itDoc = { }; - clDoc.fields[((DataMember)data).name] = itDoc; + if(!empty && !itDoc) + { + if(!clDoc.fields) clDoc.fields = { }; + clDoc.fields[((DataMember)data).name] = itDoc = { }; + } + itDoc.description = contents; contents = null; + if(itDoc.isEmpty) + { + MapIterator it { map = clDoc.fields }; + if(it.Index(((DataMember)data).name, false)) + it.Remove(); + delete itDoc; + } } - itDoc.description = contents; contents = null; break; } case propertyDescription: { - PropertyDoc itDoc; - if(!clDoc.properties) clDoc.properties = { }; - itDoc = clDoc.properties[((Property)data).name]; - if(!itDoc) + PropertyDoc itDoc = clDoc.properties ? clDoc.properties[((Property)data).name] : null; + if(!empty || itDoc) { - itDoc = { }; - clDoc.properties[((Property)data).name] = itDoc; + if(!empty && !itDoc) + { + if(!clDoc.properties) clDoc.properties = { }; + clDoc.properties[((Property)data).name] = itDoc = { }; + } + itDoc.description = contents, contents = null; + if(itDoc.isEmpty) + { + MapIterator it { map = clDoc.properties }; + if(it.Index(((Property)data).name, false)) + it.Remove(); + delete itDoc; + } } - itDoc.description = contents; contents = null; break; } case parameter: { - ParameterDoc itDoc; - char * name; - Type prev; - for(prev = data; prev; prev = prev.prev); - name = ((Type)data).name; - if(type == functionDoc) + if(type == functionDoc || type == methodDoc) { - if(!fnDoc.parameters) fnDoc.parameters = { }; - itDoc = fnDoc.parameters[name]; - if(!itDoc) + Map * parameters = (type == functionDoc) ? &fnDoc.parameters : &mdDoc.parameters; + char * name = ((Type)data).name; + ParameterDoc itDoc = *parameters ? (*parameters)[name] : null; + int position = 0; + Type prev = data; + while(prev) position++, prev = prev.prev; + + if(!empty || itDoc) { - itDoc = { }; - fnDoc.parameters[name] = itDoc; - } - itDoc.description = contents; contents = null; - } - else if(type == methodDoc) - { - if(!mdDoc.parameters) mdDoc.parameters = { }; - itDoc = mdDoc.parameters[name]; - if(!itDoc) - { - itDoc = { }; - mdDoc.parameters[name] = itDoc; + if(!empty && !itDoc) + { + if(!*parameters) *parameters = { }; + (*parameters)[name] = itDoc = { }; + } + itDoc.description = contents; contents = null; + itDoc.position = position; + if(itDoc.isEmpty) + { + MapIterator it { map = *parameters }; + if(it.Index(((Type)data).name, false)) + it.Remove(); + delete itDoc; + } } - itDoc.description = contents; contents = null; } break; } @@ -2979,22 +3011,31 @@ class HelpView : HTMLView const char * name = RSearchString(function.name, "::", strlen(function.name), true, false); if(name) name += 2; else name = function.name; if(it.Index(name, false)) - { it.Remove(); - } delete fnDoc; } else if(type == methodDoc && mdDoc && mdDoc.isEmpty) { MapIterator it { map = clDoc.methods }; if(it.Index(method.name, false)) - { it.Remove(); - } delete mdDoc; } + if(nsDoc) + { + if(nsDoc.functions && !nsDoc.functions.count) delete nsDoc.functions; + if(nsDoc.defines && !nsDoc.defines.count) delete nsDoc.defines; + } + if(clDoc) + { + if(clDoc && clDoc.conversions && !clDoc.conversions.count) delete clDoc.conversions; + if(clDoc && clDoc.properties && !clDoc.properties.count) delete clDoc.properties; + if(clDoc && clDoc.fields && !clDoc.fields.count) delete clDoc.fields; + if(clDoc && clDoc.methods && !clDoc.methods.count) delete clDoc.methods; + if(clDoc && clDoc.values && !clDoc.values.count) delete clDoc.values; + } - if(docRetrieved) + if(clDoc || nsDoc) { char dirPath[MAX_LOCATION]; StripLastDirectory(docPath, dirPath); diff --git a/ecere/src/sys/JSON.ec b/ecere/src/sys/JSON.ec index fa327d6..4fd0acd 100644 --- a/ecere/src/sys/JSON.ec +++ b/ecere/src/sys/JSON.ec @@ -30,11 +30,16 @@ public enum SetBool : uint }; +public class eCONParser : JSONParser +{ + eCON = true; +} + public class JSONParser { public: File f; - char pch; +private: char ch; bool eCON; @@ -210,10 +215,10 @@ public: if(type.type != structClass) value.p = 0; } - else if(isSubclass(string, type)) + else if(isSubclass(type, string)) { void * object = value.p; - Class subtype = eSystem_SuperFindClass(string, type.module); + Class subtype = superFindClass(string, type.module); SkipEmpty(); result = GetObject(subtype, &object); if(result) @@ -708,10 +713,10 @@ public: offset = member._class.offset + member.offset; } else if(prop) - type = eSystem_SuperFindClass(prop.dataTypeString, objectType.module); + type = superFindClass(prop.dataTypeString, objectType.module); else if(member) { - type = eSystem_SuperFindClass(member.dataTypeString, objectType.module); + type = superFindClass(member.dataTypeString, objectType.module); offset = member._class.offset + member.offset; } } @@ -744,14 +749,14 @@ public: member = eClass_FindDataMember(objectType, string, objectType.module, null, null); if(member) { - type = eSystem_SuperFindClass(member.dataTypeString, objectType.module); + type = superFindClass(member.dataTypeString, objectType.module); offset = member._class.offset + member.offset; } else if(!member) { prop = eClass_FindProperty(objectType, string, objectType.module); if(prop) - type = eSystem_SuperFindClass(prop.dataTypeString, objectType.module); + type = superFindClass(prop.dataTypeString, objectType.module); else PrintLn("Warning: member ", string, " not found in class ", (String)objectType.name); } @@ -1427,7 +1432,7 @@ static bool WriteValue(File f, Class type, DataValue value, int indent, bool eCO else if(type.type == bitClass) { Class dataType; - dataType = eSystem_SuperFindClass(type.dataTypeString, type.module); + dataType = superFindClass(type.dataTypeString, type.module); WriteNumber(f, dataType, value, indent, eCON); } else if(type.type == systemClass || type.type == unitClass) @@ -1539,7 +1544,7 @@ static bool WriteONObject(File f, Class objectType, void * object, int indent, b type = mapDataClass; } else - type = eSystem_SuperFindClass(prop.dataTypeString, _class.module); + type = superFindClass(prop.dataTypeString, _class.module); if(!type) PrintLn("warning: Unresolved data type ", (String)prop.dataTypeString); @@ -1618,7 +1623,7 @@ static bool WriteONObject(File f, Class objectType, void * object, int indent, b DataMember member = (DataMember)prop; DataValue value { }; uint offset; - Class type = eSystem_SuperFindClass(member.dataTypeString, _class.module); + Class type = superFindClass(member.dataTypeString, _class.module); offset = member._class.offset + member.offset; if(type) @@ -1703,7 +1708,7 @@ static bool WriteONObject(File f, Class objectType, void * object, int indent, b return true; } -static Class eSystem_SuperFindClass(const String name, Module alternativeModule) +static Class superFindClass(const String name, Module alternativeModule) { Class _class = eSystem_FindClass(__thisModule, name); if(!_class && alternativeModule) @@ -1713,9 +1718,9 @@ static Class eSystem_SuperFindClass(const String name, Module alternativeModule) return _class; } -static bool isSubclass(const String name, Class type) +static bool isSubclass(Class type, const String name) { - Class _class = eSystem_SuperFindClass(name, type.module); + Class _class = superFindClass(name, type.module); if(eClass_IsDerived(_class, type)) return true; return false; -- 1.8.3.1