Exemplo n.º 1
0
int mesage_Field(lua_State* L){
	CString type = luaL_typename(L, 2);
	CMessage* msg = cmessage_arg(L, "mesage_Field");
	CDatum* d;
	if(type == "string")
		d = msg->GetDatum(luaL_checkstring(L, 2));
	else
		d = msg->GetDatum(luaL_checkint(L, 2));

	if (!d) return 0;
	switch (d->GetVarType())
	{
	case VT_R8:
	{
		double i;
		d->GetValueAsDouble(i);
		lua_pushnumber(L, i);
	}
		break;
	case VT_I4:
	{
		long i;
		d->GetValueAsLong(i);
		lua_pushinteger(L, i);
	}
		break;
	case VT_BOOL:
	{
		bool i;
		d->GetValueAsBool(i);
		lua_pushboolean(L, i);
	}
		break;
	case VT_BSTR:
	case VT_DATE:
		lua_pushstring(L, d->GetValueText());
		break;
	default:
		lua_pushnil(L);
	}
	return 1;
}
Exemplo n.º 2
0
int mesage_GetPathValue(lua_State* L)
{
	CString path = luaL_checkstring(L,2);
	CMessage* msg = cmessage_arg(L,"mesage_GetPathValue");
	CDatum* d = msg->GetDatumByPath(path);
	if(!d) return 0;
	switch(d->GetVarType())
	{
	case VT_R8:
		{
			double i;
			d->GetValueAsDouble(i);
			lua_pushnumber(L, i);
		}
		break;
	case VT_I4:
		{
			long i;
			d->GetValueAsLong(i);
			lua_pushinteger(L, i);
		}
		break;
	case VT_BOOL:
		{
			bool i;
			d->GetValueAsBool(i);
			lua_pushboolean(L, i);
		}
		break;
	case VT_BSTR:
	case VT_DATE:
		lua_pushstring(L, d->GetValueText());
		break;
	default:
		lua_pushnil(L);
	}
	return 1;
}