X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fdali-script-v8%2Fsrc%2Fobject%2Fproperty-buffer-api.cpp;h=46de3b3bd48829b46e0ab64a44a737701edb0e0f;hb=1dbb50c7c99eef4f1771787bbf97bbb023a49c91;hp=dabaaf6323eb6b1969156fc687236b83e2ca3d86;hpb=8c31a5ca493d17693e53f9909a4453b1fa058ab3;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/plugins/dali-script-v8/src/object/property-buffer-api.cpp b/plugins/dali-script-v8/src/object/property-buffer-api.cpp index dabaaf6..46de3b3 100644 --- a/plugins/dali-script-v8/src/object/property-buffer-api.cpp +++ b/plugins/dali-script-v8/src/object/property-buffer-api.cpp @@ -34,18 +34,15 @@ namespace // unnamed namespace struct PropertyBufferParameters { PropertyBufferParameters() - : mSize( 0 ) { } PropertyBuffer NewPropertyBuffer() { - return PropertyBuffer::New( mBufferFormat, - mSize); + return PropertyBuffer::New( mBufferFormat ); } Property::Map mBufferFormat; - std::size_t mSize; }; } // unnamed space @@ -119,8 +116,8 @@ PropertyBuffer PropertyBufferApi::GetPropertyBufferFromParams( int paramIndex, * @constructor * @for PropertyBuffer * @method PropertyBuffer - * @param {Object} bufferFormat - * @param {integer} size + * @param {Object} bufferFormat Map of names and types that describes the components of the buffer + * @param {integer} size The number of elements in the property buffer * @return {Object} PropertyBuffer * @example *``` @@ -145,15 +142,7 @@ PropertyBuffer PropertyBufferApi::New( v8::Isolate* isolate, const v8::FunctionC return PropertyBuffer(); } - found = false; - int size = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0); - if( !found ) - { - DALI_SCRIPT_EXCEPTION( isolate, "missing buffer size from param 1" ); - return PropertyBuffer(); - } - - return PropertyBuffer::New(bufferFormat, static_cast(size)); + return PropertyBuffer::New( bufferFormat ); } /** @@ -165,7 +154,7 @@ PropertyBuffer PropertyBufferApi::New( v8::Isolate* isolate, const v8::FunctionC * * @method setData * @for PropertyBuffer - * @param {Object} data The data that will be copied to the buffer. + * @param {Float32Array} data The data that will be copied to the buffer. * @example *``` * var vertexData = [ 0, 1, @@ -177,7 +166,7 @@ PropertyBuffer PropertyBufferApi::New( v8::Isolate* isolate, const v8::FunctionC * var vertexDataArray = new Float32Array(vertexData.length); * vertexDataArray.set(vertexData, 0); * - * propertyBuffer.setData( vertexDataArray ); + * propertyBuffer.setData( vertexDataArray, vertexData.length ); *``` */ void PropertyBufferApi::SetData( const v8::FunctionCallbackInfo< v8::Value >& args ) @@ -189,13 +178,22 @@ void PropertyBufferApi::SetData( const v8::FunctionCallbackInfo< v8::Value >& ar bool found( false ); void* data = V8Utils::GetArrayBufferViewParameter( PARAMETER_0, found, isolate, args); - if( !found ) + + if( ! found ) { DALI_SCRIPT_EXCEPTION( isolate, "invalid data parameter" ); } else { - buffer.SetData( data ); + int size = V8Utils::GetIntegerParameter( PARAMETER_1, found, isolate, args, 0); + if( !found ) + { + DALI_SCRIPT_EXCEPTION( isolate, "missing buffer size from param 1" ); + } + else + { + buffer.SetData( data, size ); + } } }