summaryrefslogtreecommitdiff
path: root/libseed/seed-engine.h
blob: 9652344437421bf9fe1f0fdb01135057f7211377 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* -*- mode: C; indent-tabs-mode: t; tab-width: 8; c-basic-offset: 2; -*- */

/*
 * This file is part of Seed, the GObject Introspection<->Javascript bindings.
 *
 * Seed is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 2 of
 * the License, or (at your option) any later version.
 * Seed is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with Seed.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright (C) Robert Carr 2009 <carrr@rpi.edu>
 */

#ifndef _SEED_ENGINE_H
#define _SEED_ENGINE_H

#include "seed-private.h"

extern JSClassRef gobject_class;
extern JSClassRef gobject_method_class;
extern JSClassRef gobject_constructor_class;
extern JSClassRef gobject_named_constructor_class;
extern JSClassRef seed_struct_constructor_class;
extern JSClassRef gobject_init_method_class;

extern pthread_key_t seed_next_gobject_wrapper_key;

extern JSClassRef seed_callback_class;
extern SeedEngine* eng;

extern JSObjectRef seed_obj_ref;

extern JSContextGroupRef context_group;

extern JSStringRef defaults_script;

typedef struct _SeedScript
{
    JSStringRef script;
    JSValueRef exception;

    JSStringRef source_url;
    gint line_number;
} SeedScript;

JSObjectRef seed_gobject_get_prototype_for_gtype(GType type);
JSClassRef seed_gobject_get_class_for_gtype(JSContextRef ctx, GType type);

void seed_gobject_define_property_from_function_info(JSContextRef ctx,
                                                     GIFunctionInfo* info,
                                                     JSObjectRef object,
                                                     gboolean instance);
void seed_create_function(JSContextRef ctx,
                          gchar* name,
                          gpointer func,
                          JSObjectRef obj);

void seed_repl_expose(JSContextRef ctx, ...);

typedef JSObjectRef (*SeedModuleInitCallback)(SeedEngine* eng);

void seed_prepare_global_context(JSContextRef ctx);

SeedScript* seed_make_script(JSContextRef ctx,
                             const gchar* js,
                             const gchar* source_url,
                             gint line_number);
SeedScript* seed_script_new_from_file(JSContextRef ctx, gchar* file);
JSValueRef seed_script_exception(SeedScript* s);

JSValueRef seed_evaluate(JSContextRef ctx,
                         SeedScript* script,
                         JSObjectRef this);

void seed_script_destroy(SeedScript* s);

JSValueRef seed_simple_evaluate(JSContextRef ctx,
                                const gchar* script,
                                JSValueRef* exception);

GOptionGroup* seed_get_option_group(void);

#endif