7 __attribute__((unused)) static void UnusedFunction()
10 a.OnGetDataFromString(null);
11 a.OnGetString(null, 0, 0);
14 extern int __ecereVMethodID_class_OnGetDataFromString;
15 extern int __ecereVMethodID_class_OnGetString;
16 extern int __ecereVMethodID_class_OnFree;
19 public enum JSONResult { syntaxError, success, typeMismatch, noItem };
21 public enum SetBool : uint
25 /*public property bool // NOT WORKING!
27 set { return value ? true : false; }
28 get { return (this == true); }
33 public class JSONParser
41 while(!f.Eof() && (!ch || ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'))
47 JSONResult GetValue(Class type, DataValue value)
49 JSONResult result = syntaxError;
55 result = GetString(&string);
59 if(type && (!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *")))
63 else if(type && (type.type == enumClass || type.type == unitClass))
65 if(((bool (*)(void *, void *, const char *))(void *)type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(type, &value.i, string))
68 result = typeMismatch;
71 else if(type && (prop = eClass_FindProperty(type, "String", type.module)))
73 // TOFIX: Add more conversion property support... Expecting void * compatible here
74 value.p = ((void *(*)())(void *)prop.Set)(string);
78 else if(type && (type.type == structClass))
80 if(((bool (*)(void *, void *, const char *))(void *)type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(type, value.p, string))
83 result = typeMismatch;
89 result = typeMismatch;
96 if(type && eClass_IsDerived(type, class(Map)))
98 result = GetMap(type, (Map *)&array);
101 result = GetArray(type, &array);
103 if(result == success && type && eClass_IsDerived(type, class(Container)))
112 if(result != success)
113 result = typeMismatch;
116 else if(ch == '-' || isdigit(ch))
118 result = GetNumber(type, value);
122 void * object = value.p;
123 result = GetObject(type, &object);
126 if(type && type.type == structClass);
127 else if(type && (type.type == normalClass || type.type == noHeadClass || type.type == bitClass))
133 result = typeMismatch;
135 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, object);
143 while(c < sizeof(buffer)-1 && isalpha(ch))
146 if(!f.Getc(&ch)) break;
153 if(!strcmp(type.name, "bool"))
155 if(!strcmpi(buffer, "false")) value.i = 0;
156 else if(!strcmpi(buffer, "true")) value.i = 1;
158 result = typeMismatch;
160 else if(!strcmp(type.name, "SetBool"))
162 if(!strcmpi(buffer, "false")) value.i = SetBool::false;
163 else if(!strcmpi(buffer, "true")) value.i = SetBool::true;
165 result = typeMismatch;
167 else if(!strcmpi(buffer, "null"))
172 result = typeMismatch;
175 result = typeMismatch;
177 else if(ch == '}' || ch == ']')
182 JSONResult GetArray(Class type, Container * array)
184 JSONResult result = syntaxError;
189 *array = eInstance_New(type);
194 Class arrayType = null;
195 JSONResult itemResult;
197 if(eClass_IsDerived(type, class(Container)))
199 arrayType = type.templateArgs[0].dataTypeClass;
202 if(arrayType && arrayType.type == structClass)
203 value.p = new byte[arrayType.structSize];
204 itemResult = GetValue(arrayType, value);
205 if(itemResult == success)
207 // TODO: Verify the matching between template type and uint64
209 if(arrayType.type == structClass)
211 t = (uint64)(uintptr)value.p;
213 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
215 t = value.ui64; //*(uint64 *)&value.d;
217 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
219 t = value.ui; //f*(uint *)&value.f;
221 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
222 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
226 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
227 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
231 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
232 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
233 !strcmp(arrayType.dataTypeString, "int16"))
237 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
238 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
244 t = (uint64)(uintptr)value.p;
246 ((void *(*)(void *, uint64))(void *)array->Add)(*array, t);
248 if(arrayType && arrayType.type == structClass)
253 if(itemResult == typeMismatch)
256 PrintLn("Warning: Incompatible value for array value, expected ", (String)arrayType.name);
258 else if(itemResult == noItem)
264 if(result != syntaxError)
266 if(ch != ']' && ch != ',')
276 result = syntaxError;
284 JSONResult GetMap(Class type, Map * map)
286 JSONResult result = syntaxError;
291 Class mapNodeType = type.templateArgs[0].dataTypeClass;
292 Class keyType = mapNodeType.templateArgs[0].dataTypeClass;
293 Property keyProp = null;
294 if(keyType && !strcmp(keyType.dataTypeString, "char *"))
295 keyProp = eClass_FindProperty(mapNodeType, "key", mapNodeType.module);
297 *map = eInstance_New(type);
304 JSONResult itemResult;
306 itemResult = GetValue(mapNodeType, value);
307 if(itemResult == success)
309 String s = keyProp ? ((void * (*)(void *))(void *)keyProp.Get)(value.p) : null;
310 ((void *(*)(void *, uint64))(void *)map->Add)(*map, (uint64)(uintptr)value.p);
311 // Must free String keys here
316 if(itemResult == typeMismatch)
319 PrintLn("Warning: Incompatible value for array value, expected ", (String)mapNodeType.name);
321 else if(itemResult == noItem)
327 if(result != syntaxError)
329 if(ch != ']' && ch != ',')
339 result = syntaxError;
347 JSONResult GetString(String * string)
349 JSONResult result = syntaxError;
350 Array<char> buffer { minAllocSize = 256 };
351 bool escaped = false;
359 if(ch == '\\' && !escaped)
365 if(ch == 'b') ch = '\b';
366 else if(ch == 'f') ch = '\f';
367 else if(ch == 'n') ch = '\n';
368 else if(ch == 'r') ch = '\r';
369 else if(ch == 't') ch = '\t';
386 if(buffer.minAllocSize < buffer.count)
387 buffer.minAllocSize *= 2;
391 *string = CopyString(buffer.array);
395 if(ch != ',' && ch != '}')
400 public JSONResult GetObject(Class objectType, void ** object)
402 JSONResult result = syntaxError;
403 if(!objectType || objectType.type != structClass)
408 Class mapKeyClass = null, mapDataClass = null;
410 if(objectType && objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
412 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
413 mapDataClass = objectType.templateArgs[2].dataTypeClass;
417 if(objectType && (objectType.type == noHeadClass || objectType.type == normalClass))
419 *object = eInstance_New(objectType);
421 else if(objectType && objectType.type != structClass)
423 *object = eSystem_New(objectType.typeSize);
430 if(GetString(&string))
432 DataMember member = null;
433 Property prop = null;
440 string[0] = (char)tolower(string[0]);
441 if(mapKeyClass && !strcmp(string, "key"))
443 prop = eClass_FindProperty(objectType, "key", objectType.module);
447 else if(mapDataClass && !strcmp(string, "value"))
449 prop = eClass_FindProperty(objectType, "value", objectType.module);
454 member = eClass_FindDataMember(objectType, string, objectType.module, null, null);
457 type = eSystem_FindClass(__thisModule, member.dataTypeString);
459 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
461 offset = member._class.offset + member.offset;
465 prop = eClass_FindProperty(objectType, string, objectType.module);
468 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
470 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
473 PrintLn("Warning: member ", string, " not found in class ", (String)objectType.name);
477 // Find Member in Object Class
481 if(type && type.type == structClass)
483 value.p = (byte *)*object + offset;
489 JSONResult itemResult = GetValue(type, value);
490 if(itemResult != syntaxError)
496 PrintLn("warning: Unresolved data type ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
498 else if(itemResult == success)
503 // TOFIX: How to swiftly handle classes with base data type?
504 if(type.type == structClass)
506 else if(type.type == normalClass || type.type == noHeadClass)
508 void ** ptr = (void**)((byte *)*object + offset);
509 if(eClass_IsDerived(type, class(Container)) && *ptr)
511 Container container = (Container)*ptr;
517 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
519 *(double *)((byte *)*object + offset) = value.d;
521 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
523 *(float *)((byte *)*object + offset) = value.f;
525 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
526 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
528 *(uint64 *)((byte *)*object + offset) = value.ui64;
530 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
531 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
533 *(int *)((byte *)*object + offset) = value.i;
535 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
536 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
537 !strcmp(type.dataTypeString, "int16"))
539 *(short *)((byte *)*object + offset) = value.s;
541 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
542 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
544 *(char *)((byte *)*object + offset) = value.c;
548 *(void **)((byte *)*object + offset) = value.p;
551 else if(prop && prop.Set)
553 if(!strcmp(type.dataTypeString, "char *"))
555 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
559 // TOFIX: How to swiftly handle classes with base data type?
560 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
562 ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
564 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
566 ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
568 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
569 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
571 ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
573 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
574 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
576 ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
578 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
579 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
580 !strcmp(type.dataTypeString, "int16"))
582 ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
584 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
585 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
587 ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
591 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
597 PrintLn("Warning: Incompatible value for ", member ? (String)member.name : (String)prop.name,
598 ", expected ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
604 result = syntaxError;
607 else if(ch && ch != '}' && ch != ',')
608 result = syntaxError;
619 result = syntaxError;
627 JSONResult GetNumber(Class type, DataValue value)
629 JSONResult result = syntaxError;
632 while(c < sizeof(buffer)-1 && (ch == '-' || ch == '.' || tolower(ch) == 'e' || ch == '+' || isdigit(ch)))
635 if(!f.Getc(&ch)) break;
638 //if(strchr(buffer, '.'))
640 // TOFIX: How to swiftly handle classes with base data type?
641 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
643 value.d = strtod(buffer, null);
646 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
648 value.f = (float)strtod(buffer, null);
651 // TOFIX: int64 looks for class long long?
652 //else if(type == class(int64) || !strcmp(type.dataTypeString, "int64"))
653 else if(!strcmp(type.dataTypeString, "int64"))
655 value.i64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
658 else if(type == class(uint64) || !strcmp(type.dataTypeString, "uint64"))
660 value.ui64 = strtoul(buffer, null, 10); // TOFIX: 64 bit support
663 else if(type == class(uint) || !strcmp(type.dataTypeString, "unsigned int"))
665 value.ui = strtoul(buffer, null, 10); // TOFIX: 64 bit support
670 value.i = strtol(buffer, null, 10);
674 if(result == success && type.type == unitClass)
676 // Convert to reference unit
679 for(prop = type.conversions.first; prop; prop = prop.next)
681 bool refProp = false;
683 if(!strcmp(prop.name, type.base.fullName))
685 else if( (c = eSystem_FindClass(type.module, prop.name) ) )
688 for(p = c.conversions.first; p; p = p.next)
690 if(!strcmp(p.name, type.base.fullName) && !p.Set && !p.Get)
699 if(prop.Set && prop.Get)
701 const String dts = type.base.dataTypeString;
702 if(!strcmp(dts, "double"))
703 value.d = ((double(*)(double))(void *)prop.Get)(value.d);
704 else if(!strcmp(dts, "float"))
705 value.f = ((float(*)(float))(void *)prop.Get)(value.f);
706 else if(!strcmp(dts, "int"))
707 value.i = ((int(*)(int))(void *)prop.Get)(value.i);
708 else if(!strcmp(dts, "int64"))
709 value.i64 = ((int64(*)(int64))(void *)prop.Get)(value.i64);
720 bool WriteMap(File f, Class type, Map map, int indent)
726 MapIterator it { map = map };
727 Class mapNodeClass = map._class.templateArgs[0].dataTypeClass;
733 MapNode n = (MapNode)it.pointer;
738 for(i = 0; i<indent; i++) f.Puts(" ");
739 _WriteJSONObject(f, mapNodeClass, n, indent);
743 for(i = 0; i<indent; i++) f.Puts(" ");
751 bool WriteArray(File f, Class type, Container array, int indent)
757 Iterator it { array };
758 Class arrayType = type.templateArgs[0].dataTypeClass;
765 uint64 t = ((uint64(*)(void *, void *))(void *)array.GetData)(array, it.pointer);
772 // TODO: Verify the matching between template type and uint64
773 if(arrayType.type == structClass)
775 value.p = (void *)(uintptr)t;
777 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
780 //value.d = *(double *)&t;
782 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
785 //value.f = *(float *)&t;
787 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
788 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
792 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
793 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
797 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
798 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
799 !strcmp(arrayType.dataTypeString, "int16"))
803 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
804 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
810 value.p = (void *)(uintptr)t;
812 for(i = 0; i<indent; i++) f.Puts(" ");
813 WriteValue(f, arrayType, value, indent);
817 for(i = 0; i<indent; i++) f.Puts(" ");
825 bool WriteNumber(File f, Class type, DataValue value, int indent)
828 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);
852 quote = (type.type == unitClass && ((buffer[0] != '.' && !isdigit(buffer[0])) || strchr(buffer, ' ')));
853 if(quote) f.Puts("\"");
855 if(quote) f.Puts("\"");
859 bool WriteValue(File f, Class type, DataValue value, int indent)
861 if(!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *"))
868 //if(strchr(value.p, '\"') || strchr(value.p, '\\'))
873 char * string = value.p;
892 else if(b == sizeof(buffer)-2 || !ch)
895 if(ch) buffer[b] = 0;
909 else if(!strcmp(type.name, "bool"))
916 else if(!strcmp(type.name, "SetBool"))
918 if(value.i == SetBool::true)
920 else if(value.i == SetBool::false)
925 else if(type.type == enumClass)
928 WriteNumber(f, type, value, indent);
931 else if(eClass_IsDerived(type, class(Map)))
933 WriteMap(f, type, value.p, indent);
935 else if(eClass_IsDerived(type, class(Container)))
937 WriteArray(f, type, value.p, indent);
939 else if(type.type == normalClass || type.type == noHeadClass || type.type == structClass)
941 _WriteJSONObject(f, type, value.p, indent);
943 else if(type.type == bitClass)
946 dataType = eSystem_FindClass(__thisModule, type.dataTypeString);
947 WriteNumber(f, dataType, value, indent);
949 else if(type.type == systemClass || type.type == unitClass)
951 WriteNumber(f, type, value, indent);
956 public bool WriteJSONObject(File f, Class objectType, void * object, int indent)
961 result = _WriteJSONObject(f, objectType, object, indent);
967 static bool _WriteJSONObject(File f, Class objectType, void * object, int indent)
971 const char * string = null;
973 if(objectType._vTbl[__ecereVMethodID_class_OnGetString] != objectType.base._vTbl[__ecereVMethodID_class_OnGetString])
977 string = ((const char *(*)())(void *)objectType._vTbl[__ecereVMethodID_class_OnGetString])(objectType, object, buffer, null, null);
981 // TOCHECK: ProjectNode.ec why do we add quotes in OnGetString there?
982 if(string[0] == '\"')
996 Class mapKeyClass = null, mapDataClass = null;
998 List<Class> bases { };
1000 if(objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
1002 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
1003 mapDataClass = objectType.templateArgs[2].dataTypeClass;
1009 for(baseClass = objectType; baseClass; baseClass = baseClass.base)
1011 if(baseClass.isInstanceClass || !baseClass.base)
1013 bases.Insert(null, baseClass);
1016 for(baseClass : bases)
1018 for(prop = baseClass.membersAndProperties.first; prop; prop = prop.next)
1020 if(prop.memberAccess != publicAccess || (prop.isProperty && (!prop.Set || !prop.Get))) continue;
1023 if(!prop.conversion && (!prop.IsSet || prop.IsSet(object)))
1025 DataValue value { };
1028 if(mapKeyClass && !strcmp(prop.name, "key"))
1030 else if(mapDataClass && !strcmp(prop.name, "value"))
1031 type = mapDataClass;
1033 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
1035 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
1037 PrintLn("warning: Unresolved data type ", (String)prop.dataTypeString);
1040 // TOFIX: How to swiftly handle classes with base data type?
1041 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1043 value.d = ((double (*)(void *))(void *)prop.Get)(object);
1045 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1047 value.f = ((float (*)(void *))(void *)prop.Get)(object);
1049 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1050 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1052 value.ui64 = ((uint64 (*)(void *))(void *)prop.Get)(object);
1054 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1055 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1057 value.i = ((int (*)(void *))(void *)prop.Get)(object);
1059 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1060 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1061 !strcmp(type.dataTypeString, "int16"))
1063 value.s = ((short (*)(void *))(void *)prop.Get)(object);
1065 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1066 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1068 value.c = ((char (*)(void *))(void *)prop.Get)(object);
1070 else if(type.type == structClass)
1072 value.p = new byte[type.structSize];
1073 ((void (*)(void *, void *))(void *)prop.Get)(object, value.p);
1077 value.p = ((void *(*)(void *))(void *)prop.Get)(object);
1080 if(!isFirst) f.Puts(",\n");
1081 for(c = 0; c<indent; c++) f.Puts(" ");
1084 f.Putc((char)toupper(prop.name[0]));
1085 f.Puts(prop.name+1);
1087 WriteValue(f, type, value, indent);
1089 if(type.type == structClass)
1096 DataMember member = (DataMember)prop;
1097 DataValue value { };
1099 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
1101 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
1103 offset = member._class.offset + member.offset;
1107 if(type.type == normalClass || type.type == noHeadClass || type.type == structClass || !strcmp(type.name, "String"))
1109 if(type.type == structClass)
1110 value.p = (void *)((byte *)object + offset);
1112 value.p = *(void **)((byte *)object + offset);
1116 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1118 value.d = *(double *)((byte *)object + offset);
1120 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1122 value.f = *(float *)((byte *)object + offset);
1124 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1125 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1127 value.ui64 = *(uint64 *)((byte *)object + offset);
1129 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1130 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1132 value.i = *(int *)((byte *)object + offset);
1133 if(!strcmp(type.name, "bool") || type.type == enumClass)
1137 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1138 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1139 !strcmp(type.dataTypeString, "int16"))
1141 value.s = *(short *)((byte *)object + offset);
1143 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1144 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1146 value.c = *(char *)((byte *)object + offset);
1150 value.i = *(int *)((byte *)object + offset);
1153 if(!isFirst) f.Puts(",\n");
1154 for(c = 0; c<indent; c++) f.Puts(" ");
1157 f.Putc((char)toupper(member.name[0]));
1158 f.Puts(member.name+1);
1160 WriteValue(f, type, value, indent);
1171 for(c = 0; c<indent; c++) f.Puts(" "); f.Puts("}");