2 // Tizen Web Device API
3 // Copyright (c) 2012 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.
19 * @file JSFilestream.h
22 #ifndef TIZENAPIS_TIZEN_JSFILESTREAM_H_
23 #define TIZENAPIS_TIZEN_JSFILESTREAM_H_
25 #include <JavaScriptCore/JavaScript.h>
26 #include <CommonsJavaScript/PrivateObject.h>
30 namespace Filesystem {
34 static const JSClassDefinition* getClassInfo();
36 static const JSClassRef getClassRef();
38 static StreamPtr getPrivateObject(JSContextRef context, JSValueRef value);
39 static void setPrivateObject(JSObjectRef object, StreamPtr data);
40 static JSObjectRef makeJSObject(JSContextRef context, StreamPtr ptr,
41 Common::SecurityAccessor* srcSecurityAccessor);
45 * The callback invoked when an object is first created.
47 static void initialize(JSContextRef context,
51 * The callback invoked when an object is finalized.
53 static void finalize(JSObjectRef object);
56 * The callback invoked when getting a property's value.
58 static JSValueRef getProperty(JSContextRef context,
60 JSStringRef propertyName,
61 JSValueRef* exception);
64 * The callback invoked when setting a property's value.
66 static bool setProperty(JSContextRef context,
68 JSStringRef propertyName,
70 JSValueRef* exception);
73 * The callback invoked when collecting the names of an object's properties.
75 static void getPropertyNames(JSContextRef context,
77 JSPropertyNameAccumulatorRef propertyNames);
80 * The callback invoked when an object is used as the target of an 'instanceof' expression.
82 static bool hasInstance(JSContextRef context,
83 JSObjectRef constructor,
84 JSValueRef possibleInstance,
85 JSValueRef* exception);
88 * Closes this FileStream.
90 static JSValueRef close(JSContextRef context,
92 JSObjectRef thisObject,
94 const JSValueRef arguments[],
95 JSValueRef* exception);
98 * Reads the specified number of characters from this FileStream.
100 static JSValueRef read(JSContextRef context,
102 JSObjectRef thisObject,
103 size_t argumentCount,
104 const JSValueRef arguments[],
105 JSValueRef* exception);
108 * Reads the specified number of bytes from this FileStream.
110 static JSValueRef readBytes(JSContextRef context,
112 JSObjectRef thisObject,
113 size_t argumentCount,
114 const JSValueRef arguments[],
115 JSValueRef* exception);
118 * Reads the specified number of bytes from this FileStream, encoding the result in base64.
120 static JSValueRef readBase64(JSContextRef context,
122 JSObjectRef thisObject,
123 size_t argumentCount,
124 const JSValueRef arguments[],
125 JSValueRef* exception);
128 * Writes the specified DOMString to this FileStream.
130 static JSValueRef write(JSContextRef context,
132 JSObjectRef thisObject,
133 size_t argumentCount,
134 const JSValueRef arguments[],
135 JSValueRef* exception);
138 * Writes the specified bytes to this FileStream.
140 static JSValueRef writeBytes(JSContextRef context,
142 JSObjectRef thisObject,
143 size_t argumentCount,
144 const JSValueRef arguments[],
145 JSValueRef* exception);
148 * Converts the specified base64 DOMString to bytes and writes the result to this FileStream.
150 static JSValueRef writeBase64(JSContextRef context,
152 JSObjectRef thisObject,
153 size_t argumentCount,
154 const JSValueRef arguments[],
155 JSValueRef* exception);
158 * This structure describes a statically declared function property.
160 static JSStaticFunction m_functions[];
163 * This structure describes a statically declared value property.
165 static JSStaticValue m_properties[];
168 * This structure contains properties and callbacks that define a type of object.
170 static JSClassDefinition m_classInfo;
172 static JSClassRef m_classRef;
173 Stream* getPrivateObject(JSObjectRef aObject);