X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Futils%2Fv8-utils.cpp;h=4d09da99bd8566168959baacae09dfd2601d46d9;hb=4bf366c7c657eacb5cf150fa52e34263ca16218f;hp=346619852b606f46dd82d9a22a38df719b956e06;hpb=da7bba2130b0b15f9d93d63b2404b8888af2c85b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/plugins/dali-script-v8/src/utils/v8-utils.cpp b/plugins/dali-script-v8/src/utils/v8-utils.cpp index 3466198..4d09da9 100644 --- a/plugins/dali-script-v8/src/utils/v8-utils.cpp +++ b/plugins/dali-script-v8/src/utils/v8-utils.cpp @@ -268,42 +268,6 @@ std::string PropertyNameToJavaScriptName(const std::string& hyphenatedName) -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); @@ -390,7 +354,7 @@ Property::Value GetPropertyValueFromObject( bool& found, v8::Isolate* isolate, c { v8::HandleScope handleScope( isolate); - Property::Value daliPropertyValue;// creates a property with Property::INVALID + Property::Value daliPropertyValue;// creates a property with Property::NONE found = false; @@ -445,11 +409,41 @@ Property::Map GetPropertyMapFromObject( v8::Isolate* isolate, const v8::Local value = object->Get( key ); - std::string valueString = V8Utils::v8StringToStdString( value ); - - propertyMap[ keyString ] = valueString.c_str(); + if( value->IsBoolean() ) + { + v8::Local v = value->ToBoolean(); + propertyMap[ keyString ] = v->Value(); + } + else if( value->IsNumber() ) + { + v8::Local v = value->ToNumber(); + propertyMap[ keyString ] = static_cast(v->Value()); + } + else if( value->IsInt32() || value->IsUint32() ) + { + v8::Local v = value->ToInt32(); + propertyMap[ keyString ] = static_cast(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; } @@ -480,6 +474,7 @@ int GetIntegerParameter( unsigned int index, bool& found, v8::Isolate* isolate, found = true; return args[ index ]->Int32Value(); } + else { return defaultValue; } @@ -498,6 +493,7 @@ float GetFloatParameter( unsigned int index, bool& found, v8::Isolate* isolate, found = true; return args[ index ]->NumberValue(); } + else { return defaultValue; } @@ -545,6 +541,24 @@ bool GetBooleanParameter( unsigned int index, bool& found, v8::Isolate* isolate, } } +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 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); @@ -765,6 +779,7 @@ Image GetImageParameter( unsigned int index, bool& found, v8::Isolate* isolate, } } + RenderTask GetRenderTaskParameter( unsigned int paramIndex, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) { found = false; @@ -781,7 +796,6 @@ RenderTask GetRenderTaskParameter( unsigned int paramIndex, bool& found, v8::Iso } } - BaseWrappedObject* GetWrappedDaliObjectParameter( unsigned int index, BaseWrappedObject::Type type, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args ) { v8::HandleScope handleScope( isolate);