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 #ifndef TIZENAPIS_TIZEN_JSFILESTREAM_H_
20 #define TIZENAPIS_TIZEN_JSFILESTREAM_H_
22 #include <JavaScriptCore/JavaScript.h>
23 #include <CommonsJavaScript/PrivateObject.h>
28 namespace Filesystem {
34 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<IStreamPtr>::Type PrivateObjectSecurity;
37 public DeviceAPI::Common::SecurityAccessor,
38 public PrivateObjectSecurity
41 PrivateObject (JSContextRef context, IStreamPtr stream) :
42 DeviceAPI::Common::SecurityAccessor(),
43 PrivateObjectSecurity(context, stream)
47 virtual ~PrivateObject()
53 static const JSClassDefinition* getClassInfo();
55 static const JSClassRef getClassRef();
59 * The callback invoked when an object is first created.
61 static void initialize(JSContextRef context,
65 * The callback invoked when an object is finalized.
67 static void finalize(JSObjectRef object);
70 * The callback invoked when getting a property's value.
72 static JSValueRef getProperty(JSContextRef context,
74 JSStringRef propertyName,
75 JSValueRef* exception);
78 * The callback invoked when setting a property's value.
80 static bool setProperty(JSContextRef context,
82 JSStringRef propertyName,
84 JSValueRef* exception);
87 * The callback invoked when collecting the names of an object's properties.
89 static void getPropertyNames(JSContextRef context,
91 JSPropertyNameAccumulatorRef propertyNames);
94 * The callback invoked when an object is used as the target of an 'instanceof' expression.
96 static bool hasInstance(JSContextRef context,
97 JSObjectRef constructor,
98 JSValueRef possibleInstance,
99 JSValueRef* exception);
102 * Closes this FileStream.
104 static JSValueRef close(JSContextRef context,
106 JSObjectRef thisObject,
107 size_t argumentCount,
108 const JSValueRef arguments[],
109 JSValueRef* exception);
112 * Reads the specified number of characters from this FileStream.
114 static JSValueRef read(JSContextRef context,
116 JSObjectRef thisObject,
117 size_t argumentCount,
118 const JSValueRef arguments[],
119 JSValueRef* exception);
122 * Reads the specified number of bytes from this FileStream.
124 static JSValueRef readBytes(JSContextRef context,
126 JSObjectRef thisObject,
127 size_t argumentCount,
128 const JSValueRef arguments[],
129 JSValueRef* exception);
132 * Reads the specified number of bytes from this FileStream, encoding the result in base64.
134 static JSValueRef readBase64(JSContextRef context,
136 JSObjectRef thisObject,
137 size_t argumentCount,
138 const JSValueRef arguments[],
139 JSValueRef* exception);
142 * Writes the specified DOMString to this FileStream.
144 static JSValueRef write(JSContextRef context,
146 JSObjectRef thisObject,
147 size_t argumentCount,
148 const JSValueRef arguments[],
149 JSValueRef* exception);
152 * Writes the specified bytes to this FileStream.
154 static JSValueRef writeBytes(JSContextRef context,
156 JSObjectRef thisObject,
157 size_t argumentCount,
158 const JSValueRef arguments[],
159 JSValueRef* exception);
162 * Converts the specified base64 DOMString to bytes and writes the result to this FileStream.
164 static JSValueRef writeBase64(JSContextRef context,
166 JSObjectRef thisObject,
167 size_t argumentCount,
168 const JSValueRef arguments[],
169 JSValueRef* exception);
172 * This structure describes a statically declared function property.
174 static JSStaticFunction m_functions[];
177 * This structure describes a statically declared value property.
179 static JSStaticValue m_properties[];
182 * This structure contains properties and callbacks that define a type of object.
184 static JSClassDefinition m_classInfo;
186 static JSClassRef m_classRef;