8 __attribute__((unused)) static void UnusedFunction()
11 a.OnGetDataFromString(null);
12 a.OnGetString(null, 0, 0);
15 extern int __ecereVMethodID_class_OnGetDataFromString;
16 extern int __ecereVMethodID_class_OnGetString;
17 extern int __ecereVMethodID_class_OnFree;
20 public enum JSONResult { syntaxError, success, typeMismatch, noItem };
22 public enum SetBool : uint
26 /*public property bool // NOT WORKING!
28 set { return value ? true : false; }
29 get { return (this == true); }
34 public class JSONParser
42 while(!f.Eof() && (!ch || ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '/'))
48 JSONResult GetValue(Class type, DataValue value)
50 JSONResult result = syntaxError;
56 result = GetString(&string);
60 if(type && (!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *")))
64 else if(type && (type.type == enumClass /*|| type.type == unitClass*/))
66 if(((bool (*)(void *, void *, const char *))(void *)type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(type, &value.i, string))
69 result = typeMismatch;
72 else if(type && (prop = eClass_FindProperty(type, "String", type.module)))
74 // TOFIX: Add more conversion property support... Expecting void * compatible here
75 value.p = ((void *(*)())(void *)prop.Set)(string);
79 else if(type && (type.type == structClass))
81 if(((bool (*)(void *, void *, const char *))(void *)type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(type, value.p, string))
84 result = typeMismatch;
90 result = typeMismatch;
97 if(type && eClass_IsDerived(type, class(Map)))
99 result = GetMap(type, (Map *)&array);
102 result = GetArray(type, &array);
104 if(result == success && type && eClass_IsDerived(type, class(Container)))
113 if(result != success)
114 result = typeMismatch;
117 else if(ch == '-' || isdigit(ch))
119 result = GetNumber(type, value);
123 void * object = value.p;
124 result = GetObject(type, &object);
127 if(type && type.type == structClass);
128 else if(type && (type.type == normalClass || type.type == noHeadClass || type.type == bitClass))
134 result = typeMismatch;
136 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, object);
144 while(c < sizeof(buffer)-1 && isalpha(ch))
147 if(!f.Getc(&ch)) break;
154 if(!strcmp(type.name, "bool"))
156 if(!strcmpi(buffer, "false")) value.i = 0;
157 else if(!strcmpi(buffer, "true")) value.i = 1;
159 result = typeMismatch;
161 else if(!strcmp(type.name, "SetBool"))
163 if(!strcmpi(buffer, "false")) value.i = SetBool::false;
164 else if(!strcmpi(buffer, "true")) value.i = SetBool::true;
166 result = typeMismatch;
168 else if(!strcmpi(buffer, "null"))
173 result = typeMismatch;
176 result = typeMismatch;
178 else if(ch == '}' || ch == ']')
183 JSONResult GetArray(Class type, Container * array)
185 JSONResult result = syntaxError;
190 *array = eInstance_New(type);
195 Class arrayType = null;
196 JSONResult itemResult;
198 if(eClass_IsDerived(type, class(Container)))
200 arrayType = type.templateArgs[0].dataTypeClass;
203 if(arrayType && arrayType.type == structClass)
204 value.p = new byte[arrayType.structSize];
205 itemResult = GetValue(arrayType, value);
206 if(itemResult == success)
208 // TODO: Verify the matching between template type and uint64
210 if(arrayType.type == structClass)
212 t = (uint64)(uintptr)value.p;
214 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
216 t = value.ui64; //*(uint64 *)&value.d;
218 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
220 t = value.ui; //f*(uint *)&value.f;
222 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
223 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
227 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
228 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
232 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
233 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
234 !strcmp(arrayType.dataTypeString, "int16"))
238 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
239 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
245 t = (uint64)(uintptr)value.p;
247 ((void *(*)(void *, uint64))(void *)array->Add)(*array, t);
249 if(arrayType && arrayType.type == structClass)
254 if(itemResult == typeMismatch)
257 PrintLn("Warning: Incompatible value for array value, expected ", (String)arrayType.name);
259 else if(itemResult == noItem)
265 if(result != syntaxError)
267 if(ch != ']' && ch != ',')
277 result = syntaxError;
285 JSONResult GetMap(Class type, Map * map)
287 JSONResult result = syntaxError;
292 Class mapNodeType = type.templateArgs[0].dataTypeClass;
293 Class keyType = mapNodeType.templateArgs[0].dataTypeClass;
294 Property keyProp = null;
295 if(keyType && !strcmp(keyType.dataTypeString, "char *"))
296 keyProp = eClass_FindProperty(mapNodeType, "key", mapNodeType.module);
298 *map = eInstance_New(type);
305 JSONResult itemResult;
307 itemResult = GetValue(mapNodeType, value);
308 if(itemResult == success)
310 String s = keyProp ? ((void * (*)(void *))(void *)keyProp.Get)(value.p) : null;
311 ((void *(*)(void *, uint64))(void *)map->Add)(*map, (uint64)(uintptr)value.p);
312 // Must free String keys here
317 if(itemResult == typeMismatch)
320 PrintLn("Warning: Incompatible value for array value, expected ", (String)mapNodeType.name);
322 else if(itemResult == noItem)
328 if(result != syntaxError)
330 if(ch != ']' && ch != ',')
340 result = syntaxError;
348 JSONResult GetString(String * string)
350 JSONResult result = syntaxError;
351 Array<char> buffer { minAllocSize = 256 };
352 bool escaped = false;
360 if(ch == '\\' && !escaped)
366 if(ch == 'b') ch = '\b';
367 else if(ch == 'f') ch = '\f';
368 else if(ch == 'n') ch = '\n';
369 else if(ch == 'r') ch = '\r';
370 else if(ch == 't') ch = '\t';
387 if(buffer.minAllocSize < buffer.count)
388 buffer.minAllocSize *= 2;
392 *string = CopyString(buffer.array);
396 if(ch != ',' && ch != '}')
401 public JSONResult GetObject(Class objectType, void ** object)
403 JSONResult result = syntaxError;
404 if(!objectType || objectType.type != structClass)
409 Class mapKeyClass = null, mapDataClass = null;
411 if(objectType && objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
413 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
414 mapDataClass = objectType.templateArgs[2].dataTypeClass;
418 if(objectType && (objectType.type == noHeadClass || objectType.type == normalClass))
420 *object = eInstance_New(objectType);
422 else if(objectType && objectType.type != structClass)
424 *object = eSystem_New(objectType.typeSize);
431 if(GetString(&string))
433 DataMember member = null;
434 Property prop = null;
441 string[0] = (char)tolower(string[0]);
442 if(mapKeyClass && !strcmp(string, "key"))
444 prop = eClass_FindProperty(objectType, "key", objectType.module);
448 else if(mapDataClass && !strcmp(string, "value"))
450 prop = eClass_FindProperty(objectType, "value", objectType.module);
455 member = eClass_FindDataMember(objectType, string, objectType.module, null, null);
458 type = eSystem_FindClass(__thisModule, member.dataTypeString);
460 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
462 offset = member._class.offset + member.offset;
466 prop = eClass_FindProperty(objectType, string, objectType.module);
469 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
471 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
474 PrintLn("Warning: member ", string, " not found in class ", (String)objectType.name);
478 // Find Member in Object Class
482 if(type && type.type == structClass)
484 value.p = (byte *)*object + offset;
490 JSONResult itemResult = GetValue(type, value);
491 if(itemResult != syntaxError)
497 PrintLn("warning: Unresolved data type ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
499 else if(itemResult == success)
504 // TOFIX: How to swiftly handle classes with base data type?
505 if(type.type == structClass)
507 else if(type.type == normalClass || type.type == noHeadClass)
509 void ** ptr = (void**)((byte *)*object + offset);
510 if(eClass_IsDerived(type, class(Container)) && *ptr)
512 Container container = (Container)*ptr;
518 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
520 *(double *)((byte *)*object + offset) = value.d;
522 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
524 *(float *)((byte *)*object + offset) = value.f;
526 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
527 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
529 *(uint64 *)((byte *)*object + offset) = value.ui64;
531 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
532 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
534 *(int *)((byte *)*object + offset) = value.i;
536 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
537 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
538 !strcmp(type.dataTypeString, "int16"))
540 *(short *)((byte *)*object + offset) = value.s;
542 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
543 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
545 *(char *)((byte *)*object + offset) = value.c;
549 *(void **)((byte *)*object + offset) = value.p;
552 else if(prop && prop.Set)
554 if(!strcmp(type.dataTypeString, "char *"))
556 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
560 // TOFIX: How to swiftly handle classes with base data type?
561 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
563 ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
565 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
567 ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
569 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
570 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
572 ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
574 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
575 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
577 ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
579 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
580 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
581 !strcmp(type.dataTypeString, "int16"))
583 ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
585 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
586 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
588 ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
592 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
598 PrintLn("Warning: Incompatible value for ", member ? (String)member.name : (String)prop.name,
599 ", expected ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
605 result = syntaxError;
608 else if(ch && ch != '}' && ch != ',')
609 result = syntaxError;
620 result = syntaxError;
628 JSONResult GetNumber(Class type, DataValue value)
630 JSONResult result = syntaxError;
633 while(c < sizeof(buffer)-1 && (ch == '-' || ch == '.' || tolower(ch) == 'e' || ch == '+' || isdigit(ch)))
636 if(!f.Getc(&ch)) break;
639 //if(strchr(buffer, '.'))
641 // TOFIX: How to swiftly handle classes with base data type?
642 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
644 value.d = strtod(buffer, null);
647 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
649 value.f = (float)strtod(buffer, null);
652 // TOFIX: int64 looks for class long long?
653 //else if(type == class(int64) || !strcmp(type.dataTypeString, "int64"))
654 else if(!strcmp(type.dataTypeString, "int64"))
656 value.i64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
659 else if(type == class(uint64) || !strcmp(type.dataTypeString, "uint64"))
661 value.ui64 = strtoul(buffer, null, 10); // TOFIX: 64 bit support
664 else if(type == class(uint) || !strcmp(type.dataTypeString, "unsigned int"))
666 value.ui = strtoul(buffer, null, 10); // TOFIX: 64 bit support
671 value.i = strtol(buffer, null, 10);
675 if(result == success && type.type == unitClass)
677 // Convert to reference unit
680 for(prop = type.conversions.first; prop; prop = prop.next)
682 bool refProp = false;
684 if(!strcmp(prop.name, type.base.fullName))
686 else if( (c = eSystem_FindClass(type.module, prop.name) ) )
689 for(p = c.conversions.first; p; p = p.next)
691 if(!strcmp(p.name, type.base.fullName) && !p.Set && !p.Get)
700 if(prop.Set && prop.Get)
702 const String dts = type.base.dataTypeString;
703 if(!strcmp(dts, "double"))
704 value.d = ((double(*)(double))(void *)prop.Get)(value.d);
705 else if(!strcmp(dts, "float"))
706 value.f = ((float(*)(float))(void *)prop.Get)(value.f);
707 else if(!strcmp(dts, "int"))
708 value.i = ((int(*)(int))(void *)prop.Get)(value.i);
709 else if(!strcmp(dts, "int64"))
710 value.i64 = ((int64(*)(int64))(void *)prop.Get)(value.i64);
721 bool WriteMap(File f, Class type, Map map, int indent)
727 MapIterator it { map = map };
728 Class mapNodeClass = map._class.templateArgs[0].dataTypeClass;
734 MapNode n = (MapNode)it.pointer;
739 for(i = 0; i<indent; i++) f.Puts(" ");
740 _WriteJSONObject(f, mapNodeClass, n, indent);
744 for(i = 0; i<indent; i++) f.Puts(" ");
752 bool WriteArray(File f, Class type, Container array, int indent)
758 Iterator it { array };
759 Class arrayType = type.templateArgs[0].dataTypeClass;
766 uint64 t = ((uint64(*)(void *, void *))(void *)array.GetData)(array, it.pointer);
773 // TODO: Verify the matching between template type and uint64
774 if(arrayType.type == structClass)
776 value.p = (void *)(uintptr)t;
778 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
781 //value.d = *(double *)&t;
783 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
786 //value.f = *(float *)&t;
788 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
789 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
793 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
794 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
798 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
799 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
800 !strcmp(arrayType.dataTypeString, "int16"))
804 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
805 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
811 value.p = (void *)(uintptr)t;
813 for(i = 0; i<indent; i++) f.Puts(" ");
814 WriteValue(f, arrayType, value, indent);
818 for(i = 0; i<indent; i++) f.Puts(" ");
826 bool WriteNumber(File f, Class type, DataValue value, int indent)
829 bool needClass = false;
831 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
832 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.d, buffer, 0, &needClass);
833 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
834 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.f, buffer, null, &needClass);
835 else if(!strcmp(type.dataTypeString, "int64"))
836 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i64, buffer, null, &needClass);
837 else if(!strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64") || type.typeSize == sizeof(int64))
838 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui64, buffer, null, &needClass);
839 else if(!strcmp(type.dataTypeString, "int"))
840 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i, buffer, null, &needClass);
841 else if(!strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint") || type.typeSize == sizeof(int))
842 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui, buffer, null, &needClass);
843 else if(!strcmp(type.dataTypeString, "short") || !strcmp(type.dataTypeString, "int16"))
844 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.s, buffer, null, &needClass);
845 else if(!strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") || type.typeSize == sizeof(short int))
846 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.us, buffer, null, &needClass);
847 else if(!strcmp(type.dataTypeString, "char"))
848 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.c, buffer, null, &needClass);
849 else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
850 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
855 bool WriteValue(File f, Class type, DataValue value, int indent)
857 if(!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *"))
864 //if(strchr(value.p, '\"') || strchr(value.p, '\\'))
869 char * string = value.p;
888 else if(b == sizeof(buffer)-2 || !ch)
891 if(ch) buffer[b] = 0;
905 else if(!strcmp(type.name, "bool"))
912 else if(!strcmp(type.name, "SetBool"))
914 if(value.i == SetBool::true)
916 else if(value.i == SetBool::false)
921 else if(type.type == enumClass) // || type.type == unitClass)
924 WriteNumber(f, type, value, indent);
927 else if(eClass_IsDerived(type, class(Map)))
929 WriteMap(f, type, value.p, indent);
931 else if(eClass_IsDerived(type, class(Container)))
933 WriteArray(f, type, value.p, indent);
935 else if(type.type == normalClass || type.type == noHeadClass || type.type == structClass)
937 _WriteJSONObject(f, type, value.p, indent);
939 else if(type.type == bitClass)
942 dataType = eSystem_FindClass(__thisModule, type.dataTypeString);
943 WriteNumber(f, dataType, value, indent);
945 else if(type.type == systemClass || type.type == unitClass)
947 WriteNumber(f, type, value, indent);
952 public bool WriteJSONObject(File f, Class objectType, void * object, int indent)
957 result = _WriteJSONObject(f, objectType, object, indent);
963 static bool _WriteJSONObject(File f, Class objectType, void * object, int indent)
967 const char * string = null;
969 if(objectType._vTbl[__ecereVMethodID_class_OnGetString] != objectType.base._vTbl[__ecereVMethodID_class_OnGetString])
973 string = ((const char *(*)())(void *)objectType._vTbl[__ecereVMethodID_class_OnGetString])(objectType, object, buffer, null, null);
977 // TOCHECK: ProjectNode.ec why do we add quotes in OnGetString there?
978 if(string[0] == '\"')
992 Class mapKeyClass = null, mapDataClass = null;
994 List<Class> bases { };
996 if(objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
998 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
999 mapDataClass = objectType.templateArgs[2].dataTypeClass;
1005 for(baseClass = objectType; baseClass; baseClass = baseClass.base)
1007 if(baseClass.isInstanceClass || !baseClass.base)
1009 bases.Insert(null, baseClass);
1012 for(baseClass : bases)
1014 for(prop = baseClass.membersAndProperties.first; prop; prop = prop.next)
1016 if(prop.memberAccess != publicAccess || (prop.isProperty && (!prop.Set || !prop.Get))) continue;
1019 if(!prop.conversion && (!prop.IsSet || prop.IsSet(object)))
1021 DataValue value { };
1024 if(mapKeyClass && !strcmp(prop.name, "key"))
1026 else if(mapDataClass && !strcmp(prop.name, "value"))
1027 type = mapDataClass;
1029 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
1031 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
1033 PrintLn("warning: Unresolved data type ", (String)prop.dataTypeString);
1036 // TOFIX: How to swiftly handle classes with base data type?
1037 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1039 value.d = ((double (*)(void *))(void *)prop.Get)(object);
1041 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1043 value.f = ((float (*)(void *))(void *)prop.Get)(object);
1045 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1046 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1048 value.ui64 = ((uint64 (*)(void *))(void *)prop.Get)(object);
1050 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1051 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1053 value.i = ((int (*)(void *))(void *)prop.Get)(object);
1055 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1056 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1057 !strcmp(type.dataTypeString, "int16"))
1059 value.s = ((short (*)(void *))(void *)prop.Get)(object);
1061 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1062 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1064 value.c = ((char (*)(void *))(void *)prop.Get)(object);
1066 else if(type.type == structClass)
1068 value.p = new byte[type.structSize];
1069 ((void (*)(void *, void *))(void *)prop.Get)(object, value.p);
1073 value.p = ((void *(*)(void *))(void *)prop.Get)(object);
1076 if(!isFirst) f.Puts(",\n");
1077 for(c = 0; c<indent; c++) f.Puts(" ");
1080 f.Putc((char)toupper(prop.name[0]));
1081 f.Puts(prop.name+1);
1083 WriteValue(f, type, value, indent);
1085 if(type.type == structClass)
1092 DataMember member = (DataMember)prop;
1093 DataValue value { };
1095 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
1097 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
1099 offset = member._class.offset + member.offset;
1103 if(type.type == normalClass || type.type == noHeadClass || type.type == structClass || !strcmp(type.name, "String"))
1105 if(type.type == structClass)
1106 value.p = (void *)((byte *)object + offset);
1108 value.p = *(void **)((byte *)object + offset);
1112 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1114 value.d = *(double *)((byte *)object + offset);
1116 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1118 value.f = *(float *)((byte *)object + offset);
1120 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1121 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1123 value.ui64 = *(uint64 *)((byte *)object + offset);
1125 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1126 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1128 value.i = *(int *)((byte *)object + offset);
1129 if(!strcmp(type.name, "bool") || type.type == enumClass)
1133 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1134 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1135 !strcmp(type.dataTypeString, "int16"))
1137 value.s = *(short *)((byte *)object + offset);
1139 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1140 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1142 value.c = *(char *)((byte *)object + offset);
1146 value.i = *(int *)((byte *)object + offset);
1149 if(!isFirst) f.Puts(",\n");
1150 for(c = 0; c<indent; c++) f.Puts(" ");
1153 f.Putc((char)toupper(member.name[0]));
1154 f.Puts(member.name+1);
1156 WriteValue(f, type, value, indent);
1167 for(c = 0; c<indent; c++) f.Puts(" "); f.Puts("}");