farshadmohajeri / extpascal

Automatically exported from code.google.com/p/extpascal
49 stars 28 forks source link

ExtJSWrapper can't compile application on Lazarus? #74

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Lazarus 1.0.8 r40573 FPC 2.6.2 x86_64-win64-win32/win64
extpascal r819

..\ExtJSWrapper\Ext.pas(19878,43) Error: Wrong type "TArrayOfString" in array 
constructor

in 

function TExtAbstractComponent.AddCls(Cls : TArrayOfString) : TExtFunction; 
begin
  JSCode(JSName + '.AddCls(' + VarToJSON([Cls]) + ');', 'TExtAbstractComponent');
  Result := Self;
end; 
....

Original issue reported on code.google.com by pavelar...@gmail.com on 13 Jun 2013 at 4:22

GoogleCodeExporter commented 9 years ago
I tried to compile ExtPascalSamples from r819 on Delphi 7 (under wine) and 
Lazarus 1.0.14 with FPC 2.6.2 on Ubuntu 13.10 (AMD 64 bits).

You can't put a dynamic array like TArrayOfString as an element of an array of 
const on delphi 7 and FPC 2.6.2. But you can put an array of variants.

As a workaround, I tried to convert instances of TArrayOfString and 
TArrayOfInteger in arrays of variants, using VarArrayCreate.

I added two function in Ext.pas :
function VarArray_from_TArrayOfString( _a: TArrayOfString): Variant;
function VarArray_from_TArrayOfInteger( _a: TArrayOfInteger): Variant;

and modified all the references to instance of TArrayOfString and 
TArrayOfInteger in array constructors.

I imagine the best would be to modify the source generator ExtToPascal, 
replacing in array constructors references to the arrays by something like:
{$IFDEF FPC}
  ' VarArray_from_'+ArrayType+'('+ArrayName+')'
{$ELSE}
  ArrayName
{$ENDIF}
where ArrayName is the variable with the name of the array like 'Cls'
and ArrayType is the variable with the name of type of the array like 
'TArrayOfString'.

Then I could compile Ext.pas.
I got some errors in code specific to ExtPascalSamples. It seems a unit ExtForm 
is missing. I commented out lines referencing properties that do not exist.
The project compiled but I got an access violation in ExtPAscal.pas in 
TExtThread.GetSequence, it seems this code is called before the creation of a 
TExtThread on a nil reference. Maybe in the initialization clause of unit 
ExtPascal, the creation of ExtUtilTextMetrics induces a call to CreateJSName 
before the thread is created in the dpr file.
I didn't go further for now.

I join a diff file for Ext.pas and  my modified Ext.pas.

I hope this helps.
Yours sincerely,
Jean SUZINEAU

Original comment by jean.suz...@gmail.com on 24 Feb 2014 at 10:05

Attachments: