2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "pan-gesture-detector-wrapper.h"
22 #include <events/pan-gesture-detector-api.h>
24 #include <dali-wrapper.h>
25 #include <shared/object-template-helper.h>
36 const ApiFunction PanGestureDetectorFunctions[]=
38 { "Attach", PanGestureDetectorApi::Attach },
39 { "Detach", PanGestureDetectorApi::Detach }
42 const unsigned int PanGestureDetectorFunctionTableCount = sizeof(PanGestureDetectorFunctions)/sizeof(PanGestureDetectorFunctions[0]);
46 PanGestureDetectorWrapper::PanGestureDetectorWrapper( PanGestureDetector panGestureDetector, GarbageCollectorInterface& gc )
47 :HandleWrapper( BaseWrappedObject::PAN_GESTURE_DETECTOR, panGestureDetector, gc ),
48 mPanGestureDetector( panGestureDetector )
52 v8::Handle<v8::ObjectTemplate> PanGestureDetectorWrapper::MakePanGestureDetectorTemplate( v8::Isolate* isolate )
54 v8::EscapableHandleScope handleScope( isolate );
56 v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
57 objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
59 // add our function properties
60 ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, PanGestureDetectorFunctions, PanGestureDetectorFunctionTableCount );
62 // property handle intercepts property getters and setters and signals
63 HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
65 return handleScope.Escape( objTemplate );
68 v8::Handle<v8::Object> PanGestureDetectorWrapper::WrapPanGestureDetector( v8::Isolate* isolate, PanGestureDetector panGestureDetector )
70 v8::EscapableHandleScope handleScope( isolate );
71 v8::Local<v8::ObjectTemplate> objectTemplate;
73 objectTemplate = MakePanGestureDetectorTemplate( isolate );
75 // create an instance of the template
76 v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
78 // create the Dali object
79 PanGestureDetectorWrapper* pointer = new PanGestureDetectorWrapper( panGestureDetector, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
81 // assign the JavaScript object to the wrapper.
82 // This also stores Dali object, in an internal field inside the JavaScript object.
83 pointer->SetJavascriptObject( isolate, localObject );
85 return handleScope.Escape( localObject );
88 PanGestureDetector PanGestureDetectorWrapper::GetPanGestureDetector()
90 return mPanGestureDetector;
94 * Create an initialized PanGestureDetector handle.
96 * @for PanGestureDetector
97 * @method PanGestureDetector
99 void PanGestureDetectorWrapper::NewPanGestureDetector( const v8::FunctionCallbackInfo< v8::Value >& args)
101 v8::Isolate* isolate = args.GetIsolate();
102 v8::HandleScope handleScope( isolate );
104 if( !args.IsConstructCall() )
106 DALI_SCRIPT_EXCEPTION( isolate, "constructor called without 'new" );
111 PanGestureDetector panGestureDetector = PanGestureDetector::New();
112 v8::Local<v8::Object> localObject = WrapPanGestureDetector( isolate, panGestureDetector );
113 args.GetReturnValue().Set( localObject );
117 } // namespace V8Plugin