std::cout << " ";
}
v8::String::Utf8Value utf8_value( args[i] );
- std::cout << *utf8_value;
+ std::cout << *utf8_value << "\n";
}
}
}
v8::String::Utf8Value utf8_value( args[i] );
output += *utf8_value;
+ output +="\n";
}
DALI_LOG_ERROR_NOFN( "JavaScript: %s",output.c_str() );
}
}
}
+bool IsPropertyMapIdentical(Property::Map map1, Property::Map map2)
+{
+ bool dirty = false;
+
+ // Compare number of properties
+ if ( map1.Count() != map2.Count() )
+ {
+ dirty = true;
+ }
+ else
+ {
+ for ( unsigned int i = 0, count = map1.Count(); i < count; ++i )
+ {
+ // Compare the key first
+ if(map1.GetKey(i) != map2.GetKey(i))
+ {
+ dirty = true;
+ }
+ else
+ {
+ Property::Value& value = map1.GetValue(i);
+ Property::Value& newValue = map2.GetValue(i);
+
+ // Compare the value type
+ if(value.GetType() != newValue.GetType())
+ {
+ dirty = true;
+ }
+ else
+ {
+ // Compare the value
+ switch( value.GetType() )
+ {
+ case Property::BOOLEAN:
+ {
+ dirty = ( value.Get<bool>() != newValue.Get<bool>() );
+ break;
+ }
+ case Property::FLOAT:
+ {
+ dirty = ( value.Get<float>() != newValue.Get<float>() );
+ break;
+ }
+ case Property::INTEGER:
+ {
+ dirty = ( value.Get<int>() != newValue.Get<int>() );
+ break;
+ }
+ case Property::RECTANGLE:
+ {
+ dirty = ( value.Get< Rect<int> >() != newValue.Get< Rect<int> >() );
+ break;
+ }
+ case Property::VECTOR2:
+ {
+ dirty = ( value.Get<Vector2>() != newValue.Get<Vector2>() );
+ break;
+ }
+ case Property::VECTOR3:
+ {
+ dirty = ( value.Get<Vector3>() != newValue.Get<Vector3>() );
+ break;
+ }
+ case Property::VECTOR4:
+ {
+ dirty = ( value.Get<Vector4>() != newValue.Get<Vector4>() );
+ break;
+ }
+ case Property::MATRIX3:
+ {
+ dirty = ( value.Get<Matrix3>() != newValue.Get<Matrix3>() );
+ break;
+ }
+ case Property::MATRIX:
+ {
+ dirty = ( value.Get<Matrix>() != newValue.Get<Matrix>() );
+ break;
+ }
+ case Property::ROTATION:
+ {
+ dirty = ( value.Get<Quaternion>() != newValue.Get<Quaternion>() );
+ break;
+ }
+ case Property::STRING:
+ {
+ dirty = ( value.Get<std::string>() != newValue.Get<std::string>() );
+ break;
+ }
+ case Property::MAP:
+ {
+ dirty = ( !IsPropertyMapIdentical( value.Get<Property::Map>(), newValue.Get<Property::Map>() ) );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ if(dirty)
+ {
+ // Different already, no need any further comparison
+ break;
+ }
+ }
+ }
+
+ return !dirty;
+}
+
void ReportException( v8::Isolate* isolate, v8::TryCatch* tryCatch)
{
v8::HandleScope handleScope( isolate );
-std::string JavaScriptNameToPropertyName(const std::string& camelCase)
-{
- std::string ret;
-
- int countUpper = 0;
- for(unsigned int i = 0; i < camelCase.size(); ++i)
- {
- if(std::isupper(camelCase[i]))
- {
- countUpper++;
- }
- }
-
- if(countUpper)
- {
- ret.reserve(camelCase.size() + countUpper);
-
- for(unsigned int i = 0; i < camelCase.size(); ++i)
- {
- char c = camelCase[i];
- if(std::isupper(c))
- {
- ret.push_back('-');
- }
-
- ret.push_back(std::tolower(c));
- }
- }
- else
- {
- return camelCase ;
- }
-
- return ret;
-}
-
void ScriptError( const char* function, v8::Isolate* isolate, std::string errorString )
{
v8::EscapableHandleScope scope( isolate);
{
v8::HandleScope handleScope( isolate);
- Property::Value daliPropertyValue;// creates a property with Property::INVALID
+ Property::Value daliPropertyValue;// creates a property with Property::NONE
found = false;
v8::Local<v8::Number> v = value->ToNumber();
return Dali::Property::Value(static_cast<float>(v->Value()));
}
- else if( value->IsInt32() )
+ else if( value->IsInt32() || value->IsUint32() )
{
found = true;
v8::Local<v8::Int32> v = value->ToInt32();
return Dali::Property::Value(static_cast<int>(v->Value()));
}
- else if ( value->IsUint32() )
- {
- found = true;
- v8::Local<v8::Uint32> v = value->ToUint32();
- return Dali::Property::Value(static_cast<unsigned int>(v->Value()));
- }
return daliPropertyValue;
}
// Get the value
v8::Local<v8::Value> value = object->Get( key );
- std::string valueString = V8Utils::v8StringToStdString( value );
-
- propertyMap[ keyString ] = valueString.c_str();
+ if( value->IsBoolean() )
+ {
+ v8::Local<v8::Boolean> v = value->ToBoolean();
+ propertyMap[ keyString ] = v->Value();
+ }
+ else if( value->IsNumber() )
+ {
+ v8::Local<v8::Number> v = value->ToNumber();
+ propertyMap[ keyString ] = static_cast<float>(v->Value());
+ }
+ else if( value->IsInt32() || value->IsUint32() )
+ {
+ v8::Local<v8::Int32> v = value->ToInt32();
+ propertyMap[ keyString ] = static_cast<int>(v->Value());
+ }
+ else if( value->IsString() )
+ {
+ std::string valueString = V8Utils::v8StringToStdString( value );
+ propertyMap[ keyString ] = valueString.c_str();
+ }
+ else if( value->IsArray() )
+ {
+ propertyMap[ keyString ] = PropertyValueWrapper::VectorOrMatrixFromV8Array( isolate, value);
+ }
+ else if( value->IsObject() )
+ {
+ Dali::Property::Map map = V8Utils::GetPropertyMapFromObject(isolate, value->ToObject());
+ if( !map.Empty() )
+ {
+ propertyMap[ keyString ] = Dali::Property::Value( map );
+ }
+ }
}
+
return propertyMap;
}
found = true;
return args[ index ]->Int32Value();
}
+ else
{
return defaultValue;
}
found = true;
return args[ index ]->NumberValue();
}
+ else
{
return defaultValue;
}
}
}
+void* GetArrayBufferViewParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+ unsigned int length = args.Length();
+ if( index < length && args[index]->IsArrayBufferView() )
+ {
+ found = true;
+ v8::ArrayBufferView* bufferView = v8::ArrayBufferView::Cast(*(args[index]));
+ v8::Handle<v8::ArrayBuffer> buffer = bufferView->Buffer();
+ v8::ArrayBuffer::Contents contents = buffer->Externalize();
+ return contents.Data();
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
Handle GetHandleParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::HandleScope handleScope( isolate);
}
}
+
RenderTask GetRenderTaskParameter( unsigned int paramIndex, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
{
found = false;
}
}
-
BaseWrappedObject* GetWrappedDaliObjectParameter( unsigned int index, BaseWrappedObject::Type type, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::HandleScope handleScope( isolate);
return;
}
- for( unsigned int index = 0; index < map.Count() - 1; ++index )
+ for( unsigned int index = 0; index < map.Count(); ++index )
{
const std::string& key = map.GetKey( index );
Property::Value& value = map.GetValue( index );
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 >();