Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » v8 JavaScript in U++
v8 JavaScript in U++ [message #32321] Mon, 09 May 2011 13:06 Go to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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.
index.php?t=getfile&id=3233&private=0

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 1029 times)
Re: v8 JavaScript in U++ [message #32322 is a reply to message #32321] Mon, 09 May 2011 13:58 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Added sourcecode
  • Attachment: JS_src.zip
    (Size: 79.44KB, Downloaded 391 times)
Re: v8 JavaScript in U++ [message #32323 is a reply to message #32322] Mon, 09 May 2011 14:32 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
cool thing.. ever thought of exposing upp to JS8? i'm currently tackling it in python
Re: v8 JavaScript in U++ [message #32324 is a reply to message #32323] Mon, 09 May 2011 14:40 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 #32328 is a reply to message #32324] Mon, 09 May 2011 15:24 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Added builded v8 for win32
Re: v8 JavaScript in U++ [message #32331 is a reply to message #32328] Mon, 09 May 2011 17:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
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 Smile

Mirek
Re: v8 JavaScript in U++ [message #32337 is a reply to message #32331] Tue, 10 May 2011 09:05 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 Smile

Mirek


Yes, it would be nice.
Re: v8 JavaScript in U++ [message #32342 is a reply to message #32337] Tue, 10 May 2011 10:28 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Added builded v8 for linx32 (ubuntu 10.10)
Re: v8 JavaScript in U++ [message #32344 is a reply to message #32342] Tue, 10 May 2011 10:40 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

and a screenshot for linux:
index.php?t=getfile&id=3238&private=0

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 903 times)
Re: v8 JavaScript in U++ [message #32808 is a reply to message #32344] Sun, 12 June 2011 00:15 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
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.
Re: v8 JavaScript in U++ [message #32813 is a reply to message #32808] Sun, 12 June 2011 20:59 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
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.
Re: v8 JavaScript in U++ [message #32822 is a reply to message #32813] Mon, 13 June 2011 09:00 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
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 #32844 is a reply to message #32822] Tue, 14 June 2011 15:54 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
tojocky wrote on 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.


Thanks! It's very important.
Re: v8 JavaScript in U++ [message #32847 is a reply to message #32843] Tue, 14 June 2011 20:22 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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 #32861 is a reply to message #32847] Wed, 15 June 2011 14:21 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
tojocky wrote on Tue, 14 June 2011 20:22


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).


Yes, I used the third way, separate folder with path environment variable set. I just missed the reboot part.

Do you mean you are working on options to build v8 libary into executable (static link) just like Esc? That will be interesting. When all are done, I will certainly consider switch back as JavsScript is a more industry standard thing.
Re: v8 JavaScript in U++ [message #33449 is a reply to message #32861] Mon, 08 August 2011 15:13 Go to previous messageGo to next message
ratah is currently offline  ratah
Messages: 107
Registered: July 2010
Experienced Member
Hello,

It compiles only with VC8.
I want to use it with mingw, how to do.
Thanks
Re: v8 JavaScript in U++ [message #33450 is a reply to message #33449] Mon, 08 August 2011 17:07 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

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.
Previous Topic: TheIde new look and new features
Next Topic: MVC example
Goto Forum:
  


Current Time: Thu Mar 28 13:16:04 CET 2024

Total time taken to generate the page: 0.01501 seconds