Coder Social home page Coder Social logo

delphi-javascript's People

Watchers

 avatar

delphi-javascript's Issues

Issue when function parameter has type Variant

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:

jQuery

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

IdHTTP and JS

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

TStreamWriter issue. Real reason of problem

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

New functions declarations for wrapper

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

XE 3 64 bit

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

Delphi XE2 and error "Insufficient RTTI available to support this operation" for TADOTable, TADOQuery....

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:

Using TFileStream cause error in XE2 and XE4.

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

Error(?) in function "procedure CheckDebugBreak(Engine: TJSEngine; var code: string);"

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

Memory leaks in TJSEngine.registerGlobalFunctions

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:

Perhaps one more bug when using wrapper in XE2.

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:

JQuery?

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

A lot of memory leaks

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

RTTI. Using of TADOTable/TADOQuery. XE2, XE4, XE5.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.