~jbicha/ubuntu/oneiric/gjs/1.29.18

« back to all changes in this revision

Viewing changes to gi/repo.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2011-02-06 13:01:02 UTC
  • mfrom: (1.3.10 experimental)
  • Revision ID: james.westby@ubuntu.com-20110206130102-69xpqq0gql9fob01
Tags: 0.7.10-1
* New upstream release.
* debian/control.in:
  - Drop build-depend on libmozjs-dev
  - Make libgjs-dev depend on xulrunner-dev and libdbus-1-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    jsval versions_val;
61
61
    JSObject *versions;
62
62
    jsval version_val;
63
 
    const char *version;
 
63
    char *version;
64
64
    JSObject *result;
65
65
 
66
66
    JS_BeginRequest(context);
78
78
    version = NULL;
79
79
    if (JS_GetProperty(context, versions, ns_name, &version_val) &&
80
80
        JSVAL_IS_STRING(version_val)) {
81
 
        version = gjs_string_get_ascii(version_val);
 
81
        version = gjs_string_get_ascii(context, version_val);
82
82
    }
83
83
 
84
84
    repo = g_irepository_get_default();
90
90
                  "Requiring %s, version %s: %s",
91
91
                  ns_name, version?version:"none", error->message);
92
92
        g_error_free(error);
 
93
        g_free(version);
93
94
        JS_EndRequest(context);
94
95
        return NULL;
95
96
    }
96
97
 
 
98
    g_free(version);
 
99
 
97
100
    /* Defines a property on "obj" (the javascript repo object)
98
101
     * with the given namespace name, pointing to that namespace
99
102
     * in the repo.
124
127
                 JSObject **objp)
125
128
{
126
129
    Repo *priv;
127
 
    const char *name;
 
130
    char *name;
 
131
    JSBool ret = JS_TRUE;
128
132
 
129
133
    *objp = NULL;
130
134
 
134
138
    /* let Object.prototype resolve these */
135
139
    if (strcmp(name, "valueOf") == 0 ||
136
140
        strcmp(name, "toString") == 0)
137
 
        return JS_TRUE;
 
141
        goto out;
138
142
 
139
143
    priv = priv_from_js(context, obj);
140
144
    gjs_debug_jsprop(GJS_DEBUG_GREPO, "Resolve prop '%s' hook obj %p priv %p", name, obj, priv);
141
145
 
142
 
    if (priv == NULL)
143
 
        return JS_TRUE; /* we are the prototype, or have the wrong class */
 
146
    if (priv == NULL) /* we are the prototype, or have the wrong class */
 
147
        goto out;
144
148
 
145
149
    JS_BeginRequest(context);
146
150
    if (resolve_namespace_object(context, obj, name) == NULL) {
147
 
        JS_EndRequest(context);
148
 
        return JS_FALSE;
 
151
        ret = JS_FALSE;
149
152
    } else {
150
153
        *objp = obj; /* store the object we defined the prop in */
151
 
        JS_EndRequest(context);
152
 
        return JS_TRUE;
153
154
    }
 
155
    JS_EndRequest(context);
 
156
 
 
157
 out:
 
158
    g_free(name);
 
159
    return ret;
154
160
}
155
161
 
156
162
/* If we set JSCLASS_CONSTRUCT_PROTOTYPE flag, then this is called on