X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Futils%2Fv8-utils.cpp;h=f843d1d8e8910e67a71ef7c45e68dbecdef932bf;hb=8c31a5ca493d17693e53f9909a4453b1fa058ab3;hp=d9fbc7ec10963416b9486370bd450be42062065d;hpb=5ed52cca615ac0b47dd0d909821a051fbfa8234a;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 d9fbc7e..f843d1d 100644 --- a/plugins/dali-script-v8/src/utils/v8-utils.cpp +++ b/plugins/dali-script-v8/src/utils/v8-utils.cpp @@ -64,7 +64,7 @@ void Log(const v8::FunctionCallbackInfo< v8::Value >& args) std::cout << " "; } v8::String::Utf8Value utf8_value( args[i] ); - std::cout << *utf8_value; + std::cout << *utf8_value << "\n"; } } @@ -85,6 +85,7 @@ void LogError(const v8::FunctionCallbackInfo< v8::Value >& args) } v8::String::Utf8Value utf8_value( args[i] ); output += *utf8_value; + output +="\n"; } DALI_LOG_ERROR_NOFN( "JavaScript: %s",output.c_str() ); } @@ -389,7 +390,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; @@ -421,18 +422,12 @@ Property::Value GetPropertyValueFromObject( bool& found, v8::Isolate* isolate, c v8::Local v = value->ToNumber(); return Dali::Property::Value(static_cast(v->Value())); } - else if( value->IsInt32() ) + else if( value->IsInt32() || value->IsUint32() ) { found = true; v8::Local v = value->ToInt32(); return Dali::Property::Value(static_cast(v->Value())); } - else if ( value->IsUint32() ) - { - found = true; - v8::Local v = value->ToUint32(); - return Dali::Property::Value(static_cast(v->Value())); - } return daliPropertyValue; } @@ -450,11 +445,33 @@ 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); + } } + return propertyMap; } @@ -485,6 +502,7 @@ int GetIntegerParameter( unsigned int index, bool& found, v8::Isolate* isolate, found = true; return args[ index ]->Int32Value(); } + else { return defaultValue; } @@ -503,6 +521,7 @@ float GetFloatParameter( unsigned int index, bool& found, v8::Isolate* isolate, found = true; return args[ index ]->NumberValue(); } + else { return defaultValue; } @@ -550,6 +569,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); @@ -770,6 +807,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; @@ -786,7 +824,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); @@ -893,11 +930,6 @@ void CreatePropertyMap( v8::Isolate* isolate, const Property::Map& map, v8::Loca v8Value = v8::Integer::New( isolate, value.Get()); break; } - case Dali::Property::UNSIGNED_INTEGER: - { - v8Value = v8::Integer::New( isolate, value.Get()); - break; - } case Dali::Property::STRING: { std::string string = value.Get< std::string >();