{
case Dali::Property::BOOLEAN:
case Dali::Property::INTEGER:
- case Dali::Property::UNSIGNED_INTEGER:
case Dali::Property::STRING:
case Dali::Property::FLOAT:
{
v8Value = v8::Integer::New( isolate, value.Get<int>());
break;
}
- case Dali::Property::UNSIGNED_INTEGER:
- {
- v8Value = v8::Integer::New( isolate, value.Get<unsigned int>());
- break;
- }
case Dali::Property::STRING:
{
std::string string = value.Get< std::string >();
break;
}
}
- v8::Local<v8::Object> ret = v8Value->ToObject();
- return handleScope.Escape( ret );
+ v8::Local<v8::Object> ret;
+
+ if( v8Value->IsObject() )
+ {
+ ret = v8Value->ToObject();
+ }
+
+ return handleScope.Escape( ret );
}
}
if(16 == len )
{
- ret = Dali::Matrix( out[0] );
+ ret = Dali::Matrix( out );
}
else if ( 9 == len )
{
{
daliPropertyValue = Dali::Property::Value( v8Value->Int32Value() ) ;//static_cast<int>( V8Utils::GetNumberValue( isolate, v8Value) ));
}
- break;
- }
- case Dali::Property::UNSIGNED_INTEGER:
- {
- if( v8Value->IsUint32() )
+ else if( V8Utils::IsStringPrimitiveOrObject( v8Value) ) // Take string as value for properties that internally convert the string to an enum
{
- daliPropertyValue = Dali::Property::Value( v8Value->Uint32Value() );//static_cast<unsigned int>( V8Utils::GetNumberValue( isolate, v8Value) ));
+ daliPropertyValue = Dali::Property::Value( V8Utils::GetStringValue( isolate, v8Value) );
}
break;
}
daliPropertyValue = ArrayFromV8Array( isolate, v8Value );
break;
}
+ case Dali::Property::MAP:
+ {
+ if( v8Value->IsObject() )
+ {
+ v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(v8Value);
+ Dali::Property::Map propertyMap = V8Utils::GetPropertyMapFromObject(isolate, object);
+ daliPropertyValue = Dali::Property::Value( propertyMap );
+ }
+ else if( V8Utils::IsStringPrimitiveOrObject( v8Value) )
+ {
+ // There are special cases where a property with property map type can accept a string value,
+ // so we do the additional check here.
+ daliPropertyValue = Dali::Property::Value( V8Utils::GetStringValue( isolate, v8Value) );
+ }
+
+ break;
+ }
case Dali::Property::NONE:
default:
{
break;
}
- } // switch type
+ } // switch type
+
+ return daliPropertyValue;
+}
+
+Dali::Property::Value PropertyValueWrapper::ExtractPropertyValue( v8::Isolate* isolate, v8::Local< v8::Value> v8Value)
+{
+ v8::HandleScope handleScope( isolate);
+
+ Dali::Property::Value daliPropertyValue;
+
+ // Check if it's a javascript Array
+ Dali::Property::Value array = VectorOrMatrixFromV8Array( isolate, v8Value );
+
+ if( V8Utils::IsBooleanPrimitiveOrObject( v8Value ) )
+ {
+ daliPropertyValue = Dali::Property::Value( V8Utils::GetBooleanValue( isolate, v8Value));
+ }
+ else if( V8Utils::IsNumberPrimitiveOrObject( v8Value ) )
+ {
+ daliPropertyValue = Dali::Property::Value( V8Utils::GetNumberValue( isolate, v8Value) );
+ }
+ else if( v8Value->IsInt32() )
+ {
+ daliPropertyValue = Dali::Property::Value( v8Value->Int32Value() ) ;
+ }
+ else if( V8Utils::IsStringPrimitiveOrObject( v8Value) )
+ {
+ daliPropertyValue = Dali::Property::Value( V8Utils::GetStringValue( isolate, v8Value) );
+ }
+ else if( array.GetType() == Dali::Property::VECTOR2
+ || array.GetType() == Dali::Property::VECTOR3
+ || array.GetType() == Dali::Property::VECTOR4 )
+ {
+ daliPropertyValue = array;
+ }
+ else if( array.GetType() == Dali::Property::MATRIX )
+ {
+ Dali::Matrix mat = array.Get<Dali::Matrix>();
+ daliPropertyValue = mat;
+ }
+ else if( array.GetType() == Dali::Property::MATRIX3 )
+ {
+ Dali::Matrix3 mat = array.Get<Dali::Matrix3>();
+ daliPropertyValue = mat;
+ }
+ else if( array.GetType() == Dali::Property::ARRAY )
+ {
+ daliPropertyValue = ArrayFromV8Array( isolate, v8Value );
+ }
+ else if( v8Value->IsObject() )
+ {
+ // Assume this is a property map
+ v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(v8Value);
+ Dali::Property::Map propertyMap = V8Utils::GetPropertyMapFromObject(isolate, object);
+ daliPropertyValue = Dali::Property::Value( propertyMap );
+ }
- return daliPropertyValue;
+ return daliPropertyValue;
}
void PropertyValueWrapper::NewRotation( const v8::FunctionCallbackInfo< v8::Value >& args)