e7e97c5de845161710e202fcf15e363a6f1edcd7
[framework/web/wrt-plugins-common.git] / src / CommonsJavaScript / JSDOMException.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef WRTDEVICEAPIS_COMMONSJAVASCRIPT_JS_DOM_EXCEPTION_H_
17 #define WRTDEVICEAPIS_COMMONSJAVASCRIPT_JS_DOM_EXCEPTION_H_
18
19 #include <JavaScriptCore/JavaScript.h>
20 #include <CommonsJavaScript/PrivateObject.h>
21 #include <CommonsJavaScript/DOMExceptionData.h>
22
23 namespace WrtDeviceApis {
24 namespace CommonsJavaScript {
25
26 class JSDOMException
27 {
28   public:
29     typedef PrivateObjectT<DOMExceptionDataPtr>::Type PrivateObject;
30
31   public:
32     static const unsigned short UNKNOWN_ERR = 0;
33     static const unsigned short INDEX_SIZE_ERR = 1;
34     static const unsigned short DOMSTRING_SIZE_ERR = 2;
35     static const unsigned short HIERARCHY_REQUEST_ERR = 3;
36     static const unsigned short WRONG_DOCUMENT_ERR = 4;
37     static const unsigned short INVALID_CHARACTER_ERR = 5;
38     static const unsigned short NO_DATA_ALLOWED_ERR = 6;
39     static const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
40     static const unsigned short NOT_FOUND_ERR = 8;
41     static const unsigned short NOT_SUPPORTED_ERR = 9;
42     static const unsigned short INUSE_ATTRIBUTE_ERR = 10;
43     static const unsigned short INVALID_STATE_ERR = 11;
44     static const unsigned short SYNTAX_ERR = 12;
45     static const unsigned short INVALID_MODIFICATION_ERR = 13;
46     static const unsigned short NAMESPACE_ERR = 14;
47     static const unsigned short INVALID_ACCESS_ERR = 15;
48     static const unsigned short VALIDATION_ERR = 16;
49     static const unsigned short TYPE_MISMATCH_ERR = 17;
50     static const unsigned short SECURITY_ERR = 18;
51     static const unsigned short NETWORK_ERR = 19;
52     static const unsigned short ABORT_ERR = 20;
53     static const unsigned short TIMEOUT_ERR = 21;
54     static const unsigned short INVALID_VALUES_ERR = 22;
55     static const unsigned short IO_ERR = 100;
56
57     //TODO INVALID_VALUES_ERR has the same error code ??
58     static const unsigned short QUOTA_EXCEEDED_ERR = 22;
59
60   public:
61     static JSClassRef getClassRef();
62     /**
63      * Gets object's class description.
64      */
65     static const JSClassDefinition* getClassInfo();
66
67   private:
68     /**
69      * The callback invoked when an object is first created.
70      */
71     static void initialize(JSContextRef context,
72             JSObjectRef object);
73
74     /**
75      * The callback invoked when an object is finalized.
76      */
77     static void finalize(JSObjectRef object);
78
79     /**
80      * The callback invoked when getting a property's value.
81      */
82     static bool hasProperty(JSContextRef context,
83             JSObjectRef object,
84             JSStringRef propertyName);
85
86     /**
87      * The callback invoked when getting a property's value.
88      */
89     static JSValueRef getProperty(JSContextRef context,
90             JSObjectRef object,
91             JSStringRef propertyName,
92             JSValueRef* exception);
93
94     /**
95      * The callback invoked when getting a property's value.
96      */
97     static JSValueRef getStaticProperty(JSContextRef context,
98             JSObjectRef object,
99             JSStringRef propertyName,
100             JSValueRef* exception);
101
102     static void getPropertyNames(JSContextRef context,
103             JSObjectRef object,
104             JSPropertyNameAccumulatorRef accumulator);
105
106     /**
107      * The callback invoked when an object is used as the target of an 'instanceof' expression.
108      */
109     static bool hasInstance(JSContextRef context,
110             JSObjectRef constructor,
111             JSValueRef possibleInstance,
112             JSValueRef* exception);
113
114     /**
115      * This structure contains properties and callbacks that define a type of object.
116      */
117     static JSClassDefinition m_classInfo;
118
119     /**
120      * This structure describes a statically declared value property.
121      */
122     static JSStaticValue m_properties[];
123
124     static JSClassRef m_classRef;
125 };
126
127 } // CommonsJavaScript
128 } // WrtDeviceApis
129
130 #endif //
131