-/* $Id: js_pgsql.c,v 1.5 2006/10/04 00:56:25 mmondor Exp $ */
+/* $Id: js_pgsql.c,v 1.6 2006/10/04 01:54:33 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
static int *param_formats = NULL;
static int param_entries = 0;
-/*
- * This object is crated by js_InitPGClass() and rooted, so that we may easily
- * root objects by adding them as properties into it. To be thread-safe, a
- * critical section or mutex would be needed when accessing this object.
- */
-static JSObject *root_object = NULL;
-
/* PG class */
static JSClass pg_class = {
}
param_entries = 16;
- /* Create our rooted object */
- if ((root_object = JS_NewObject(cx, NULL, NULL, NULL)) == NULL) {
- (void) fprintf(stderr, "PG: JS_NewObject(root_object)\n");
- goto err;
- }
- if (!JS_AddRoot(cx, &root_object)) { /* Pointer to pointer */
- (void) fprintf(stderr, "PG: JS_AddRoot(root_object)\n");
- goto err;
- }
-
return proto;
err:
return JS_FALSE;
}
+/* ARGSUSED */
static void
pg_finalize(JSContext *cx, JSObject *obj)
{
- /* XXX This never gets called since PG is uninstanciable. */
- if (root_object != NULL)
- (void) JS_RemoveRoot(cx, &root_object); /* Ptr to ptr */
+ /* NOOP */
}
{
PGconn *pgc;
FILE *fh;
+ JSObject *ro;
*rval = OBJECT_TO_JSVAL(NULL);
* Unroot previously rooted File object, if any, then root newly
* provided File object.
*/
- (void) JS_DeleteProperty(cx, root_object, "trace");
- if (!JS_DefineProperty(cx, root_object, "trace", argv[0],
+ ro = JSVAL_TO_OBJECT(argv[-1]);
+ (void) JS_DeleteProperty(cx, ro, "trace_file_root");
+ if (!JS_DefineProperty(cx, ro, "trace_file_root", argv[0],
NULL, NULL, 0)) {
QUEUE_EXCEPTION("Internal error!");
return JS_FALSE;
jsval *rval)
{
PGconn *pgc;
+ JSObject *ro;
*rval = OBJECT_TO_JSVAL(NULL);
/*
* Unroot previously rooted File object
*/
- (void) JS_DeleteProperty(cx, root_object, "trace");
+ ro = JSVAL_TO_OBJECT(argv[-1]);
+ (void) JS_DeleteProperty(cx, ro, "trace_file_root");
PQuntrace(pgc);