Fizerator / delphi-javascript

Automatically exported from code.google.com/p/delphi-javascript
0 stars 0 forks source link

Using TFileStream cause error in XE2 and XE4. #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 andre...@diatomenterprises.com on 5 Dec 2013 at 10:56

GoogleCodeExporter commented 8 years ago
There is no way to handle var paameters in js, youy will need either to create 
inherited tjsfilestream with functions for returning read data or something.

var parameters are not supported from javascript

Original comment by n.ame...@gmail.com on 6 Dec 2013 at 9:19

GoogleCodeExporter commented 8 years ago
PS i upload a new fix where at least no av will be raised but still expected 
array data will not be filled

Original comment by n.ame...@gmail.com on 6 Dec 2013 at 9:23