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
23 unset, false, true /*; // Syntax error! */
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)))
97 result = GetMap(type, (Map *)&array);
99 result = GetArray(type, &array);
101 if(result == success && type && eClass_IsDerived(type, class(Container)))
110 if(result != success)
111 result = typeMismatch;
114 else if(ch == '-' || isdigit(ch))
116 result = GetNumber(type, value);
120 void * object = value.p;
121 result = GetObject(type, &object);
124 if(type && type.type == structClass);
125 else if(type && (type.type == normalClass || type.type == noHeadClass || type.type == bitClass))
131 result = typeMismatch;
133 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, object);
141 while(c < sizeof(buffer)-1 && isalpha(ch))
144 if(!f.Getc(&ch)) break;
151 if(!strcmp(type.name, "bool"))
153 if(!strcmpi(buffer, "false")) value.i = 0;
154 else if(!strcmpi(buffer, "true")) value.i = 1;
156 result = typeMismatch;
158 else if(!strcmp(type.name, "SetBool"))
160 if(!strcmpi(buffer, "false")) value.i = SetBool::false;
161 else if(!strcmpi(buffer, "true")) value.i = SetBool::true;
163 result = typeMismatch;
165 else if(!strcmpi(buffer, "null"))
170 result = typeMismatch;
173 result = typeMismatch;
175 else if(ch == '}' || ch == ']')
180 JSONResult GetArray(Class type, Container * array)
182 JSONResult result = syntaxError;
187 *array = eInstance_New(type);
192 Class arrayType = null;
193 JSONResult itemResult;
195 if(eClass_IsDerived(type, class(Container)))
197 arrayType = type.templateArgs[0].dataTypeClass;
200 itemResult = GetValue(arrayType, value);
201 if(itemResult == success)
203 // TODO: Verify the matching between template type and uint64
205 if(arrayType.type == structClass)
207 t = (uint64)(uintptr)value.p;
209 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
211 t = *(uint64 *)&value.d;
213 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
215 t = *(uint *)&value.f;
217 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
218 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
222 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
223 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
227 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
228 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
229 !strcmp(arrayType.dataTypeString, "int16"))
233 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
234 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
240 t = (uint64)(uintptr)value.p;
242 ((void *(*)(void *, uint64))(void *)array->Add)(*array, t);
246 if(itemResult == typeMismatch)
249 PrintLn("Warning: Incompatible value for array value, expected ", (String)arrayType.name);
251 else if(itemResult == noItem)
257 if(result != syntaxError)
259 if(ch != ']' && ch != ',')
269 result = syntaxError;
277 JSONResult GetMap(Class type, Map * map)
279 JSONResult result = syntaxError;
284 Class mapNodeType = type.templateArgs[0].dataTypeClass;
285 Class keyType = mapNodeType.templateArgs[0].dataTypeClass;
286 Property keyProp = null;
287 if(keyType && !strcmp(keyType.dataTypeString, "char *"))
288 keyProp = eClass_FindProperty(mapNodeType, "key", mapNodeType.module);
290 *map = eInstance_New(type);
297 JSONResult itemResult;
299 itemResult = GetValue(mapNodeType, value);
300 if(itemResult == success)
302 String s = keyProp ? ((void * (*)(void *))(void *)keyProp.Get)(value.p) : null;
303 ((void *(*)(void *, uint64))(void *)map->Add)(*map, (uint64)(uintptr)value.p);
304 // Must free String keys here
309 if(itemResult == typeMismatch)
312 PrintLn("Warning: Incompatible value for array value, expected ", (String)mapNodeType.name);
314 else if(itemResult == noItem)
320 if(result != syntaxError)
322 if(ch != ']' && ch != ',')
332 result = syntaxError;
340 JSONResult GetString(String * string)
342 JSONResult result = syntaxError;
343 Array<char> buffer { minAllocSize = 256 };
344 bool escaped = false;
352 if(ch == '\\' && !escaped)
358 if(ch == 'b') ch = '\b';
359 else if(ch == 'f') ch = '\f';
360 else if(ch == 'n') ch = '\n';
361 else if(ch == 'r') ch = '\r';
362 else if(ch == 't') ch = '\t';
379 if(buffer.minAllocSize < buffer.count)
380 buffer.minAllocSize *= 2;
384 *string = CopyString(buffer.array);
388 if(ch != ',' && ch != '}')
393 public JSONResult GetObject(Class objectType, void ** object)
395 JSONResult result = syntaxError;
396 if(!objectType || objectType.type != structClass)
401 Class mapKeyClass = null, mapDataClass = null;
403 if(objectType && objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
405 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
406 mapDataClass = objectType.templateArgs[2].dataTypeClass;
410 if(objectType && (objectType.type == noHeadClass || objectType.type == normalClass))
412 *object = eInstance_New(objectType);
414 else if(objectType && objectType.type != structClass)
416 *object = eSystem_New(objectType.typeSize);
423 if(GetString(&string))
425 DataMember member = null;
426 Property prop = null;
432 string[0] = (char)tolower(string[0]);
433 if(mapKeyClass && !strcmp(string, "key"))
435 prop = eClass_FindProperty(objectType, "key", objectType.module);
439 else if(mapDataClass && !strcmp(string, "value"))
441 prop = eClass_FindProperty(objectType, "value", objectType.module);
446 member = eClass_FindDataMember(objectType, string, objectType.module, null, null);
449 type = eSystem_FindClass(__thisModule, member.dataTypeString);
451 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
455 prop = eClass_FindProperty(objectType, string, objectType.module);
458 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
460 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
463 PrintLn("Warning: member ", string, " not found in class ", (String)objectType.name);
467 // Find Member in Object Class
471 if(type && type.type == structClass)
473 value.p = (byte *)*object + member._class.offset + member.offset;
479 JSONResult itemResult = GetValue(type, value);
480 if(itemResult != syntaxError)
486 PrintLn("warning: Unresolved data type ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
488 else if(itemResult == success)
493 // TOFIX: How to swiftly handle classes with base data type?
494 if(type.type == structClass)
496 else if(type.type == normalClass || type.type == noHeadClass)
498 void ** ptr = (void**)((byte *)*object + member._class.offset + member.offset);
499 if(eClass_IsDerived(type, class(Container)) && *ptr)
501 Container container = (Container)*ptr;
507 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
509 *(double *)((byte *)*object + member._class.offset + member.offset) = value.d;
511 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
513 *(float *)((byte *)*object + member._class.offset + member.offset) = value.f;
515 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
516 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
518 *(uint64 *)((byte *)*object + member._class.offset + member.offset) = value.ui64;
520 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
521 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
523 *(int *)((byte *)*object + member._class.offset + member.offset) = value.i;
525 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
526 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
527 !strcmp(type.dataTypeString, "int16"))
529 *(short *)((byte *)*object + member._class.offset + member.offset) = value.s;
531 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
532 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
534 *(char *)((byte *)*object + member._class.offset + member.offset) = value.c;
538 *(void **)((byte *)*object + member._class.offset + member.offset) = value.p;
541 else if(prop && prop.Set)
543 if(!strcmp(type.dataTypeString, "char *"))
545 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
549 // TOFIX: How to swiftly handle classes with base data type?
550 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
552 ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
554 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
556 ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
558 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
559 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
561 ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
563 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
564 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
566 ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
568 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
569 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
570 !strcmp(type.dataTypeString, "int16"))
572 ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
574 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
575 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
577 ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
581 ((void (*)(void *, void *))(void *)prop.Set)(*object, value.p);
587 PrintLn("Warning: Incompatible value for ", member ? (String)member.name : (String)prop.name,
588 ", expected ", member ? (String)member.dataTypeString : (String)prop.dataTypeString);
594 result = syntaxError;
597 else if(ch && ch != '}' && ch != ',')
598 result = syntaxError;
609 result = syntaxError;
617 JSONResult GetNumber(Class type, DataValue value)
619 JSONResult result = syntaxError;
622 while(c < sizeof(buffer)-1 && (ch == '-' || ch == '.' || tolower(ch) == 'e' || ch == '+' || isdigit(ch)))
625 if(!f.Getc(&ch)) break;
628 //if(strchr(buffer, '.'))
630 // TOFIX: How to swiftly handle classes with base data type?
631 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
633 value.d = strtod(buffer, null);
636 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
638 value.f = (float)strtod(buffer, null);
641 // TOFIX: int64 looks for class long long?
642 //else if(type == class(int64) || !strcmp(type.dataTypeString, "int64"))
643 else if(!strcmp(type.dataTypeString, "int64"))
645 value.i64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
648 else if(type == class(uint64) || !strcmp(type.dataTypeString, "uint64"))
650 value.ui64 = strtol(buffer, null, 10); // TOFIX: 64 bit support
655 value.i = strtol(buffer, null, 10);
662 bool WriteMap(File f, Class type, Map map, int indent)
668 MapIterator it { map = map };
669 Class mapNodeClass = map._class.templateArgs[0].dataTypeClass;
675 MapNode n = (MapNode)it.pointer;
680 for(i = 0; i<indent; i++) f.Puts(" ");
681 _WriteJSONObject(f, mapNodeClass, n, indent);
685 for(i = 0; i<indent; i++) f.Puts(" ");
693 bool WriteArray(File f, Class type, Container array, int indent)
699 Iterator it { array };
700 Class arrayType = type.templateArgs[0].dataTypeClass;
707 uint64 t = ((uint64(*)(void *, void *))(void *)array.GetData)(array, it.pointer);
714 // TODO: Verify the matching between template type and uint64
715 if(arrayType.type == structClass)
717 value.p = (void *)(uintptr)t;
719 else if(arrayType == class(double) || !strcmp(arrayType.dataTypeString, "double"))
721 value.d = *(double *)&t;
723 else if(arrayType == class(float) || !strcmp(arrayType.dataTypeString, "float"))
725 value.f = *(float *)&t;
727 else if(arrayType.typeSize == sizeof(int64) || !strcmp(arrayType.dataTypeString, "int64") ||
728 !strcmp(arrayType.dataTypeString, "unsigned int64") || !strcmp(arrayType.dataTypeString, "uint64"))
732 else if(arrayType.typeSize == sizeof(int) || !strcmp(arrayType.dataTypeString, "int") ||
733 !strcmp(arrayType.dataTypeString, "unsigned int") || !strcmp(arrayType.dataTypeString, "uint"))
737 else if(arrayType.typeSize == sizeof(short int) || !strcmp(arrayType.dataTypeString, "short") ||
738 !strcmp(arrayType.dataTypeString, "unsigned short") || !strcmp(arrayType.dataTypeString, "uint16") ||
739 !strcmp(arrayType.dataTypeString, "int16"))
743 else if(arrayType.typeSize == sizeof(byte) || !strcmp(arrayType.dataTypeString, "char") ||
744 !strcmp(arrayType.dataTypeString, "unsigned char") || !strcmp(arrayType.dataTypeString, "byte"))
750 value.p = (void *)(uintptr)t;
752 for(i = 0; i<indent; i++) f.Puts(" ");
753 WriteValue(f, arrayType, value, indent);
757 for(i = 0; i<indent; i++) f.Puts(" ");
765 bool WriteNumber(File f, Class type, DataValue value, int indent)
768 bool needClass = false;
770 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
771 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.d, buffer, 0, &needClass);
772 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
773 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.f, buffer, null, &needClass);
774 else if(!strcmp(type.dataTypeString, "int64"))
775 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i64, buffer, null, &needClass);
776 else if(!strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64") || type.typeSize == sizeof(int64))
777 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui64, buffer, null, &needClass);
778 else if(!strcmp(type.dataTypeString, "int"))
779 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.i, buffer, null, &needClass);
780 else if(!strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint") || type.typeSize == sizeof(int))
781 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.ui, buffer, null, &needClass);
782 else if(!strcmp(type.dataTypeString, "short") || !strcmp(type.dataTypeString, "int16"))
783 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.s, buffer, null, &needClass);
784 else if(!strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") || type.typeSize == sizeof(short int))
785 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.us, buffer, null, &needClass);
786 else if(!strcmp(type.dataTypeString, "char"))
787 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.c, buffer, null, &needClass);
788 else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
789 ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
794 bool WriteValue(File f, Class type, DataValue value, int indent)
796 if(!strcmp(type.name, "String") || !strcmp(type.dataTypeString, "char *"))
803 //if(strchr(value.p, '\"') || strchr(value.p, '\\'))
808 char * string = value.p;
827 else if(b == sizeof(buffer)-2 || !ch)
830 if(ch) buffer[b] = 0;
844 else if(!strcmp(type.name, "bool"))
851 else if(!strcmp(type.name, "SetBool"))
853 if(value.i == SetBool::true)
855 else if(value.i == SetBool::false)
860 else if(type.type == enumClass || type.type == unitClass)
863 WriteNumber(f, type, value, indent);
866 else if(eClass_IsDerived(type, class(Map)))
868 WriteMap(f, type, value.p, indent);
870 else if(eClass_IsDerived(type, class(Container)))
872 WriteArray(f, type, value.p, indent);
874 else if(type.type == normalClass || type.type == noHeadClass || type.type == structClass || type.type == bitClass)
876 _WriteJSONObject(f, type, value.p, indent);
878 else if(type.type == systemClass)
880 WriteNumber(f, type, value, indent);
885 public bool WriteJSONObject(File f, Class objectType, void * object, int indent)
890 result = _WriteJSONObject(f, objectType, object, indent);
896 static bool _WriteJSONObject(File f, Class objectType, void * object, int indent)
900 const char * string = null;
902 if(objectType._vTbl[__ecereVMethodID_class_OnGetString] != objectType.base._vTbl[__ecereVMethodID_class_OnGetString])
906 string = ((const char *(*)())(void *)objectType._vTbl[__ecereVMethodID_class_OnGetString])(objectType, object, buffer, null, null);
910 // TOCHECK: ProjectNode.ec why do we add quotes in OnGetString there?
911 if(string[0] == '\"')
925 Class mapKeyClass = null, mapDataClass = null;
927 if(objectType.templateClass && eClass_IsDerived(objectType.templateClass, class(MapNode)))
929 mapKeyClass = objectType.templateArgs[0].dataTypeClass;
930 mapDataClass = objectType.templateArgs[2].dataTypeClass;
936 for(prop = objectType.membersAndProperties.first; prop; prop = prop.next)
938 if(prop.memberAccess != publicAccess || (prop.isProperty && (!prop.Set || !prop.Get))) continue;
941 if(!prop.conversion && (!prop.IsSet || prop.IsSet(object)))
946 if(mapKeyClass && !strcmp(prop.name, "key"))
948 else if(mapDataClass && !strcmp(prop.name, "value"))
951 type = eSystem_FindClass(__thisModule, prop.dataTypeString);
953 type = eSystem_FindClass(__thisModule.application, prop.dataTypeString);
955 PrintLn("warning: Unresolved data type ", (String)prop.dataTypeString);
958 // TOFIX: How to swiftly handle classes with base data type?
959 if(type == class(double) || !strcmp(type.dataTypeString, "double"))
961 value.d = ((double (*)(void *))(void *)prop.Get)(object);
963 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
965 value.f = ((float (*)(void *))(void *)prop.Get)(object);
967 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
968 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
970 value.ui64 = ((uint64 (*)(void *))(void *)prop.Get)(object);
972 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
973 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
975 value.i = ((int (*)(void *))(void *)prop.Get)(object);
977 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
978 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
979 !strcmp(type.dataTypeString, "int16"))
981 value.s = ((short (*)(void *))(void *)prop.Get)(object);
983 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
984 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
986 value.c = ((char (*)(void *))(void *)prop.Get)(object);
990 value.p = ((void *(*)(void *))(void *)prop.Get)(object);
993 if(!isFirst) f.Puts(",\n");
994 for(c = 0; c<indent; c++) f.Puts(" ");
997 f.Putc((char)toupper(prop.name[0]));
1000 WriteValue(f, type, value, indent);
1007 DataMember member = (DataMember)prop;
1008 DataValue value { };
1009 Class type = eSystem_FindClass(__thisModule, member.dataTypeString);
1011 type = eSystem_FindClass(__thisModule.application, member.dataTypeString);
1015 if(type.type == normalClass || type.type == noHeadClass || type.type == structClass || !strcmp(type.name, "String"))
1017 if(type.type == structClass)
1018 value.p = (void *)((byte *)object + member._class.offset + member.offset);
1020 value.p = *(void **)((byte *)object + member._class.offset + member.offset);
1024 else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
1026 value.d = *(double *)((byte *)object + member._class.offset + member.offset);
1028 else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
1030 value.f = *(float *)((byte *)object + member._class.offset + member.offset);
1032 else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
1033 !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
1035 value.ui64 = *(uint64 *)((byte *)object + member._class.offset + member.offset);
1037 else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
1038 !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
1040 value.i = *(int *)((byte *)object + member._class.offset + member.offset);
1041 if(!strcmp(type.name, "bool") || type.type == enumClass)
1045 else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
1046 !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
1047 !strcmp(type.dataTypeString, "int16"))
1049 value.s = *(short *)((byte *)object + member._class.offset + member.offset);
1051 else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
1052 !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
1054 value.c = *(char *)((byte *)object + member._class.offset + member.offset);
1058 value.i = *(int *)((byte *)object + member._class.offset + member.offset);
1061 if(!isFirst) f.Puts(",\n");
1062 for(c = 0; c<indent; c++) f.Puts(" ");
1065 f.Putc((char)toupper(member.name[0]));
1066 f.Puts(member.name+1);
1068 WriteValue(f, type, value, indent);
1076 for(c = 0; c<indent; c++) f.Puts(" "); f.Puts("}");