patiencer / delphi-javascript Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/delphi-javascript
Automatically exported from code.google.com/p/delphi-javascript
Delphi XE2.
Let's say we have some global function in Delphi:
class function TSMJSGlobalFunctions._VariantToInt (varVal : variant) : integer;
begin
Result := Integer (varVal);
end;
This is how from JavaScript we calling this function:
function doF () {
_Debug ("VariantToInt 100 = " + _VariantToInt ("100"));
}
NOTE: "_Debug" function, just another global function, which showing result in
some window.
So, when from JavaScript we call "VariantToInt ("100")", in Delphi function
will be passed value UNASSIGNED, instead actual value equal to "100" (type
string).
How I fixed it:
In unit "jsintf.pas"
class function TJSClass.JSValToTValue(cx: PJSContext; t: PTypeInfo; vp: jsval;
RttiType: TRttiType): TValue;
From {
Result := TValue.Empty;
case t^.Kind of
}
To {
Result := TValue.Empty;
//-=-
intVarType := t^.Kind;
if intVarType = tkVariant then
begin
case vp.tag of
JSVAL_TAG_STRING :
intVarType := tkString;
JSVAL_TAG_INT32 :
intVarType := tkInteger;
end;
end;
//-=-
case intVarType of
}
New variable added:
intVarType : System.TypInfo.TTypeKind;
Original issue reported on code.google.com by [email protected]
on 11 Dec 2013 at 9:11
Attachments:
How to use jQuery with this library? To parse HTML for example?
Original issue reported on code.google.com by [email protected]
on 11 Aug 2013 at 11:57
Hello!
How to pre parse this with delphi-javascript?
IdHTTP1.GET('http://www.hotmail.com');
Hotmail will say no JS enabled and Cookies. :)
Original issue reported on code.google.com by [email protected]
on 9 Nov 2012 at 2:46
Hi
Is there a version available for Delphi XE5?
Thanks.
Original issue reported on code.google.com by [email protected]
on 30 Sep 2014 at 8:37
Hello!
The reason why TStreamWriter write only zero-char in file:
when you using Delphi, calling function:
procedure TStreamWriter.WriteLine(const Value: string);
when you using JavaScript, calling function:
procedure TStreamWriter.WriteLine(Value: Char);
Looks like function that responsible to found proper overloaded method doesn't
work correctly.
With best regards,
Original issue reported on code.google.com by [email protected]
on 6 Dec 2013 at 12:18
Part 1.
Added in file “js15decl.pas”:
procedure JS_SetOperationCallback (cx : PJSContext; funcTransition : pointer);
cdecl; external libName;
function JS_GetOperationCallback (cx : PJSContext) : pointer; cdecl; external
libName;
procedure JS_TriggerOperationCallback (cx : PJSContext); cdecl; external
libName;
Purpose of these functions:
"To enforce application limits on the amount of time a script may run. (In this
case, the callback may terminate the script by returning “JS_FALSE”.)"
https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_SetOper
ationCallback
Part 2.
Added in file “js15decl.pas”:
JSFunctionCallback = procedure (const proc : JSFunction; const scr : JSScript;
const cx : PJSContext; entering : integer); cdecl;
procedure JS_SetFunctionCallback (cx : PJSContext; proc : JSFunctionCallback);
cdecl; external libName;
function JS_GetFunctionCallback (cx : PJSContext) : pointer; cdecl; external
libName;
Purpose of this function:
"Sets a callback to be run whenever a JavaScript function is invoked or exited.
This lets you trace the execution of code, and is particularly useful for
JavaScript tracers and profilers since it works across all run modes
(interpreter, method JIT, trace JIT). Using this function may have a
significant performance impact. See Function tracing for an example."
https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_Reference/JS_SetFunc
tionCallback
Original issue reported on code.google.com by [email protected]
on 19 Dec 2013 at 10:09
Hello!
I would like to use this with Indy 64 bit in XE 3 but dll looks 32 bit so it
wont work :(
Please recompile the dll! :(
Original issue reported on code.google.com by [email protected]
on 8 Nov 2012 at 8:05
please update js32.dll and js64.dll to thread-safe build!
Original issue reported on code.google.com by [email protected]
on 18 Dec 2013 at 9:21
file "JSINTF.PAS"
Following methods cause exception "Insufficient RTTI available to support this
operation" in XE2 when calling ".MethodKind".
Suggested fix/patch below.
If you (dear developer) have more nice solution how to fix this error, please
go ahead! :)
Thanks!
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-
//-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-
const
cnstStrExcludedMethod =
'FilterOnBookmarks;BookmarkValid;CompareBookmarks;GetBlobFieldData;' +
'AppendRecord;FreeBookmark;GetBookmark;GotoBookmark;InsertRecord;' +
'SetFields;';
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-
//-=- Fix for XE2 and error "Insufficient RTTI available to support this
operation" by A.Z.
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-
{$IF CompilerVersion = 23}
if (Pos (methodName + ';', cnstStrExcludedMethod) > 0) then
begin
if exclude or m.IsConstructor or m.IsDestructor or m.IsStatic or m.IsClassMethod or (m.Visibility < Visibility) then
continue;
end
else
if exclude or m.IsConstructor or m.IsDestructor or m.IsStatic or m.IsClassMethod or (not (m.MethodKind in [mkProcedure, mkFunction])) or (m.Visibility < Visibility) then
continue;
{$ELSE}
if exclude or m.IsConstructor or m.IsDestructor or m.IsStatic or m.IsClassMethod or (not(m.MethodKind in [mkProcedure, mkFunction])) or (m.Visibility < Visibility) then
continue;
{$IFEND}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-
//-=-
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-
Original issue reported on code.google.com by [email protected]
on 27 Nov 2013 at 9:13
Attachments:
Tested under Delphi XE2 and XE4. Completely the same behavior.
Trying to run following JavaScript code:
function SomeFunction ()
{
var strBuffer = new Array (10);
var intX = 0;
var file = new TFileStream ("C:\\Temp\\test2.txt", 0);
intX = file.Read (strBuffer, 10); //-=- Exception will occure in this line
file.Free ();
return ("OK");
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
First I get error in this function. I try to fixed it as showed below.
#1.
class function TJSClass.JSArgsToTValues(params: TArray<TRttiParameter>; cx:
PJSContext; jsobj: PJSObject; argc: uintN; argv: pjsval): TArray<TValue>;
From {
for i := 0 to High(params) do
begin
param := params[i];
//-=- Next line cause error: "raised exception class $C0000005 with message 'access violation at 0x00452a48: read of address 0x00000004'"
//-=- Because "param.ParamType = nil"
if (param.ParamType.Handle = TypeInfo(TJSNativeCallParams)) then
}
To {
for i := 0 to High(params) do
begin
param := params[i];
//-=-
if (param.ParamType = nil) then
Continue;
//-=-
if (param.ParamType.Handle = TypeInfo(TJSNativeCallParams)) then
}
Then I get error in next function. I try to fixed it as showed below.
#2.
function RttiMethodFindOverload(const LMethod : TRttiMethod; t : TRttiType;
Instance: TValue): boolean;
From {
vp := argv[LIndex];
//-=- Next line cause error: "raised exception class $C0000005 with message 'access violation at 0x00452a48: read of address 0x00000004'"
//-=- Because "Params[LIndex].ParamType = nil"
case Params[LIndex].ParamType.typeKind of
tkEnumeration:
}
To {
vp := argv[LIndex];
//-=-
if Params[LIndex].ParamType = nil then
Continue;
//-=-
case Params[LIndex].ParamType.typeKind of
tkEnumeration:
}
Finally I get error in next function. I have no idea how to fix this.
class function TJSClass.JSMethodCall(cx: PJSContext; argc: uintN; vp: pjsval):
JSBool;
found := true;
//-=- Next line cause error: "Invalid class typecast"
methodResult := m.Invoke(Obj.FNativeObj, args);
if methodResult.Kind <> tkUnknown then
Original issue reported on code.google.com by [email protected]
on 5 Dec 2013 at 10:56
Hello!
Will this work with delphi-javascript?
Original issue reported on code.google.com by [email protected]
on 12 Nov 2012 at 9:34
jsintf.pas
procedure CheckDebugBreak(Engine: TJSEngine; var code: string);
#1
instead of
if pos('DebugBreak()', Code) > 1 then
should be
if pos('DebugBreak()', Code) >= 1 then
#2
instead of
if (pos('DebugBreak()', lines[i]) > 1) and (trim(lines[i]) = 'DebugBreak();') then
should be
if (pos('DebugBreak()', lines[i]) >= 1) and (trim(lines[i]) = 'DebugBreak();') then
Original issue reported on code.google.com by [email protected]
on 8 Nov 2013 at 12:06
What steps will reproduce the problem?
Try the attached project (Delphi XE2)
What is the expected output? What do you see instead?
No memory leaks
What version of the product are you using? On what operating system?
Last trunk on Delphi XE2 on Windows 7
The problem seems to be the PAnsiChar function name used in the
TJSFunctionSpecArray because it is allocated but is nowhere deallocated.
Original issue reported on code.google.com by [email protected]
on 18 Jul 2012 at 10:51
Attachments:
memory leak when demo run with xe3!
Original issue reported on code.google.com by [email protected]
on 27 Nov 2012 at 2:32
Perhaps one more bug when using wrapper in XE2. I don’t have ability to test
it under different version of Delphi.
File: “JSINTF.PAS”
procedure TJSClassProto.DefineJSClass(AClass: TClass; AClassFlags:
TJSClassFlagAttributes);
From
{
if exclude or (Length(ip.ReadMethod.GetParameters) = 0) or (ip.Visibility < mvPublic) then
continue;
}
To
{
if exclude or (ip.ReadMethod = nil) or (Length(ip.ReadMethod.GetParameters) = 0) or (ip.Visibility < mvPublic) then
continue;
}
Sometimes, for some method, for example for some “Destroy” method
ip.ReadMethod is nil, therefor calling ip.ReadMethod.GetParameters cause
---------------------------
Debugger Exception Notification
---------------------------
Project XXXXXXXXXX.exe raised exception class $C0000005 with message 'access
violation at 0x0440b9d3: read of address 0x00000000'.
---------------------------
Break Continue Help
---------------------------
Original issue reported on code.google.com by [email protected]
on 29 Nov 2013 at 7:56
Attachments:
It'll be great if you add support for Delphi 2010 which also supports enhanced
RTTI.
Original issue reported on code.google.com by [email protected]
on 13 Dec 2011 at 5:52
Hello!
Can i execute JQuery with it? And other librarys?
Thanks
Original issue reported on code.google.com by [email protected]
on 18 Dec 2012 at 11:38
What steps will reproduce the problem?
Run the demo program with the following line in the dpr
ReportMemoryLeaksOnShutdown := true;
What is the expected output? What do you see instead?
I'm expect no memory leaks but I see a lot of memory leaks.
What version of the product are you using? On what operating system?
Delphi XE2
Please provide any additional information below.
I'm using the last trunk version
Original issue reported on code.google.com by [email protected]
on 23 Jul 2012 at 2:57
For reproduce error do following:
1. Create DataModule (name: DM). Put TADOConnection (connected to MS SQL 2008R2
database), TADOTable/TADOQuery.
2. Create in runtime JS Engine (name: oSMJSEngine), register/create
CreateJSObject for DataModule.
Code:
TJSClass.CreateJSObject (DM, oSMJSEngine, 'DM', [cfaInheritedMethods,
cfaInheritedProperties, cfaProtectedMethods, cfaProtectedFields,
cfaGlobalFields, cfaGlobalProperties]);
I try to play with TJSClassFlagAttributes but it didn't help also.
3. From JavaScript try to run following command:
DM.ADOTable1.FieldByName ("SomeFieldName").AsString
And you will get error in unit "jsintf.pas", in function "procedure
TJSClassProto.DefineJSClass(AClass: TClass; AClassFlags:
TJSClassFlagAttributes);", starting at line 2014:
defineEnum({ pt.Name + '_' + } GetEnumName(pt.Handle, i), 1 shl i);
Error message:
Project xxx.exe raised exception class $C0000005 with message 'access violation
at 0x00642891: read of address 0x000000c8'.
It's also related to error: Insufficient RTTI available to support this
operation -- this is what I got in XE2.
I am using Windows 7 x64 bit. Projest was compiled for x86 platform.
I am using latest copy of "delphi-javascipt" project -- was taken from your SVN
repository, by end of Oct/2013.
Thanks!
Original issue reported on code.google.com by [email protected]
on 30 Oct 2013 at 12:54
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.