Script UTC test cases
[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 const char* PLUGIN_FILE = "libdali-script-plugin-v8.so";
37 }
38
39 Script::Script(void) : mPlugin(NULL)
40 {
41   ScriptPluginProxy *plugin = new ScriptPluginProxy( PLUGIN_FILE );
42
43   if( mPlugin )
44   {
45     DALI_LOG_WARNING("Reloading script plugin %s, is this what you wanted to do?",PLUGIN_FILE);
46     delete mPlugin;
47     mPlugin = NULL;
48   }
49
50   if( plugin->IsInitialized() )
51   {
52     mPlugin = plugin;
53   }
54   else
55   {
56     delete plugin;
57   }
58
59 }
60
61 bool Script::ExecuteFile( const std::string& filename )
62 {
63   if( mPlugin )
64   {
65     return mPlugin->ExecuteFile(filename);
66   }
67   return false;
68 }
69
70 Script::~Script()
71 {
72   if( mPlugin )
73   {
74     delete mPlugin;
75   }
76 }
77
78 } // namespace Internal
79
80 } // namespace Toolkit
81
82 } // namespace Dali