2 * Browser D-Bus Bridge, JavaScriptCore version
4 * Copyright © 2008 Movial Creative Technologies Inc
5 * Contact: Movial Creative Technologies Inc, <info@movial.com>
6 * Authors: Kalle Vahlman, <kalle.vahlman@movial.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 #include <JavaScriptCore/JavaScript.h>
26 #include "jscorebus-classfactory.h"
29 GHashTable *definitions = NULL;
31 GHashTable *classes = NULL;
34 jsclassdef_insert(const char *class_name, const JSClassDefinition *definition)
36 if (G_UNLIKELY(definitions == NULL))
38 definitions = g_hash_table_new(g_str_hash, g_str_equal);
41 g_hash_table_insert(definitions, (gpointer)class_name, (gpointer)definition);
44 const JSClassDefinition *
45 jsclassdef_lookup(const char *class_name)
47 if (class_name == NULL)
52 if (G_UNLIKELY(definitions == NULL))
57 return (const JSClassDefinition *) g_hash_table_lookup(definitions,
58 (gpointer)class_name);
62 jsclass_lookup(const JSClassDefinition *definition)
66 if (G_UNLIKELY(classes == NULL))
68 classes = g_hash_table_new(NULL, NULL);
71 jsclass = g_hash_table_lookup(classes, (gpointer)definition);
72 if (G_UNLIKELY(jsclass == NULL))
74 jsclass = JSClassCreate(definition);
75 g_hash_table_insert(classes, (gpointer)definition, (gpointer)jsclass);