tizen 2.3.1 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / Common / JSWebAPIError.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 #ifndef _JS_WEBAPI_ERROR_H_
19 #define _JS_WEBAPI_ERROR_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include "JSWebAPIErrorFactory.h"
23
24 #include "WebAPIError.h"
25
26 namespace DeviceAPI {
27 namespace Common {
28
29 class JSWebAPIErrorFactory;
30
31 class JSWebAPIError {
32 public:
33     static JSClassRef getClassRef();
34
35     static const JSClassDefinition* getClassInfo();
36
37     static bool isObjectOfClass(JSContextRef context, JSValueRef value);
38
39     static JSObjectRef constructor(JSContextRef context,
40             JSObjectRef constructor,
41             size_t argumentCount,
42             const JSValueRef arguments[],
43             JSValueRef* exception);
44
45 private:
46     static JSObjectRef createJSObject(JSContextRef context,
47             WebAPIError* webapiError);
48
49     static WebAPIError* getPriv(JSContextRef context, JSObjectRef object);
50
51     static void initialize(JSContextRef context, JSObjectRef object);
52
53     static void finalize(JSObjectRef object);
54
55     static JSValueRef getProperty(JSContextRef context,
56             JSObjectRef object,
57             JSStringRef propertyName,
58             JSValueRef* exception);
59
60     static JSValueRef toString(JSContextRef context,
61             JSObjectRef object,
62             JSObjectRef thisObject,
63             size_t argumentCount,
64             const JSValueRef arguments[],
65             JSValueRef* exception);
66
67     static JSClassDefinition m_classInfo;
68
69     static JSStaticValue m_properties[];
70
71     static JSClassRef m_classRef;
72
73     static JSStaticFunction m_function[];
74
75     friend class JSWebAPIErrorFactory;
76 };
77
78 } // Common
79 } // DeviceAPI
80
81 #endif // _JS_WEBAPI_ERROR_H_