2 // Tizen Web Device API
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #ifndef _TIZEN_COMMON_STANDALONECONSOLE_
19 #define _TIZEN_COMMON_STANDALONECONSOLE_
23 #include <JavaScriptCore/JavaScript.h>
28 class StandaloneConsole{
31 virtual ~StandaloneConsole();
33 JSObjectRef getGlobalObject();
34 JSContextRef getGlobalContext();
36 void RunLine(const char *line);
37 void RunScript(const char * path);
39 void GarbageCollect();
42 JSValueRef RunLineEx( const char *line , JSValueRef *exception);
43 JSValueRef RunScriptEx( const char *path , JSValueRef *exception);
45 JSObjectRef registModule( const char *name, JSClassRef module, void *priv);
46 void appendModule( const char* name, JSObjectRef module );
48 static JSValueRef alert(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
49 static JSValueRef setInterval(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
50 static JSValueRef clearInterval(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
52 static JSValueRef setTimeout(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
54 static void commandline(StandaloneConsole *console);
57 static Eina_Bool timerCb(void *data);
58 void reportingResult(JSValueRef v, JSValueRef exception);
60 JSContextRef mGlobalContext;
61 JSObjectRef mGlobalObject;
62 std::map<int,int> mTimerMap;
68 #endif //_TIZEN_COMMON_STANDALONECONSOLE_