1 #ifndef __DALI_V8PLUGIN_PROPERTYVALUE_WRAPPER_H__
2 #define __DALI_V8PLUGIN_PROPERTYVALUE_WRAPPER_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/object/property-value.h>
26 #include <shared/base-wrapped-object.h>
37 * An PropertyValue wrapper.
38 * Provides access to Property Value specific functionality and V8 memory handling.
40 * Only wraps complex types.
41 * Native JavaScript Property Value types such as float, bool string etc are handled by the actor wrapper.
42 * This supports sub property access for maps and vector.x etc and math functionality not easily mapped
43 * to JavaScript objects.
46 class PropertyValueWrapper : public BaseWrappedObject
52 * @param[in] value property value to wrap
53 * @param[in] gc Dali garbage collector interface
55 explicit PropertyValueWrapper( const Dali::Property::Value& value, GarbageCollectorInterface& gc );
60 virtual ~PropertyValueWrapper();
63 * @brief Creates a new Rotation wrapped inside a Javascript Object.
64 * @param[in] args v8 function call arguments interpreted as (x=0,y=0)
66 static void NewRotation( const v8::FunctionCallbackInfo< v8::Value >& args);
69 * @brief Creates a new Matrix wrapped inside a Javascript Object.
70 * @param[in] args v8 function call arguments can be a 4 x 4 matrix or a 3 x 3 matrix
72 static void NewMatrix( const v8::FunctionCallbackInfo< v8::Value >& args);
75 * @brief Wraps a dali property value inside a JavaScript object
76 * @return JavaScript object
78 static v8::Handle<v8::Object> WrapDaliProperty(v8::Isolate* isolate, const Dali::Property::Value &value);
81 * @brief Extract a property value wrapper from a javascript object
82 * @return property value wrapper
84 static PropertyValueWrapper* Unwrap( v8::Isolate* isolate, v8::Handle< v8::Object> obj);
87 * Extract a property value from a javascript object, of a given type
88 * @return property value
90 static Dali::Property::Value ExtractPropertyValue( v8::Isolate* isolate, v8::Local< v8::Value> v8Value, Dali::Property::Type type);
93 * @brief Extract a vector or a matrix from a JavaScript array
94 * @return property value ( vector or matrix)
96 static Dali::Property::Value VectorOrMatrixFromV8Array( v8::Isolate* isolate, const v8::Local<v8::Value>& v8Value);
99 * @brief Extract a Dali Property::Array from a JavaScript array
100 * @return array property value ( vector or matrix)
102 static Dali::Property::Value ArrayFromV8Array( v8::Isolate* isolate, const v8::Local<v8::Value>& v8Value);
105 * @return property value
107 Dali::Property::Value GetValue()
116 * @brief get the value for a property for JavaScript object than contains a Dali object.
117 * E.g. Get( "x", JavaScript object that wraps a Dali Vector2 )
118 * @param[in] propertyName property name
119 * @param[in] info reference to PropertyCallbackInfo structure (contains the Javascript
120 * object and the return value).
122 static void PropertyGet( v8::Local<v8::String> propertyName,
123 const v8::PropertyCallbackInfo<v8::Value>& info);
127 * @brief Set the value for a property for JavaScript object than contains a Dali object.
128 * E.g. Set( "x", 103, JavaScript object that wraps a Dali Vector2 )
129 * @param[in] propertyName property name
130 * @param[in] javaScriptValue javascript value to set, this is typically a number
131 * @param[in] info reference to PropertyCallbackInfo structure (contains the Javascript
134 static void PropertySet( v8::Local<v8::String> propertyName,
135 v8::Local<v8::Value> javaScriptValue,
136 const v8::PropertyCallbackInfo<v8::Value>& info);
141 // The Property Value ObjectTemplates
142 static v8::Persistent<v8::ObjectTemplate> mTemplatePrimitive;
145 * @brief used to make Vectors, rotation and rect template
146 * Just produces an object template with 2 internal fields
147 * A type and a pointer to the dali object
149 static v8::Handle<v8::ObjectTemplate> MakeDaliPropertyTemplate( v8::Isolate* isolate );
153 Dali::Property::Value mValue; ///< property value