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 itemResult = GetValue(arrayType, value);
203 if(itemResult == success)
205 // TODO: Verify the matching between template type and uint64
207 if(arrayType.type == structClass)
209 t = (uint64)(uintptr)value.p;
211 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
213 t = value.ui64; //*(uint64 *)&value.d;
215 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
217 t = value.ui; //f*(uint *)&value.f;
219 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
220 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
224 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
225 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
229 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
230 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
231 !strcmp(arrayType.dataTypeString, "int16"))
235 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
236 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
242 t = (uint64)(uintptr)value.p;
244 ((void *(*)(void *, uint64))(void *)array->Add)(*array, t);
248 if(itemResult == typeMismatch)
251 PrintLn("Warning: Incompatible value for array value, expected ", (String)arrayType.name);
253 else if(itemResult == noItem)
259 if(result != syntaxError)
261 if(ch != ']' && ch != ',')
271 result = syntaxError;
279 JSONResult GetMap(Class type, Map * map)
281 JSONResult result = syntaxError;
286 Class mapNodeType = type.templateArgs[0].dataTypeClass;
287 Class keyType = mapNodeType.templateArgs[0].dataTypeClass;
288 Property keyProp = null;
289 if(keyType && !strcmp(keyType.dataTypeString, "char *"))
290 keyProp = eClass_FindProperty(mapNodeType, "key", mapNodeType.module);
292 *map = eInstance_New(type);
299 JSONResult itemResult;
301 itemResult = GetValue(mapNodeType, value);
302 if(itemResult == success)
304 String s = keyProp ? ((void * (*)(void *))(void *)keyProp.Get)(value.p) : null;
305 ((void *(*)(void *, uint64))(void *)map->Add)(*map, (uint64)(uintptr)value.p);
306 // Must free String keys here
311 if(itemResult == typeMismatch)
314 PrintLn("Warning: Incompatible value for array value, expected ", (String)mapNodeType.name);
316 else if(itemResult == noItem)
322 if(result != syntaxError)
324 if(ch != ']' && ch != ',')
334 result = syntaxError;
342 JSONResult GetString(String * string)
344 JSONResult result = syntaxError;
345 Array<char> buffer { minAllocSize = 256 };
346 bool escaped = false;
354 if(ch == '\\' && !escaped)
360 if(ch == 'b') ch = '\b';
361 else if(ch == 'f') ch = '\f';
362 else if(ch == 'n') ch = '\n';
363 else if(ch == 'r') ch = '\r';
364 else if(ch == 't') ch = '\t';
381 if(buffer.minAllocSize < buffer.count)
382 buffer.minAllocSize *= 2;
386 *string = CopyString(buffer.array);
390 if(ch != ',' && ch != '}')
395 public JSONResult GetObject(Class objectType, void ** object)
397 JSONResult result = syntaxError;
398 if(!objectType || objectType.type != structClass)
403 Class mapKeyClass = null, mapDataClass = null;
405 if(objectType && objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
407 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
408 mapDataClass = objectType.templateArgs[2].dataTypeClass;
412 if(objectType && (objectType.type == noHeadClass || objectType.type == normalClass))
414 *object = eInstance_New(objectType);
416 else if(objectType && objectType.type != structClass)
418 *object = eSystem_New(objectType.typeSize);
425 if(GetString(&string))
427 DataMember member = null;
428 Property prop = null;
435 string[0] = (char)tolower(string[0]);
436 if(mapKeyClass && !strcmp(string, "key"))
438 prop = eClass_FindProperty(objectType, "key", objectType.module);
442 else if(mapDataClass && !strcmp(string, "value"))
444 prop = eClass_FindProperty(objectType, "value", objectType.module);
449 member = eClass_FindDataMember(objectType, string, objectType.module, null, null);
452 type = eSystem_FindClass(__thisModule, member.dataTypeString);
454 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
456 offset = member._class.offset + member.offset;
460 prop = eClass_FindProperty(objectType, string, objectType.module);
463 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
465 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
468 PrintLn("Warning: member ", string, " not found in class ", (String)objectType.name);
472 // Find Member in Object Class
476 if(type && type.type == structClass)
478 value.p = (byte *)*object + offset;
484 JSONResult itemResult = GetValue(type, value);
485 if(itemResult != syntaxError)
491 PrintLn("warning: Unresolved data type ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
493 else if(itemResult == success)
498 // TOFIX: How to swiftly handle classes with base data type?
499 if(type.type == structClass)
501 else if(type.type == normalClass || type.type == noHeadClass)
503 void ** ptr = (void**)((byte *)*object + offset);
504 if(eClass_IsDerived(type, class(Container)) && *ptr)
506 Container container = (Container)*ptr;
512 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
514 *(double *)((byte *)*object + offset) = value.d;
516 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
518 *(float *)((byte *)*object + offset) = value.f;
520 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
521 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
523 *(uint64 *)((byte *)*object + offset) = value.ui64;
525 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
526 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
528 *(int *)((byte *)*object + offset) = value.i;
530 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
531 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
532 !strcmp(type.dataTypeString, "int16"))
534 *(short *)((byte *)*object + offset) = value.s;
536 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
537 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
539 *(char *)((byte *)*object + offset) = value.c;
543 *(void **)((byte *)*object + offset) = value.p;
546 else if(prop && prop.Set)
548 if(!strcmp(type.dataTypeString, "char *"))
550 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
554 // TOFIX: How to swiftly handle classes with base data type?
555 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
557 ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
559 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
561 ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
563 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
564 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
566 ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
568 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
569 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
571 ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
573 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
574 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
575 !strcmp(type.dataTypeString, "int16"))
577 ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
579 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
580 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
582 ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
586 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
592 PrintLn("Warning: Incompatible value for ", member ? (String)member.name : (String)prop.name,
593 ", expected ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
599 result = syntaxError;
602 else if(ch && ch != '}' && ch != ',')
603 result = syntaxError;
614 result = syntaxError;
622 JSONResult GetNumber(Class type, DataValue value)
624 JSONResult result = syntaxError;
627 while(c < sizeof(buffer)-1 && (ch == '-' || ch == '.' || tolower(ch) == 'e' || ch == '+' || isdigit(ch)))
630 if(!f.Getc(&ch)) break;
633 //if(strchr(buffer, '.'))
635 // TOFIX: How to swiftly handle classes with base data type?
636 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
638 value.d = strtod(buffer, null);
641 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
643 value.f = (float)strtod(buffer, null);
646 // TOFIX: int64 looks for class long long?
647 //else if(type == class(int64) || !strcmp(type.dataTypeString, "int64"))
648 else if(!strcmp(type.dataTypeString, "int64"))
650 value.i64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
653 else if(type == class(uint64) || !strcmp(type.dataTypeString, "uint64"))
655 value.ui64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
660 value.i = strtol(buffer, null, 10);
667 bool WriteMap(File f, Class type, Map map, int indent)
673 MapIterator it { map = map };
674 Class mapNodeClass = map._class.templateArgs[0].dataTypeClass;
680 MapNode n = (MapNode)it.pointer;
685 for(i = 0; i<indent; i++) f.Puts(" ");
686 _WriteJSONObject(f, mapNodeClass, n, indent);
690 for(i = 0; i<indent; i++) f.Puts(" ");
698 bool WriteArray(File f, Class type, Container array, int indent)
704 Iterator it { array };
705 Class arrayType = type.templateArgs[0].dataTypeClass;
712 uint64 t = ((uint64(*)(void *, void *))(void *)array.GetData)(array, it.pointer);
719 // TODO: Verify the matching between template type and uint64
720 if(arrayType.type == structClass)
722 value.p = (void *)(uintptr)t;
724 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
727 //value.d = *(double *)&t;
729 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
732 //value.f = *(float *)&t;
734 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
735 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
739 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
740 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
744 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
745 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
746 !strcmp(arrayType.dataTypeString, "int16"))
750 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
751 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
757 value.p = (void *)(uintptr)t;
759 for(i = 0; i<indent; i++) f.Puts(" ");
760 WriteValue(f, arrayType, value, indent);
764 for(i = 0; i<indent; i++) f.Puts(" ");
772 bool WriteNumber(File f, Class type, DataValue value, int indent)
775 bool needClass = false;
777 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
778 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.d, buffer, 0, &needClass);
779 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
780 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.f, buffer, null, &needClass);
781 else if(!strcmp(type.dataTypeString, "int64"))
782 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i64, buffer, null, &needClass);
783 else if(!strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64") || type.typeSize == sizeof(int64))
784 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui64, buffer, null, &needClass);
785 else if(!strcmp(type.dataTypeString, "int"))
786 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i, buffer, null, &needClass);
787 else if(!strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint") || type.typeSize == sizeof(int))
788 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui, buffer, null, &needClass);
789 else if(!strcmp(type.dataTypeString, "short") || !strcmp(type.dataTypeString, "int16"))
790 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.s, buffer, null, &needClass);
791 else if(!strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") || type.typeSize == sizeof(short int))
792 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.us, buffer, null, &needClass);
793 else if(!strcmp(type.dataTypeString, "char"))
794 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.c, buffer, null, &needClass);
795 else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
796 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
801 bool WriteValue(File f, Class type, DataValue value, int indent)
803 if(!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *"))
810 //if(strchr(value.p, '\"') || strchr(value.p, '\\'))
815 char * string = value.p;
834 else if(b == sizeof(buffer)-2 || !ch)
837 if(ch) buffer[b] = 0;
851 else if(!strcmp(type.name, "bool"))
858 else if(!strcmp(type.name, "SetBool"))
860 if(value.i == SetBool::true)
862 else if(value.i == SetBool::false)
867 else if(type.type == enumClass || type.type == unitClass)
870 WriteNumber(f, type, value, indent);
873 else if(eClass_IsDerived(type, class(Map)))
875 WriteMap(f, type, value.p, indent);
877 else if(eClass_IsDerived(type, class(Container)))
879 WriteArray(f, type, value.p, indent);
881 else if(type.type == normalClass || type.type == noHeadClass || type.type == structClass)
883 _WriteJSONObject(f, type, value.p, indent);
885 else if(type.type == bitClass)
888 dataType = eSystem_FindClass(__thisModule, type.dataTypeString);
889 WriteNumber(f, dataType, value, indent);
891 else if(type.type == systemClass)
893 WriteNumber(f, type, value, indent);
898 public bool WriteJSONObject(File f, Class objectType, void * object, int indent)
903 result = _WriteJSONObject(f, objectType, object, indent);
909 static bool _WriteJSONObject(File f, Class objectType, void * object, int indent)
913 const char * string = null;
915 if(objectType._vTbl[__ecereVMethodID_class_OnGetString] != objectType.base._vTbl[__ecereVMethodID_class_OnGetString])
919 string = ((const char *(*)())(void *)objectType._vTbl[__ecereVMethodID_class_OnGetString])(objectType, object, buffer, null, null);
923 // TOCHECK: ProjectNode.ec why do we add quotes in OnGetString there?
924 if(string[0] == '\"')
938 Class mapKeyClass = null, mapDataClass = null;
940 List<Class> bases { };
942 if(objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
944 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
945 mapDataClass = objectType.templateArgs[2].dataTypeClass;
951 for(baseClass = objectType; baseClass; baseClass = baseClass.base)
953 if(baseClass.isInstanceClass || !baseClass.base)
955 bases.Insert(null, baseClass);
958 for(baseClass : bases)
960 for(prop = baseClass.membersAndProperties.first; prop; prop = prop.next)
962 if(prop.memberAccess != publicAccess || (prop.isProperty && (!prop.Set || !prop.Get))) continue;
965 if(!prop.conversion && (!prop.IsSet || prop.IsSet(object)))
970 if(mapKeyClass && !strcmp(prop.name, "key"))
972 else if(mapDataClass && !strcmp(prop.name, "value"))
975 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
977 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
979 PrintLn("warning: Unresolved data type ", (String)prop.dataTypeString);
982 // TOFIX: How to swiftly handle classes with base data type?
983 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
985 value.d = ((double (*)(void *))(void *)prop.Get)(object);
987 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
989 value.f = ((float (*)(void *))(void *)prop.Get)(object);
991 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
992 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
994 value.ui64 = ((uint64 (*)(void *))(void *)prop.Get)(object);
996 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
997 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
999 value.i = ((int (*)(void *))(void *)prop.Get)(object);
1001 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1002 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1003 !strcmp(type.dataTypeString, "int16"))
1005 value.s = ((short (*)(void *))(void *)prop.Get)(object);
1007 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1008 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1010 value.c = ((char (*)(void *))(void *)prop.Get)(object);
1012 else if(type.type == structClass)
1014 value.p = new byte[type.structSize];
1015 ((void (*)(void *, void *))(void *)prop.Get)(object, value.p);
1019 value.p = ((void *(*)(void *))(void *)prop.Get)(object);
1022 if(!isFirst) f.Puts(",\n");
1023 for(c = 0; c<indent; c++) f.Puts(" ");
1026 f.Putc((char)toupper(prop.name[0]));
1027 f.Puts(prop.name+1);
1029 WriteValue(f, type, value, indent);
1031 if(type.type == structClass)
1038 DataMember member = (DataMember)prop;
1039 DataValue value { };
1041 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
1043 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
1045 offset = member._class.offset + member.offset;
1049 if(type.type == normalClass || type.type == noHeadClass || type.type == structClass || !strcmp(type.name, "String"))
1051 if(type.type == structClass)
1052 value.p = (void *)((byte *)object + offset);
1054 value.p = *(void **)((byte *)object + offset);
1058 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1060 value.d = *(double *)((byte *)object + offset);
1062 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1064 value.f = *(float *)((byte *)object + offset);
1066 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1067 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1069 value.ui64 = *(uint64 *)((byte *)object + offset);
1071 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1072 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1074 value.i = *(int *)((byte *)object + offset);
1075 if(!strcmp(type.name, "bool") || type.type == enumClass)
1079 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1080 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1081 !strcmp(type.dataTypeString, "int16"))
1083 value.s = *(short *)((byte *)object + offset);
1085 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1086 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1088 value.c = *(char *)((byte *)object + offset);
1092 value.i = *(int *)((byte *)object + offset);
1095 if(!isFirst) f.Puts(",\n");
1096 for(c = 0; c<indent; c++) f.Puts(" ");
1099 f.Putc((char)toupper(member.name[0]));
1100 f.Puts(member.name+1);
1102 WriteValue(f, type, value, indent);
1113 for(c = 0; c<indent; c++) f.Puts(" "); f.Puts("}");