Skip to content

Commit

Permalink
D2009 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderlan.anjos committed Apr 12, 2009
1 parent ce21c29 commit afcea2b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
8 changes: 4 additions & 4 deletions BlockSocket.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ TBlockSocket = class
procedure Connect(Host : string; pPort : word);
procedure Purge;
procedure Close;
function RecvString : string;
procedure SendString(const Data: string);
function RecvString : AnsiString;
procedure SendString(const Data: AnsiString);
function WaitingData : cardinal;
function CanRead(Timeout: Integer): Boolean;
function Error : integer;
Expand Down Expand Up @@ -171,7 +171,7 @@ procedure TBlockSocket.Purge;

// Returns the socket input stream as a string
// @see Error
function TBlockSocket.RecvString : string;
function TBlockSocket.RecvString : AnsiString;
var
Tam : integer;
begin
Expand All @@ -186,7 +186,7 @@ function TBlockSocket.RecvString : string;
@param Data String to send
@see Error
}
procedure TBlockSocket.SendString(const Data: string); begin
procedure TBlockSocket.SendString(const Data: AnsiString); begin
fpSend(Socket, @Data[1], length(Data), 0);
end;

Expand Down
37 changes: 31 additions & 6 deletions ExtPascal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ TExtObject = class
function IsParent(CName : string): boolean;
function VarToJSON(A : array of const) : string; overload;
function VarToJSON(Exts : TExtObjectList) : string; overload;
function VarToJSON(Strs : TArrayOfString) : string; overload;
function VarToJSON(Ints : TArrayOfInteger) : string; overload;
function VarToJSON(Strs : {$IF Defined(FPC) or (RTLVersion < 20)}TArrayOfString {$ELSE}array of string {$IFEND}) : string; overload;
function VarToJSON(Ints : {$IF Defined(FPC) or (RTLVersion < 20)}TArrayOfInteger{$ELSE}array of integer{$IFEND}) : string; overload;
function ParamAsInteger(ParamName : string) : integer;
function ParamAsDouble(ParamName : string) : double;
function ParamAsBoolean(ParamName : string) : boolean;
Expand Down Expand Up @@ -945,9 +945,14 @@ function TExtObject.JSExpression(Expression : string; MethodsValues : array of c
for I := 0 to high(MethodsValues) do
with MethodsValues[I] do
if VType = vtObject then begin
Command := TExtFunction(VObject).ExtractJSCommand; // FPC idiosincrasy
Command := TExtFunction(VObject).ExtractJSCommand; // FPC idiosincrasy
{$IFNDEF UNICODE}
VAnsiString := pointer(Command);
VType := vtAnsiString;
{$ELSE}
VUnicodeString := pointer(Command);
VType := vtUnicodeString;
{$ENDIF}
end;
JSReturns.Values[Mark] := Format(Expression, MethodsValues);
end;
Expand Down Expand Up @@ -1209,21 +1214,33 @@ function TExtObject.Ajax(MethodName : string; Params : array of const; IsEvent :
case VType of
vtAnsiString : lParams := lParams + '"+' + string(VAnsiString) + '+"';
vtString : lParams := lParams + '"+' + VString^ + '+"';
vtWideString : lParams := lParams + '"+' + string(VWideString) + '+"';
{$IFDEF UNICODE}
vtUnicodeString : lParams := lParams + '"+' + string(VUnicodeString) + '+"';
{$ENDIF}
vtObject : begin
lParams := lParams + '"+' + TExtObject(VObject).ExtractJSCommand + '+"';
TExtObject(VObject).JSCommand := '';
end;
vtInteger : lParams := lParams + IntToStr(VInteger);
vtBoolean : lParams := lParams + IfThen(VBoolean, 'true', 'false');
vtExtended : lParams := lParams + FloatToStr(VExtended^);
vtCurrency : lParams := lParams + CurrToStr(VCurrency^);
vtInt64 : lParams := lParams + IntToStr(VInt64^);
vtVariant : lParams := lParams + string(VVariant^);
vtChar : lParams := lParams + '"+' + VChar + '+"';
vtWideChar : lParams := lParams + '"+' + VWideChar + '+"';
end
else
case VType of
vtAnsiString : lParams := lParams + '&' + string(VAnsiString) + '=';
vtString : lParams := lParams + '&' + VString^ + '=';
vtWideString : lParams := lParams + '&' + string(VWideString) + '=';
{$IFDEF UNICODE}
vtUnicodeString : lParams := lParams + '&' + string(VUnicodeString) + '=';
{$ENDIF}
vtChar : lParams := lParams + '&' + VChar + '=';
vtWideChar : lParams := lParams + '&' + VWideChar + '=';
else
JSCode('Ext.Msg.show({title:"Error",msg:"Ajax method: ' + MethodName +
' has an invalid parameter name in place #' + IntToStr(I+1) + '",icon:Ext.Msg.ERROR,buttons:Ext.Msg.OK});');
Expand Down Expand Up @@ -1333,10 +1350,18 @@ function TExtObject.VarToJSON(A : array of const) : string;
end;
vtAnsiString: Result := Result + StrToJS(string(VAnsiString));
vtString: Result := Result + StrToJS(VString^);
vtWideString: Result := Result + StrToJS(string(VWideString));
{$IFDEF UNICODE}
vtUnicodeString: Result := Result + StrToJS(string(VUnicodeString));
{$ENDIF}
vtInteger: Result := Result + IntToStr(VInteger);
vtBoolean: Result := Result + IfThen(VBoolean, 'true', 'false');
vtExtended: Result := Result + FloatToStr(VExtended^);
vtVariant: Result := Result + string(VVariant^)
vtCurrency: Result := Result + CurrToStr(VCurrency^);
vtInt64: Result := Result + IntToStr(VInt64^);
vtVariant: Result := Result + string(VVariant^);
vtChar: Result := Result + VChar;
vtWideChar: Result := Result + VWideChar;
end;
if I < high(A) then Result := Result + ',';
inc(I);
Expand All @@ -1361,7 +1386,7 @@ function TExtObject.VarToJSON(Exts : TExtObjectList) : string; begin
@param Strs An <link TArrayOfString, array of strings> to convert
@return JSON representation of Strs
}
function TExtObject.VarToJSON(Strs : TArrayOfString) : string;
function TExtObject.VarToJSON(Strs : {$IF Defined(FPC) or (RTLVersion < 20)}TArrayOfString{$ELSE}array of string{$IFEND}) : string;
var
I : integer;
begin
Expand All @@ -1378,7 +1403,7 @@ function TExtObject.VarToJSON(Strs : TArrayOfString) : string;
@param Ints An <link TArrayOfInteger, array of integers> to convert
@return JSON representation of Ints
}
function TExtObject.VarToJSON(Ints : TArrayOfInteger) : string;
function TExtObject.VarToJSON(Ints : {$IF Defined(FPC) or (RTLVersion < 20)}TArrayOfInteger{$ELSE}array of integer{$IFEND}) : string;
var
I : integer;
begin
Expand Down
7 changes: 3 additions & 4 deletions ExtPascalSamples.dpr
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
program ExtPascalSamples;
{.$DEFINE SERVICE}
uses
ExtPascal, ExtPascalUtils, SysUtils, {$IFNDEF WebServer}FCGIApp{$ELSE}IdExtHTTPServer{$ENDIF}, {$IFDEF SERVICE}Services,{$ENDIF}
Classes, Ext, ExtGlobal, ExtData, ExtForm, ExtGrid, ExtUtil, ExtAir, ExtSql, ExtDd, ExtLayout, ExtMenu, ExtState, ExtTree;

