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 itemResult = GetValue(arrayType, value);
204 if(itemResult == success)
206 // TODO: Verify the matching between template type and uint64
208 if(arrayType.type == structClass)
210 t = (uint64)(uintptr)value.p;
212 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
214 t = value.ui64; //*(uint64 *)&value.d;
216 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
218 t = value.ui; //f*(uint *)&value.f;
220 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
221 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
225 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
226 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
230 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
231 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
232 !strcmp(arrayType.dataTypeString, "int16"))
236 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
237 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
243 t = (uint64)(uintptr)value.p;
245 ((void *(*)(void *, uint64))(void *)array->Add)(*array, t);
249 if(itemResult == typeMismatch)
252 PrintLn("Warning: Incompatible value for array value, expected ", (String)arrayType.name);
254 else if(itemResult == noItem)
260 if(result != syntaxError)
262 if(ch != ']' && ch != ',')
272 result = syntaxError;
280 JSONResult GetMap(Class type, Map * map)
282 JSONResult result = syntaxError;
287 Class mapNodeType = type.templateArgs[0].dataTypeClass;
288 Class keyType = mapNodeType.templateArgs[0].dataTypeClass;
289 Property keyProp = null;
290 if(keyType && !strcmp(keyType.dataTypeString, "char *"))
291 keyProp = eClass_FindProperty(mapNodeType, "key", mapNodeType.module);
293 *map = eInstance_New(type);
300 JSONResult itemResult;
302 itemResult = GetValue(mapNodeType, value);
303 if(itemResult == success)
305 String s = keyProp ? ((void * (*)(void *))(void *)keyProp.Get)(value.p) : null;
306 ((void *(*)(void *, uint64))(void *)map->Add)(*map, (uint64)(uintptr)value.p);
307 // Must free String keys here
312 if(itemResult == typeMismatch)
315 PrintLn("Warning: Incompatible value for array value, expected ", (String)mapNodeType.name);
317 else if(itemResult == noItem)
323 if(result != syntaxError)
325 if(ch != ']' && ch != ',')
335 result = syntaxError;
343 JSONResult GetString(String * string)
345 JSONResult result = syntaxError;
346 Array<char> buffer { minAllocSize = 256 };
347 bool escaped = false;
355 if(ch == '\\' && !escaped)
361 if(ch == 'b') ch = '\b';
362 else if(ch == 'f') ch = '\f';
363 else if(ch == 'n') ch = '\n';
364 else if(ch == 'r') ch = '\r';
365 else if(ch == 't') ch = '\t';
382 if(buffer.minAllocSize < buffer.count)
383 buffer.minAllocSize *= 2;
387 *string = CopyString(buffer.array);
391 if(ch != ',' && ch != '}')
396 public JSONResult GetObject(Class objectType, void ** object)
398 JSONResult result = syntaxError;
399 if(!objectType || objectType.type != structClass)
404 Class mapKeyClass = null, mapDataClass = null;
406 if(objectType && objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
408 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
409 mapDataClass = objectType.templateArgs[2].dataTypeClass;
413 if(objectType && (objectType.type == noHeadClass || objectType.type == normalClass))
415 *object = eInstance_New(objectType);
417 else if(objectType && objectType.type != structClass)
419 *object = eSystem_New(objectType.typeSize);
426 if(GetString(&string))
428 DataMember member = null;
429 Property prop = null;
436 string[0] = (char)tolower(string[0]);
437 if(mapKeyClass && !strcmp(string, "key"))
439 prop = eClass_FindProperty(objectType, "key", objectType.module);
443 else if(mapDataClass && !strcmp(string, "value"))
445 prop = eClass_FindProperty(objectType, "value", objectType.module);
450 member = eClass_FindDataMember(objectType, string, objectType.module, null, null);
453 type = eSystem_FindClass(__thisModule, member.dataTypeString);
455 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
457 offset = member._class.offset + member.offset;
461 prop = eClass_FindProperty(objectType, string, objectType.module);
464 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
466 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
469 PrintLn("Warning: member ", string, " not found in class ", (String)objectType.name);
473 // Find Member in Object Class
477 if(type && type.type == structClass)
479 value.p = (byte *)*object + offset;
485 JSONResult itemResult = GetValue(type, value);
486 if(itemResult != syntaxError)
492 PrintLn("warning: Unresolved data type ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
494 else if(itemResult == success)
499 // TOFIX: How to swiftly handle classes with base data type?
500 if(type.type == structClass)
502 else if(type.type == normalClass || type.type == noHeadClass)
504 void ** ptr = (void**)((byte *)*object + offset);
505 if(eClass_IsDerived(type, class(Container)) && *ptr)
507 Container container = (Container)*ptr;
513 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
515 *(double *)((byte *)*object + offset) = value.d;
517 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
519 *(float *)((byte *)*object + offset) = value.f;
521 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
522 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
524 *(uint64 *)((byte *)*object + offset) = value.ui64;
526 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
527 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
529 *(int *)((byte *)*object + offset) = value.i;
531 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
532 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
533 !strcmp(type.dataTypeString, "int16"))
535 *(short *)((byte *)*object + offset) = value.s;
537 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
538 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
540 *(char *)((byte *)*object + offset) = value.c;
544 *(void **)((byte *)*object + offset) = value.p;
547 else if(prop && prop.Set)
549 if(!strcmp(type.dataTypeString, "char *"))
551 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
555 // TOFIX: How to swiftly handle classes with base data type?
556 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
558 ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
560 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
562 ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
564 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
565 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
567 ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
569 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
570 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
572 ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
574 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
575 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
576 !strcmp(type.dataTypeString, "int16"))
578 ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
580 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
581 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
583 ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
587 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
593 PrintLn("Warning: Incompatible value for ", member ? (String)member.name : (String)prop.name,
594 ", expected ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
600 result = syntaxError;
603 else if(ch && ch != '}' && ch != ',')
604 result = syntaxError;
615 result = syntaxError;
623 JSONResult GetNumber(Class type, DataValue value)
625 JSONResult result = syntaxError;
628 while(c < sizeof(buffer)-1 && (ch == '-' || ch == '.' || tolower(ch) == 'e' || ch == '+' || isdigit(ch)))
631 if(!f.Getc(&ch)) break;
634 //if(strchr(buffer, '.'))
636 // TOFIX: How to swiftly handle classes with base data type?
637 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
639 value.d = strtod(buffer, null);
642 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
644 value.f = (float)strtod(buffer, null);
647 // TOFIX: int64 looks for class long long?
648 //else if(type == class(int64) || !strcmp(type.dataTypeString, "int64"))
649 else if(!strcmp(type.dataTypeString, "int64"))
651 value.i64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
654 else if(type == class(uint64) || !strcmp(type.dataTypeString, "uint64"))
656 value.ui64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
661 value.i = strtol(buffer, null, 10);
668 bool WriteMap(File f, Class type, Map map, int indent)
674 MapIterator it { map = map };
675 Class mapNodeClass = map._class.templateArgs[0].dataTypeClass;
681 MapNode n = (MapNode)it.pointer;
686 for(i = 0; i<indent; i++) f.Puts(" ");
687 _WriteJSONObject(f, mapNodeClass, n, indent);
691 for(i = 0; i<indent; i++) f.Puts(" ");
699 bool WriteArray(File f, Class type, Container array, int indent)
705 Iterator it { array };
706 Class arrayType = type.templateArgs[0].dataTypeClass;
713 uint64 t = ((uint64(*)(void *, void *))(void *)array.GetData)(array, it.pointer);
720 // TODO: Verify the matching between template type and uint64
721 if(arrayType.type == structClass)
723 value.p = (void *)(uintptr)t;
725 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
728 //value.d = *(double *)&t;
730 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
733 //value.f = *(float *)&t;
735 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
736 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
740 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
741 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
745 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
746 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
747 !strcmp(arrayType.dataTypeString, "int16"))
751 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
752 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
758 value.p = (void *)(uintptr)t;
760 for(i = 0; i<indent; i++) f.Puts(" ");
761 WriteValue(f, arrayType, value, indent);
765 for(i = 0; i<indent; i++) f.Puts(" ");
773 bool WriteNumber(File f, Class type, DataValue value, int indent)
776 bool needClass = false;
778 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
779 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.d, buffer, 0, &needClass);
780 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
781 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.f, buffer, null, &needClass);
782 else if(!strcmp(type.dataTypeString, "int64"))
783 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i64, buffer, null, &needClass);
784 else if(!strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64") || type.typeSize == sizeof(int64))
785 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui64, buffer, null, &needClass);
786 else if(!strcmp(type.dataTypeString, "int"))
787 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i, buffer, null, &needClass);
788 else if(!strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint") || type.typeSize == sizeof(int))
789 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui, buffer, null, &needClass);
790 else if(!strcmp(type.dataTypeString, "short") || !strcmp(type.dataTypeString, "int16"))
791 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.s, buffer, null, &needClass);
792 else if(!strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") || type.typeSize == sizeof(short int))
793 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.us, buffer, null, &needClass);
794 else if(!strcmp(type.dataTypeString, "char"))
795 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.c, buffer, null, &needClass);
796 else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
797 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
802 bool WriteValue(File f, Class type, DataValue value, int indent)
804 if(!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *"))
811 //if(strchr(value.p, '\"') || strchr(value.p, '\\'))
816 char * string = value.p;
835 else if(b == sizeof(buffer)-2 || !ch)
838 if(ch) buffer[b] = 0;
852 else if(!strcmp(type.name, "bool"))
859 else if(!strcmp(type.name, "SetBool"))
861 if(value.i == SetBool::true)
863 else if(value.i == SetBool::false)
868 else if(type.type == enumClass || type.type == unitClass)
871 WriteNumber(f, type, value, indent);
874 else if(eClass_IsDerived(type, class(Map)))
876 WriteMap(f, type, value.p, indent);
878 else if(eClass_IsDerived(type, class(Container)))
880 WriteArray(f, type, value.p, indent);
882 else if(type.type == normalClass || type.type == noHeadClass || type.type == structClass)
884 _WriteJSONObject(f, type, value.p, indent);
886 else if(type.type == bitClass)
889 dataType = eSystem_FindClass(__thisModule, type.dataTypeString);
890 WriteNumber(f, dataType, value, indent);
892 else if(type.type == systemClass)
894 WriteNumber(f, type, value, indent);
899 public bool WriteJSONObject(File f, Class objectType, void * object, int indent)
904 result = _WriteJSONObject(f, objectType, object, indent);
910 static bool _WriteJSONObject(File f, Class objectType, void * object, int indent)
914 const char * string = null;
916 if(objectType._vTbl[__ecereVMethodID_class_OnGetString] != objectType.base._vTbl[__ecereVMethodID_class_OnGetString])
920 string = ((const char *(*)())(void *)objectType._vTbl[__ecereVMethodID_class_OnGetString])(objectType, object, buffer, null, null);
924 // TOCHECK: ProjectNode.ec why do we add quotes in OnGetString there?
925 if(string[0] == '\"')
939 Class mapKeyClass = null, mapDataClass = null;
941 List<Class> bases { };
943 if(objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
945 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
946 mapDataClass = objectType.templateArgs[2].dataTypeClass;
952 for(baseClass = objectType; baseClass; baseClass = baseClass.base)
954 if(baseClass.isInstanceClass || !baseClass.base)
956 bases.Insert(null, baseClass);
959 for(baseClass : bases)
961 for(prop = baseClass.membersAndProperties.first; prop; prop = prop.next)
963 if(prop.memberAccess != publicAccess || (prop.isProperty && (!prop.Set || !prop.Get))) continue;
966 if(!prop.conversion && (!prop.IsSet || prop.IsSet(object)))
971 if(mapKeyClass && !strcmp(prop.name, "key"))
973 else if(mapDataClass && !strcmp(prop.name, "value"))
976 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
978 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
980 PrintLn("warning: Unresolved data type ", (String)prop.dataTypeString);
983 // TOFIX: How to swiftly handle classes with base data type?
984 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
986 value.d = ((double (*)(void *))(void *)prop.Get)(object);
988 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
990 value.f = ((float (*)(void *))(void *)prop.Get)(object);
992 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
993 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
995 value.ui64 = ((uint64 (*)(void *))(void *)prop.Get)(object);
997 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
998 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1000 value.i = ((int (*)(void *))(void *)prop.Get)(object);
1002 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1003 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1004 !strcmp(type.dataTypeString, "int16"))
1006 value.s = ((short (*)(void *))(void *)prop.Get)(object);
1008 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1009 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1011 value.c = ((char (*)(void *))(void *)prop.Get)(object);
1013 else if(type.type == structClass)
1015 value.p = new byte[type.structSize];
1016 ((void (*)(void *, void *))(void *)prop.Get)(object, value.p);
1020 value.p = ((void *(*)(void *))(void *)prop.Get)(object);
1023 if(!isFirst) f.Puts(",\n");
1024 for(c = 0; c<indent; c++) f.Puts(" ");
1027 f.Putc((char)toupper(prop.name[0]));
1028 f.Puts(prop.name+1);
1030 WriteValue(f, type, value, indent);
1032 if(type.type == structClass)
1039 DataMember member = (DataMember)prop;
1040 DataValue value { };
1042 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
1044 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
1046 offset = member._class.offset + member.offset;
1050 if(type.type == normalClass || type.type == noHeadClass || type.type == structClass || !strcmp(type.name, "String"))
1052 if(type.type == structClass)
1053 value.p = (void *)((byte *)object + offset);
1055 value.p = *(void **)((byte *)object + offset);
1059 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1061 value.d = *(double *)((byte *)object + offset);
1063 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1065 value.f = *(float *)((byte *)object + offset);
1067 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1068 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1070 value.ui64 = *(uint64 *)((byte *)object + offset);
1072 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1073 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1075 value.i = *(int *)((byte *)object + offset);
1076 if(!strcmp(type.name, "bool") || type.type == enumClass)
1080 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1081 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1082 !strcmp(type.dataTypeString, "int16"))
1084 value.s = *(short *)((byte *)object + offset);
1086 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1087 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1089 value.c = *(char *)((byte *)object + offset);
1093 value.i = *(int *)((byte *)object + offset);
1096 if(!isFirst) f.Puts(",\n");
1097 for(c = 0; c<indent; c++) f.Puts(" ");
1100 f.Putc((char)toupper(member.name[0]));
1101 f.Puts(member.name+1);
1103 WriteValue(f, type, value, indent);
1114 for(c = 0; c<indent; c++) f.Puts(" "); f.Puts("}");