cwObject.h/cpp : cwObject now detects and properly encodes floats and unsigned integers that are specified with the 'f' and 'u' suffix.

This commit is contained in:
kevin 2024-04-26 16:59:40 -04:00
parent e42dd71b09
commit a7a38fa9f4
2 changed files with 14 additions and 2 deletions

View File

@ -869,11 +869,17 @@ cw::rc_t cw::objectFromString( const char* s, object_t*& objRef )
break;
case lex::kRealLexTId:
_objCreateValueNode( cnp, lex::tokenDouble(lexH), "real" );
if( tokenIsSinglePrecision(lexH) )
_objCreateValueNode( cnp, lex::tokenFloat(lexH),"float" );
else
_objCreateValueNode( cnp, lex::tokenDouble(lexH), "double" );
break;
case lex::kIntLexTId:
_objCreateValueNode( cnp, lex::tokenInt(lexH), "int" );
if( tokenIsUnsigned(lexH) )
_objCreateValueNode( cnp, lex::tokenUInt(lexH), "uint" );
else
_objCreateValueNode( cnp, lex::tokenInt(lexH), "int" );
break;
case lex::kHexLexTId:

View File

@ -74,6 +74,12 @@ namespace cw
return obj;
}
template<> object_t* _objSetLeafValue<float>( object_t* obj, float value )
{
obj->u.f = value;
obj->type = _objIdToType(kFloatTId);
return obj;
}
template<> object_t* _objSetLeafValue<double>( object_t* obj, double value )
{