Esempio n. 1
0
	JS_FS_END
};

static JSFunctionSpec File_functions_static[] =
{
	JS_FS("exists", File_function_exists_static, 0, 0, 0),
	JS_FS("isFile", File_function_isFile_static, 0, 0, 0),
	JS_FS("isDirectory", File_function_isDirectory_static, 0, 0, 0),
	JS_FS("readAll", File_function_readAll_static, 0, 0, 0),
	JS_FS("size", File_function_size_static, 0, 0, 0),
	JS_FS_END
};

static JSPropertySpec File_propertes[] =
{
	JS_PS("path", 0, JSPROP_ENUMERATE|JSPROP_PERMANENT, 0, File_property_path_set),
	JS_PS_END
};

JSClass File_class =
{
	"File",					//         name: The class name
	JSCLASS_HAS_PRIVATE,	//        flags: Various flags
	JS_PropertyStub,		//  addProperty: A hook called just after adding a new property. May modify the new property value. (Default: JS_PropertyStub)
	JS_PropertyStub,		//  delProperty: A hook called when deleting a property. May veto. (Default: JS_PropertyStub)
	JS_PropertyStub,		//  getProperty: A hook called when getting a property. This is the default getter for the class. (Default: JS_PropertyStub)
	JS_PropertyStub,		//  setProperty: A hook called when setting a property. This is the default setter for the class.
							//               When a script creates a new property, this is called after addProperty. (Default: JS_PropertyStub)
	JS_EnumerateStub,		//    enumerate: Method for enumerating object properties (Default: JS_EnumerateStub)
	JS_ResolveStub,			//      resolve: Hook for implementing lazy properties. See JSClass.resolve for details (Default: JS_ResolveStub)
	JS_ConvertStub,			//      convert: Method for converting property values. (Default: JS_ConvertStub)
Esempio n. 2
0
JSAPI_PROP(file_get_writable);
JSAPI_PROP(file_get_skippable);
JSAPI_PROP(file_get_closed);
JSAPI_STRICT_PROP(file_set_position);

JSFunctionSpec file_methods[] = {
	JS_FS("read", file_read, 1, JSPROP_STATIC),
	JS_FS("write", file_write, 1, JSPROP_STATIC),
	JS_FS("skip", file_skip, 1, JSPROP_STATIC),
	JS_FS("flush", file_flush, 0, JSPROP_STATIC),
	JS_FS("close", file_close, 0, JSPROP_STATIC),
	JS_FS_END
};

JSPropertySpec file_props[] = {
	JS_PS("length", 0, JSPROP_STATIC, file_get_length, nullptr),
	JS_PS("position", 0, JSPROP_DEFAULT, file_get_position, file_set_position),
	JS_PS("readable", 0, JSPROP_STATIC, file_get_readable, nullptr),
	JS_PS("writable", 0, JSPROP_STATIC, file_get_writable, nullptr),
	JS_PS("skippable", 0, JSPROP_STATIC, file_get_skippable, nullptr),
	JS_PS("closed", 0, JSPROP_STATIC, file_get_closed, nullptr),
	JS_PS_END
};

JSFunctionSpec file_static_methods[] = {
	JS_FS("open", file_open, 2, JSPROP_STATIC),
	JS_FS_END
};

JSAPI_FUNC(file_open)
{