Comments (2)
Ah, it's the docs. Had I not turned off warnings I would have spotted the problem right away too: I was passing a pointer to a function with the wrong signature! This example runs just fine:
#include "v7.h"
static enum v7_err
js_get_1024(struct v7 *v7, v7_val_t *res)
{
*res = v7_mk_number(v7, 1024);
return V7_OK;
}
int
main(void)
{
struct v7*
v7 = v7_create();
v7_set_method(v7, v7_get_global(v7), "get_1024", js_get_1024);
v7_val_t
result = V7_INTERNAL_ERROR;
enum v7_err
status = v7_exec(v7, "print('get_1024: ' + get_1024())", &result);
if(status != V7_OK)
fprintf(stderr, "error: %d\n", (int)status);
else
printf("result: %s\n", (enum v7_err)result == V7_OK ? "success" : "failure");
v7_destroy(v7);
return (int)status;
}
Output:
get_1024: 1024
result: success
from v7.
I've put in a pull request with corrections to the examples.
from v7.
Related Issues (20)
- V7 ScriptBASIC integration on Windows 7 32 bit HOT 41
- unit_test fails HOT 3
- v7_next_prop - No property attributes being returned HOT 10
- Script BASIC HOT 9
- v7.c: line:29703 /* TODO(dfrank) : add getter/setter support */ HOT 1
- How to load the byte code generated by v7_compile? HOT 4
- Can't call js function from C HOT 13
- Make user_data property as _V7_PROPERTY_OFF_HEAP HOT 1
- Segmentation Faults 2017-05-09
- Can I run under iOS? And Is it thread safe? HOT 2
- v7 support ajax?
- Trouble passing "true", "false" and "null" HOT 3
- v7_array_length issue HOT 1
- link errors since commit 8d8d8ce5... HOT 1
- Developer Centre down?
- C program crashes when trying to retrieve one of struct members as object member if below 0 HOT 4
- v7 Optimization tips
- Linker errors: Undefined symbols for architecture x86_64
- JSON.parse error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v7.