Merge "Fix resource leaks in layouting." into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / scripting / script-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "script-impl.h"
20
21 // INTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include "script-plugin-proxy.h"
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 namespace
35 {
36 #if _GLIBCXX_USE_CXX11_ABI
37 const char* PLUGIN_FILE = "libdali-script-plugin-v8-cxx11.so";
38 #else
39 const char* PLUGIN_FILE = "libdali-script-plugin-v8.so";
40 #endif
41 }
42
43 Script::Script()
44 : mPlugin( NULL )
45 {
46   ScriptPluginProxy *plugin = new ScriptPluginProxy( PLUGIN_FILE );
47
48   if( plugin->IsInitialized() )
49   {
50     mPlugin = plugin;
51   }
52   else
53   {
54     delete plugin;
55   }
56 }
57
58 bool Script::ExecuteFile( const std::string& filename )
59 {
60   if( mPlugin )
61   {
62     return mPlugin->ExecuteFile(filename);
63   }
64   return false;
65 }
66
67 Script::~Script()
68 {
69   if( mPlugin )
70   {
71     delete mPlugin;
72   }
73 }
74
75 } // namespace Internal
76
77 } // namespace Toolkit
78
79 } // namespace Dali