Permalink
Browse files

File related constants

  • Loading branch information...
1 parent ccfcf1f commit 2959767095173df2a7d9ae10359734ba4b385a36 @peter-leonov committed Apr 30, 2010
Showing with 46 additions and 2 deletions.
  1. +46 −2 classes/File.c
View
@@ -30,7 +30,7 @@ constructor(JSContext *cx, JSObject *self, uintN argc, jsval *argv, jsval *rval)
}
static JSBool
-getProperty(JSContext *cx, JSObject *self, jsval id, jsval *vp)
+static_getProperty(JSContext *cx, JSObject *self, jsval id, jsval *vp)
{
TRACE();
@@ -56,14 +56,30 @@ static JSFunctionSpec static_funcs[] =
static JSPropertySpec static_props[] =
{
+ {"INVALID", 1, JSPROP_READONLY, static_getProperty, NULL},
+ {"ERROR", 2, JSPROP_READONLY, static_getProperty, NULL},
+
+ {"HAVE_CASELESS_FILESYSTEM", 3, JSPROP_READONLY, static_getProperty, NULL},
+
+ {"RDONLY", 4, JSPROP_READONLY, static_getProperty, NULL},
+ {"WRONLY", 5, JSPROP_READONLY, static_getProperty, NULL},
+ {"RDWR", 6, JSPROP_READONLY, static_getProperty, NULL},
+ {"CREATE_OR_OPEN", 7, JSPROP_READONLY, static_getProperty, NULL},
+ {"OPEN", 8, JSPROP_READONLY, static_getProperty, NULL},
+ {"TRUNCATE", 9, JSPROP_READONLY, static_getProperty, NULL},
+ {"APPEND", 10, JSPROP_READONLY, static_getProperty, NULL},
+ {"NONBLOCK", 11, JSPROP_READONLY, static_getProperty, NULL},
+ {"DEFAULT_ACCESS", 12, JSPROP_READONLY, static_getProperty, NULL},
+ {"OWNER_ACCESS", 13, JSPROP_READONLY, static_getProperty, NULL},
+
{0, 0, 0, NULL, NULL}
};
JSClass ngx_http_js__nginx_file__class =
{
"File",
0,
- JS_PropertyStub, JS_PropertyStub, getProperty, JS_PropertyStub,
+ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
};
@@ -81,5 +97,33 @@ ngx_http_js__nginx_file__init(JSContext *cx, JSObject *global)
props, funcs, static_props, static_funcs);
E(ngx_http_js__nginx_file__prototype, "Can`t JS_InitClass(Nginx.File)");
+ // LOG("Nginx property id = %d\n", JSVAL_TO_INT(id));
+ if (JSVAL_IS_INT(id))
+ {
+ switch (JSVAL_TO_INT(id))
+ {
+ case 1: *vp = INT_TO_JSVAL(NGX_INVALID_FILE); break;
+ case 2: *vp = INT_TO_JSVAL(NGX_FILE_ERROR); break;
+
+#ifdef NGX_HAVE_CASELESS_FILESYSTEM
+ case 3: *vp = JSVAL_TRUE; break;
+#else
+ case 3: *vp = JSVAL_FALSE; break;
+#endif
+
+ case 4: *vp = INT_TO_JSVAL(NGX_FILE_RDONLY); break;
+ case 5: *vp = INT_TO_JSVAL(NGX_FILE_WRONLY); break;
+ case 6: *vp = INT_TO_JSVAL(NGX_FILE_RDWR); break;
+ case 7: *vp = INT_TO_JSVAL(NGX_FILE_CREATE_OR_OPEN); break;
+ case 8: *vp = INT_TO_JSVAL(NGX_FILE_OPEN); break;
+ case 9: *vp = INT_TO_JSVAL(NGX_FILE_TRUNCATE); break;
+ case 10: *vp = INT_TO_JSVAL(NGX_FILE_APPEND); break;
+ case 11: *vp = INT_TO_JSVAL(NGX_FILE_NONBLOCK); break;
+ case 12: *vp = INT_TO_JSVAL(NGX_FILE_DEFAULT_ACCESS); break;
+ case 13: *vp = INT_TO_JSVAL(NGX_FILE_OWNER_ACCESS); break;
+ }
+ }
+ return JS_TRUE;
+
return JS_TRUE;
}

0 comments on commit 2959767

Please sign in to comment.