|
|
Home » Developing U++ » U++ Developers corner » v8 JavaScript in U++
v8 JavaScript in U++ [message #32321] |
Mon, 09 May 2011 13:06  |
|
Hello All,
v8 JavaScript can be integrated in U++.
I use shared library of v8 because it take less space.
I have attached a simple example with screen shot.

To run this example need to have a builded v8 3.3.4.0, add in include folders v8.lib (for windows) and run.
To run a simple JavaScript code is simple:
V8JS::Locker locker;
V8JS::HandleValue result = curr_V8JS.Execute(CodeForExecution.GetData());
if(curr_V8JS.IsError()){
PromptOK(DeQtf(Format("JavaScriptError: %s", curr_V8JS.GetLastError())));
}
I added some functions(system.write(), alert(), ...) and handlers(onexit());
Any comment are welcome.
-
Attachment: v8_test.PNG
(Size: 20.14KB, Downloaded 1146 times)
|
|
|
|
|
Re: v8 JavaScript in U++ [message #32324 is a reply to message #32323] |
Mon, 09 May 2011 14:40   |
|
kohait00 wrote on Mon, 09 May 2011 15:32 | cool thing.. ever thought of exposing upp to JS8? i'm currently tackling it in python
|
V8 JS seems to be very promised. the code can be be compiled under many processors, the compiled code can be stored and restored to minimize compile time.
JavaScript seems to be very flexible by modifying objects instance on run-time and do not have strong type variables.
[Updated on: Mon, 09 May 2011 14:41] Report message to a moderator
|
|
|
|
|
Re: v8 JavaScript in U++ [message #32337 is a reply to message #32331] |
Tue, 10 May 2011 09:05   |
|
mirek wrote on Mon, 09 May 2011 18:58 |
tojocky wrote on Mon, 09 May 2011 09:24 | Added builded v8 for win32
|
Perhaps would be nice to use it as script language in theide 
Mirek
|
Yes, it would be nice.
|
|
|
|
Re: v8 JavaScript in U++ [message #32344 is a reply to message #32342] |
Tue, 10 May 2011 10:40   |
|
and a screenshot for linux:

To make work the preview sources need to change order from:
#include <CtrlLib/CtrlLib.h>
#include <V8JS/V8JS.h>
#include <V8JS/macros.h>
to:
#include <V8JS/V8JS.h>
#include <V8JS/macros.h>
#include <CtrlLib/CtrlLib.h>
and copy the attached library to location:
sudo cp libv8.so /usr/lib/libv8.so
P.S. Under the linux I see a problem. found some memory leaks.
-
Attachment: v8_linux.png
(Size: 17.94KB, Downloaded 1012 times)
|
|
|
|
|
Re: v8 JavaScript in U++ [message #32822 is a reply to message #32813] |
Mon, 13 June 2011 09:00   |
|
Lance wrote on Sun, 12 June 2011 21:59 | Never mind. v8 might not be right for my situation. I need a scripting language that can call external library functions, eg, a function written in C++ in the host program. Doesn't v8 provide mechanism to interface at least _cdecl functions? Can you provide some example. That would be truly interesting and useful.
kohait's python package may be able to do that.
|
You can do this in c++ and wrap into v8. this is done in v8cgi, node.js. I planned to do too.
I will keep you informed when I done this part of job.
|
|
|
Re: v8 JavaScript in U++ [message #32823 is a reply to message #32808] |
Mon, 13 June 2011 09:01   |
|
Lance wrote on Sun, 12 June 2011 01:15 | Beautiful! It works for me, simpler than I had expected.
I did the test on Windows. Interesting enough, when I directly run the generated exe file, everything is fine. But when I try to run it from TheIDE, it crushes TheIDE, repeatedly. Any idea what I might have done wrong?
Thank again for the great job.
|
What exactly crashes? can you upload the log file? in my case it works without any errors.
|
|
|
Re: v8 JavaScript in U++ [message #32843 is a reply to message #32823] |
Tue, 14 June 2011 15:52   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
tojocky wrote on Mon, 13 June 2011 09:01 |
Lance wrote on Sun, 12 June 2011 01:15 | Beautiful! It works for me, simpler than I had expected.
I did the test on Windows. Interesting enough, when I directly run the generated exe file, everything is fine. But when I try to run it from TheIDE, it crushes TheIDE, repeatedly. Any idea what I might have done wrong?
Thank again for the great job.
|
What exactly crashes? can you upload the log file? in my case it works without any errors.
|
Hi tojockyL:
Interesting enough, this time it is just fine.
I guess the problem was with environment variable PATH. I set PATH for the v8js.dll(?) which is immediately available to the test program if launched from Windows Explorer directly, but somehow TheIDE will remember the OLD PATH value before system reboots (strange enough)
|
|
|
|
Re: v8 JavaScript in U++ [message #32847 is a reply to message #32843] |
Tue, 14 June 2011 20:22   |
|
Lance wrote on Tue, 14 June 2011 16:52 | Hi tojockyL:
Interesting enough, this time it is just fine.
I guess the problem was with environment variable PATH. I set PATH for the v8js.dll(?) which is immediately available to the test program if launched from Windows Explorer directly, but somehow TheIDE will remember the OLD PATH value before system reboots (strange enough)
|
As a solution put the dll in c:\windows directory or in the same location with executable. Another solution is to modify PATH variable and restart the windows.
A better solution is to use v8 library in executable (added as task to me).
|
|
|
|
|
Re: v8 JavaScript in U++ [message #33450 is a reply to message #33449] |
Mon, 08 August 2011 17:07  |
|
ratah wrote on Mon, 08 August 2011 16:13 | Hello,
It compiles only with VC8.
I want to use it with mingw, how to do.
Thanks
|
Exists some tricks. I will test and upload the detailed steps.
|
|
|
Goto Forum:
Current Time: Tue Apr 29 09:27:48 CEST 2025
Total time taken to generate the page: 0.01446 seconds
|
|
|