{
value.p = string;
}
- else if(type && (type.type == enumClass /*|| type.type == unitClass*/))
+ else if(type && (type.type == enumClass || type.type == unitClass))
{
if(((bool (*)(void *, void *, const char *))(void *)type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(type, &value.i, string))
result = success;
}
else if(!strcmpi(buffer, "null"))
{
- value.p = 0;
+ if(type.type != structClass)
+ value.p = 0;
}
else
result = typeMismatch;
if(!isKey)
delete value.p;
}
- // TOFIX: How to swiftly handle classes with base data type?
- else if(type == class(double) || !strcmp(type.dataTypeString, "double"))
- {
- ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
- }
- else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
+ else if(type.type == enumClass || type.type == bitClass || type.type == unitClass || type.type == systemClass)
{
- ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
- }
- else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
- !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
- {
- ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
- }
- else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
- !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
- {
- ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
- }
- else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
- !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
- !strcmp(type.dataTypeString, "int16"))
- {
- ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
- }
- else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
- !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
- {
- ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
+ // TOFIX: How to swiftly handle classes with base data type?
+ if(type == class(double) || !strcmp(type.dataTypeString, "double"))
+ {
+ ((void (*)(void *, double))(void *)prop.Set)(*object, value.d);
+ }
+ else if(type == class(float) || !strcmp(type.dataTypeString, "float"))
+ {
+ ((void (*)(void *, float))(void *)prop.Set)(*object, value.f);
+ }
+ else if(type.typeSize == sizeof(int64) || !strcmp(type.dataTypeString, "int64") ||
+ !strcmp(type.dataTypeString, "unsigned int64") || !strcmp(type.dataTypeString, "uint64"))
+ {
+ ((void (*)(void *, uint64))(void *)prop.Set)(*object, value.ui64);
+ }
+ else if(type.typeSize == sizeof(int) || !strcmp(type.dataTypeString, "int") ||
+ !strcmp(type.dataTypeString, "unsigned int") || !strcmp(type.dataTypeString, "uint"))
+ {
+ ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
+ }
+ else if(type.typeSize == sizeof(short int) || !strcmp(type.dataTypeString, "short") ||
+ !strcmp(type.dataTypeString, "unsigned short") || !strcmp(type.dataTypeString, "uint16") ||
+ !strcmp(type.dataTypeString, "int16"))
+ {
+ ((void (*)(void *, short))(void *)prop.Set)(*object, value.s);
+ }
+ else if(type.typeSize == sizeof(byte) || !strcmp(type.dataTypeString, "char") ||
+ !strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte"))
+ {
+ ((void (*)(void *, char))(void *)prop.Set)(*object, value.c);
+ }
+ else
+ {
+ ((void (*)(void *, int))(void *)prop.Set)(*object, value.i);
+ }
}
else
{
}
buffer[c] = 0;
//if(strchr(buffer, '.'))
+ if(!type) return success;
// TOFIX: How to swiftly handle classes with base data type?
if(type == class(double) || !strcmp(type.dataTypeString, "double"))
}
else if(type == class(uint) || !strcmp(type.dataTypeString, "unsigned int"))
{
- value.ui = strtoul(buffer, null, 10); // TOFIX: 64 bit support
+ value.ui = (uint)strtoul(buffer, null, 10); // TOFIX: 64 bit support
result = success;
}
else
{
- value.i = strtol(buffer, null, 10);
+ value.i = (int)strtol(buffer, null, 10);
result = success;
}
{
char buffer[1024];
bool needClass = false;
+ bool quote;
buffer[0] = 0;
if(type == class(double) || !strcmp(type.dataTypeString, "double"))
((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.d, buffer, 0, &needClass);
((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.c, buffer, null, &needClass);
else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
+
+ quote = (type.type == unitClass && ((buffer[0] != '.' && !isdigit(buffer[0])) || strchr(buffer, ' ')));
+ if(quote) f.Puts("\"");
f.Puts(buffer);
+ if(quote) f.Puts("\"");
return true;
}
else
f.Puts("unset");
}
- else if(type.type == enumClass) // || type.type == unitClass)
+ else if(type.type == enumClass)
{
f.Puts("\"");
WriteNumber(f, type, value, indent);