Allow to extract string value from a property with type of property map in JavaScript
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / src / object / property-buffer-wrapper.h
1 #ifndef __DALI_V8PLUGIN_PROPERTY_BUFFER_WRAPPER_H__
2 #define __DALI_V8PLUGIN_PROPERTY_BUFFER_WRAPPER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <v8.h>
23 #include <dali/devel-api/object/property-buffer.h>
24
25 // INTERNAL INCLUDES
26 #include <shared/base-wrapped-object.h>
27
28 namespace Dali
29 {
30
31 namespace V8Plugin
32 {
33
34
35 /**
36  * A PropertyBuffer wrapper.
37  * Provides access to PropertyBuffer specific functionality and V8 memory handling.
38  */
39 class PropertyBufferWrapper : public BaseWrappedObject
40 {
41
42 public:
43
44   /**
45    * @brief Constructor
46    * @param[in] propertyBuffer DALi property buffer
47    * @param[in] gc garbage collection interface
48    */
49   PropertyBufferWrapper( const PropertyBuffer& propertyBuffer,
50                 GarbageCollectorInterface& gc );
51
52   /**
53    * @brief Destructor
54    */
55   virtual ~PropertyBufferWrapper()
56   {
57   };
58
59   /**
60    * @brief Creates a new PropertyBuffer wrapped inside a Javascript Object.
61    * @param[in] args v8 function call arguments interpreted
62    */
63   static void NewPropertyBuffer( const v8::FunctionCallbackInfo< v8::Value >& args);
64
65   /**
66    * Wraps a property buffer
67    */
68   static v8::Handle<v8::Object> WrapPropertyBuffer(v8::Isolate* isolate, const Dali::PropertyBuffer& );
69
70
71   // The PropertyBufferAttribute ObjectTemplate, we cache templates so we don't have
72   // keep generating them everytime we want to create a PropertyBuffer
73   static v8::Persistent<v8::ObjectTemplate> mPropertyBufferTemplate;
74
75   /**
76    * @brief Gets the handle of property buffer
77    */
78   PropertyBuffer GetPropertyBuffer();
79
80
81 private:
82
83   // PropertyBuffer
84   PropertyBuffer mPropertyBuffer;
85
86   static v8::Handle<v8::ObjectTemplate> MakePropertyBufferTemplate( v8::Isolate* isolate );
87   static v8::Local<v8::ObjectTemplate> GetPropertyBufferTemplate( v8::Isolate* isolate );
88
89 };
90
91 } // namespace V8Plugin
92
93 } // namespace Dali
94
95 #endif // __DALI_V8PLUGIN_PROPERTY_BUFFER_WRAPPER_H__