Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: include/v8c.h

Issue 6070: Basic C bindings for v8.
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/SConscript » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Copyright 2007-2008 the V8 project authors. All rights reserved.
2 Redistribution and use in source and binary forms, with or without
3 modification, are permitted provided that the following conditions are
4 met:
5
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above
9 copyright notice, this list of conditions and the following
10 disclaimer in the documentation and/or other materials provided
11 with the distribution.
12 * Neither the name of Google Inc. nor the names of its
13 contributors may be used to endorse or promote products derived
14 from this software without specific prior written permission.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /* v8c -- v8 API for using v8 from C (and other languages that can bind against
30 C). */
31
32 /* NOTE: This file tries to follow include/v8.h directly. The
33 function order should match the order there, and that file should contain
34 all the documentation.
35 */
36
37 /* v8::Handle has a lot of nice type-checking and wrapping and unwrapping,
38 but in the C world all we get is a pointer.
39 Internally, V8Handle is the pointer held by a v8::Handle.
40 */
41 typedef void* V8Handle;
42
43 /* To have the compiler help catch type errors, this file is #included by
44 both the C++ implementation and the C user. These typedefs make the
45 function prototypes work on both sides.
46 */
47 #ifdef __cplusplus
48 extern "C" {
49 typedef v8::HandleScope V8HandleScope;
50 typedef v8::Arguments V8Arguments;
51 typedef v8::ExtensionConfiguration* V8ExtensionConfiguration;
52 typedef v8::String::Utf8Value V8StringUtf8Value;
53 typedef v8::TryCatch V8TryCatch;
54 #else /* Compiling on the C side. */
55 typedef int bool;
56 typedef struct _V8HandleScope V8HandleScope;
57 typedef struct _V8Arguments V8Arguments;
58 typedef void* V8ExtensionConfiguration;
59 typedef void V8StringUtf8Value;
60 typedef struct _V8TryCatch V8TryCatch;
61 #endif
62
63 /* Handle */
64 bool v8_handle_is_empty(V8Handle handle);
65
66 /* HandleScope */
67 V8HandleScope* v8_handle_scope_new();
68 void v8_handle_scope_free(V8HandleScope* hs);
69
70 /* Script */
71 V8Handle v8_script_compile(V8Handle source);
72 V8Handle v8_script_run(V8Handle script);
73
74 /* String */
75 V8Handle v8_string_new_utf8(const char* data, int length);
76
77 /* String::Utf8Value */
78 V8StringUtf8Value* v8_string_utf8_value_new(V8Handle handle);
79 int v8_string_utf8_value_length(V8StringUtf8Value* utf8);
80 char* v8_string_utf8_value_chars(V8StringUtf8Value* utf8);
81 void v8_string_utf8_value_free(V8StringUtf8Value* utf8);
82
83 /* Template */
84 void v8_template_set(V8Handle tmpl, V8Handle name, V8Handle value);
85
86 /* Arguments */
87 int v8_arguments_length(const V8Arguments* args);
88 V8Handle v8_arguments_get(const V8Arguments* args, int i);
89
90 /* FunctionTemplate */
91 /* V8 lets you add a "data" value to a function template, but v8c uses
92 it internally. We could still provide extra-data-like
93 functionality if needed, though. */
94 typedef V8Handle (*V8InvocationCallback)(const V8Arguments*);
95 V8Handle v8_function_template_new(V8InvocationCallback callback);
96
97 /* ObjectTemplate */
98 V8Handle v8_object_template_new();
99
100 /* Special static values */
101 V8Handle v8_undefined();
102 V8Handle v8_null();
103 V8Handle v8_true();
104 V8Handle v8_false();
105
106 /* V8 (class containing static functions) */
107 void v8_set_flags_from_command_line(int* argc, char** argv,
108 bool remove_flags);
109
110 /* TryCatch */
111 V8TryCatch* v8_try_catch_new();
112 void v8_try_catch_free(V8TryCatch* try_catch);
113 bool v8_try_catch_has_caught(V8TryCatch* try_catch);
114 V8Handle v8_try_catch_exception(V8TryCatch* try_catch);
115 V8Handle v8_try_catch_get_message(V8TryCatch* try_catch);
116 void v8_try_catch_reset(V8TryCatch* try_catch);
117 void v8_try_catch_set_verbose(V8TryCatch* try_catch, bool value);
118
119 /* Context */
120 V8Handle v8_context_new(V8ExtensionConfiguration extensions,
121 V8Handle global_template);
122 void v8_context_enter(V8Handle context);
123 void v8_context_exit(V8Handle context);
124
125 #ifdef __cplusplus
126 }
127 #endif
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698