blob: 29b95cae2ac966bf927358e9011fb7a2c6a3a063 [file] [log] [blame]
jat@google.com64a55cb2009-10-16 14:16:57 +00001/*
2 * Copyright 2007 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17#include "JsRootedValue.h"
18
19// Initialize static value used to hold the JavaScript String class.
20JSClass* JsRootedValue::stringClass = 0;
21
22// Initialize static reference to the sole JSRuntime value in Gecko.
23JSRuntime* JsRootedValue::runtime = 0;
24
25// Static stack of JavaScript execution contexts.
26std::stack<JSContext*> JsRootedValue::contextStack;
27
28/*
29 * Actually get the stringClass pointer from JavaScript.
30 */
31void JsRootedValue::fetchStringClass() const {
32 Tracer tracer("JsRootedValue::fetchStringClass");
33 JSContext* cx = currentContext();
34 jsval val = JS_GetEmptyStringValue(cx);
35 JSObject* obj;
36 // on error, leave stringClass null
37 if (!JS_ValueToObject(cx, val, &obj)) return;
38 if (!obj) {
39 tracer.log("ensureStringClass: null object");
40 return;
41 }
42 stringClass = JS_GET_CLASS(cx, obj);
43 tracer.log("stringClass=%08x", unsigned(stringClass));
44}