On Tue, Apr 30, 2013 at 9:08 AM, Sarim Khan <[email protected]> wrote:
> Hi,
>
> I have library implemented in javascript. I use that library in c++ apps.
> So what i do now, is to use v8, create a context, then read the js files,
> and run the js codes inside the context. Then find the js function in c++.
> Then use the function from c++. But this approach comes with a performance
> cost.
>
> So i want to include my javascript files and use the mksnapshot feature of
> v8. When compiling vs makes snapshot of runtime.js array.js string.js
> ........., How can i add my js files to this list.
>
See --extra-code flag.
>
> I tried this so far, opened runtime.js and added this line to the end.
>
> runtime.js:function sarim() { return "i'm awesome";};
>
> Then i compiled v8 (make native -j 4 library=shared werror=no) and run the
> shell, (out/native/shell)
>
> > sarim
> (shell):1: ReferenceError: sarim is not defined
> sarim
> ^
> ReferenceError: sarim is not defined
> at (shell):1:1
>
>
>
> So my code in is not getting included.
>
> How to include my code ?
>
Your code is probably included, but to make you function available in the
way you want, you should assign it to a property on a global object:
global.sarim = sarim;
Hope this helps,
Dmitry
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.