mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
956 B
34 lines
956 B
name: duk_pcompile_lstring_filename
|
|
|
|
proto: |
|
|
duk_int_t duk_pcompile_lstring_filename(duk_context *ctx, duk_uint_t flags, const char *src, duk_size_t len);
|
|
|
|
stack: |
|
|
[ ... filename! ] -> [ ... function! ] (if success, return value == 0)
|
|
[ ... filename! ] -> [ ... err! ] (if failure, return value != 0)
|
|
|
|
summary: |
|
|
<p>Like
|
|
<code><a href="#duk_pcompile">duk_pcompile()</a></code>, but the compile input
|
|
is given as a C string with explicit length.</p>
|
|
|
|
<div include="no-string-intern.html" />
|
|
|
|
example: |
|
|
const char *src = /* ... */;
|
|
duk_size_t len = /* ... */;
|
|
|
|
duk_push_string(ctx, "myFile.js");
|
|
if (duk_pcompile_lstring_filename(ctx, 0, src, len) != 0) {
|
|
printf("compile failed: %s\n", duk_safe_to_string(ctx, -1));
|
|
} else {
|
|
duk_call(ctx, 0); /* [ func ] -> [ result ] */
|
|
printf("program result: %s\n", duk_safe_to_string(ctx, -1));
|
|
}
|
|
duk_pop(ctx);
|
|
|
|
tags:
|
|
- compile
|
|
- protected
|
|
|
|
introduced: 1.0.0
|
|
|