Ejemplo n.º 1
0
int Conv::GetNaturalType(Handle<Value> val) {
  if(val.IsEmpty()) return TYPE_INVALID;
  if(val->IsUndefined()) return TYPE_UNDEFINED;
  if(val->IsNull()) return TYPE_NULL;
  if(val->IsBoolean() || val->IsBooleanObject()) return TYPE_BOOL;
  if(val->IsInt32()) return TYPE_INT;
  if(val->IsUint32()) return TYPE_LONG;
  if(val->IsNumber() || val->IsNumberObject()) return TYPE_DOUBLE;
  if(val->IsString() || val->IsStringObject()) return TYPE_STRING;
  return GetNaturalType(Handle<Object>::Cast(val));
}
Ejemplo n.º 2
0
jstring tns::ConvertToJavaString(const Handle<Value>& value)
{
	Handle<String> valueAsString;
	if (value->IsStringObject())
	{
		auto stringObject = Handle<StringObject>::Cast(value);
		valueAsString = stringObject->ValueOf();
	}
	else
	{
		valueAsString = value->ToString();
	}

	JEnv env;
	String::Value stringValue(valueAsString);
	return env.NewString((const jchar*)*stringValue, valueAsString->Length());
}