Open GoogleCodeExporter opened 9 years ago
I will look into it today or tomorrow. Although I can only test in in Delphi 7.
I
will post result here.
Original comment by Dusan.Ha...@gmail.com
on 8 Mar 2010 at 2:07
Try rev.3, it is compileable in Delphi7, I added simpler test2.dpr especially
for
delphi testing, works fine in Delphi7, can you check it out?
Original comment by Dusan.Ha...@gmail.com
on 8 Mar 2010 at 3:52
I'm able to compile it now, but always get the 'EVALUATE ERROR' when it comes to
evaluating the script. I think it might all have to do with the different
treatment
of strings in later Delphi versions, they completely made the switch to Unicode
and
the default string type is now 'unicodestring', and if one wants to use ANSI
you have
to specifically call it an AnsiString?
Original comment by craigthe...@gmail.com
on 10 Mar 2010 at 1:07
Do you also have EVALUATE ERROR in test2 ?
Original comment by Dusan.Ha...@gmail.com
on 10 Mar 2010 at 4:09
Yes, I was running Test2.dpr. I've been investigating, but I'm not sure when the big string changes were
introduced - there's a lot section in the Delphi help about converting
everything to unicode, mentions a lot of
things about Move, Copy, StrDispose... and how they all need modifying to
reflect the change. But perhaps that's
not the issue. I am also using the SpiderMonkey DLLs from the very latest
firefox - are you?
Original comment by craigthe...@gmail.com
on 11 Mar 2010 at 1:24
I use DLL from Firefox 3.6: js3250.dll, mozcrt19.dll, nspr4.dll and WindowsXP
with
Delphi7.
Thy modify test2.dpr, there is "source" constant:
source = 'var a = 6; var b = 7; echo("The ultimate answer is ",a*b,"\n");';
Try change it to:
source = 'var a = 6; var b = 7; var c = a * b;';
And after this code:
if not s.Evaluate(source) then
writeln('!!! EVALUATE ERROR !!!');
Add this line:
writeln('c = ',s.GetValue('c'));
I suspect the binding of "echo" function to cause this, can you try it. I also
put
modified test2.dpr to attachment.
Original comment by Dusan.Ha...@gmail.com
on 11 Mar 2010 at 7:48
Attachments:
I had the same thought, and tried removing the 'echo' function, but still got
the
evaluate error. However, I will try the code you just sent when I finish work
later.
Original comment by craigthe...@gmail.com
on 11 Mar 2010 at 7:50
Ok, I also isolated code to bare minimum in test3.dpr, now it uses only
js15decl. It
should be simpler to debug.
Original comment by Dusan.Ha...@gmail.com
on 11 Mar 2010 at 8:17
Attachments:
This time I don't get any exceptions, but I receive the output:
"function binding: 7698792
EVALUATE ERROR
press enter"
Original comment by craigthe...@gmail.com
on 14 Mar 2010 at 4:34
Does it print same error when source has no echo function?
const source = 'var a=6; var b=7; var c = 6 * 7;';
Original comment by Dusan.Ha...@gmail.com
on 14 Mar 2010 at 8:48
Also try attached demo, in my case it print:
1. source: TRUE
2. source_byte: TRUE
3. source_word: MyErrorReporter:
Message : SyntaxError: illegal character
LineNo : 0
LineBuf : v
FALSE
4. source_integer: MyErrorReporter:
Message : SyntaxError: illegal character
LineNo : 0
LineBuf : v
FALSE
5. source_longint: MyErrorReporter:
Message : SyntaxError: illegal character
LineNo : 0
LineBuf : v
FALSE
6. source_longword: MyErrorReporter:
Message : SyntaxError: illegal character
LineNo : 0
LineBuf : v
FALSE
7. source_char: TRUE
8. source_pchar: TRUE
Original comment by Dusan.Ha...@gmail.com
on 14 Mar 2010 at 9:28
Attachments:
This time it seems to ask for more DLLs... including MOZCRT19.dll and nspr4.dll.
The final output is:
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
1. source: FALSE
2. source_byte: TRUE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
3. source_word: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
4. source_integer: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
5. source_longint: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
6. source_longword: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
7. source_char: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
8. source_pchar: FALSE
press enter
Original comment by craigthe...@gmail.com
on 15 Mar 2010 at 1:34
Ah, perhaps progress! If I change all the JS_EvaluateScript statements to
JS_UCEvaluateScript, I get:
1. source: TRUE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : ??
2. source_byte: FALSE
3. source_word: TRUE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
4. source_integer: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
5. source_longint: FALSE
MyErrorReporter:
Message : ???????????????
LineNo : 0
LineBuf : v
6. source_longword: FALSE
7. source_char: TRUE
8. source_pchar: TRUE
press enter
Original comment by craigthe...@gmail.com
on 15 Mar 2010 at 1:40
OK I've been experimenting with changing JS_functions to JS_UCfunctions in
fpcjs.pas,
and now get the results from your original test.dpr!
This is JS code
Hello
World
pi is 3.14 approximately, or 3.14159000000000E+0000 to be more precise
1.41421356237310E+0000 is sqrt 2
hello 95-year-old John has bmi 2.78000000000000E+0000 is TRUE male and blood c
This is foo
factorial 5 is 120
FATAL: 0. is unknown type
---
However, as you already knew the RegisterFunction doesn't work properly. That's
the
bit I'm most interested in :D.
Original comment by craigthe...@gmail.com
on 15 Mar 2010 at 1:55
[deleted comment]
Sorry to spam you like this. There seems to be a problem with js15decl.pas, in
that
it has a prototype for:
function JS_CallUCFunctionName(cx: PJSContext; obj: PJSObject; name: pjschar;
namelen: size_t; argc: uintN; argv: pjsval; rval: pjsval): JSBool; cdecl;
external
LibName;
But unfortunately calling that doesn't work - "The procedure entry point
JS_CallUCFunctionName could not be located in the dynamic link library
JS3250.dll". I
think if it did, perhaps we could get RegisterFunction to work.
Original comment by craigthe...@gmail.com
on 15 Mar 2010 at 2:07
I looked into jsapi.h (e.g. https://developer.mozilla.org/en/JSAPI_User_Guide)
and
there is no such a thing as JS_CallUCFunctionName. It seems to be some old
stuff.
Original comment by Dusan.Ha...@gmail.com
on 15 Mar 2010 at 6:05
Original issue reported on code.google.com by
craigthe...@gmail.com
on 8 Mar 2010 at 1:40