{$IFNDEF WebServer}
{$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
{$ENDIF}
uses
ExtPascal, ExtPascalUtils, SysUtils, {$IFNDEF WebServer}FCGIApp{$ELSE}IdExtHTTPServer{$ENDIF}, {$IFDEF SERVICE}Services,{$ENDIF}
Classes, Ext, ExtGlobal, ExtData, ExtForm, ExtGrid, ExtUtil, ExtAir, ExtSql, ExtDd, ExtLayout, ExtMenu, ExtState, ExtTree;

type
TSamples = class(TExtThread)
Expand Down
4 changes: 2 additions & 2 deletions ExtToPascal.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ uses

const
UsesPublished = false;

function FixReserved(S : string) : string;
const
Reserved = '.and.array.as.asm.begin.case.class.const.constructor.destructor.destroy.dispinterface.div.do.downto.else.end.except.exports.'+
Expand Down Expand Up @@ -1205,7 +1205,7 @@ begin
AllClasses := TStringList.Create;
Units := TStringList.Create;
writeln('ExtToPascal wrapper, version ', ExtPascalVersion);
writeln('(c) 2008 by Wanderlan Santos dos Anjos, BSD license'^M^J);
writeln('(c) 2009 by Wanderlan Santos dos Anjos, BSD license'^M^J);
writeln('Reading HTML files...');
T := now;
repeat
Expand Down
4 changes: 2 additions & 2 deletions SocketsDelphi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ function fpaccept(s:cint; addrx : psockaddr; addrlen : plongint):cint; begin
fpAccept:=WinSockDelphi.Accept(S,WinSockDelphi.PSockAddr(Addrx), AddrLen);
end;

function fpgetsockname(s:cint; name : psockaddr; namelen : psocklen):cint; begin
fpGetSockName:=WinSockDelphi.GetSockName(S,WinSockDelphi.TSockAddr(name^),nameLen^);
function fpgetsockname(s:cint; name : psockaddr; namelen : psocklen):cint; begin
fpGetSockName:=WinSockDelphi.GetSockName(S, WinSockDelphi.PSockAddr(name)^,nameLen^);
end;

type
Expand Down
13 changes: 0 additions & 13 deletions WinSockDelphi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -931,19 +931,6 @@ TWSAProtocol_InfoW = record

SERVICE_TYPE_VALUE_OBJECTIDA = 'ObjectId';
SERVICE_TYPE_VALUE_OBJECTIDW : PWideChar = 'ObjectId';

{$IFDEF UNICODE}
SERVICE_TYPE_VALUE_SAPID = SERVICE_TYPE_VALUE_SAPIDW;
SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTW;
SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTW;
SERVICE_TYPE_VALUE_OBJECTID = SERVICE_TYPE_VALUE_OBJECTIDW;
{$ELSE}
SERVICE_TYPE_VALUE_SAPID = SERVICE_TYPE_VALUE_SAPIDA;
SERVICE_TYPE_VALUE_TCPPORT = SERVICE_TYPE_VALUE_TCPPORTA;
SERVICE_TYPE_VALUE_UDPPORT = SERVICE_TYPE_VALUE_UDPPORTA;
SERVICE_TYPE_VALUE_OBJECTID = SERVICE_TYPE_VALUE_OBJECTIDA;
{$ENDIF}

{$endif}{FPC}

{ SockAddr Information }
Expand Down

0 comments on commit afcea2b

Please sign in to comment.