<div dir="ltr">Fantastico Antonio...<div><br></div><div>Ya me van a explicar porque hay que realizar esos cambios... porque esto se trata de 2 cosas....</div><div><br></div><div>1) Trasmitir mis conocimientos de TDD al grupo.</div>
<div>2) Aprender a fondo FreePacal...</div><div><br></div><div>Ahora estoy haciendo un ejemplo con el framework Brook y consultado una base de datos para mostrarlo en una grilla con Bootstrap... realmente el lenguaje es fantastico.</div>
<div><br></div><div>Saludos y Gracias,</div><div><br></div><div>Pancho</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-01 8:40 GMT-03:00 Antonio Evora <span dir="ltr"><<a href="mailto:aevorar@gmail.com" target="_blank">aevorar@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Buenas Francisco.<br>
He realizado las siguientes modificaciones para que compile y se ejecute bajo linux (por si deseas añadirlas):<br>
<br>
<code><br>
unit NoRefCountObject;<br>
<br>
interface<br>
<br>
type<br>
<br>
// TNoRefCountObject<br>
//<br>
{: Base object to implement interfaces without reference counting }<br>
TNoRefCountObject = class(TObject, IInterface)<br>
protected<br>
function QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$<u></u>ELSE}const{$ENDIF} iid : tguid;out obj) : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$<u></u>ENDIF};<br>
function _AddRef: longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$<u></u>ENDIF};<br>
function _Release: longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$<u></u>ENDIF};<br>
end;<br>
<br>
implementation<br>
<br>
{ TNoRefCountObject }<br>
<br>
function TNoRefCountObject.<u></u>QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$<u></u>ELSE}const{$ENDIF} iid : tguid;out obj) : longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$<u></u>ENDIF};<br>
begin<br>
if GetInterface(IID, Obj) then<br>
Result := 0<br>
else<br>
Result := E_NOINTERFACE;<br>
end;<br>
<br>
function TNoRefCountObject._AddRef: longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$<u></u>ENDIF};<br>
begin<br>
Result := -1;<br>
end;<br>
<br>
function TNoRefCountObject._Release: longint;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$<u></u>ENDIF};<br>
begin<br>
Result := -1;<br>
end;<br>
<br>
end.<br>
</code><br>
<br>
<code><br>
unit VariantsUtil;<br>
<br>
interface<br>
<br>
uses<br>
// Delphi<br>
Variants,<br>
SysUtils<br>
;<br>
<br>
type<br>
<br>
TVariantArray = array of Variant;<br>
<br>
//: convert an array of const to an array of variants<br>
procedure ConstArrayToVariantArray(const AValues : array of const;<br>
var ADest: TVariantArray);<br>
<br>
//: convert an array of variant to a text representation<br>
function VariantArrayToString(const AVarArray: TVariantArray): string;<br>
<br>
//: convert a variant to an integer<br>
function Var2Int(Value: Variant): Integer;<br>
//: convert a variant to a pointer<br>
function Var2Ptr(Value: Variant): Pointer;<br>
//: convert a pointer to a variant<br>
function Ptr2Var(Value: Pointer): Variant;<br>
//: convert a variant to an object<br>
function Var2Obj(Value: Variant): TObject;<br>
//: convert an object to a variant<br>
function Obj2Var(Value: TObject): Variant;<br>
//: convert a variant to an interface<br>
function Var2Intf(Value: Variant): IInterface;<br>
//: convert an interface to a variant<br>
function Intf2Var(Value: IInterface): Variant;<br>
<br>
<br>
implementation<br>
<br>
<br>
// ConstArrayToVariantArray<br>
//<br>
procedure ConstArrayToVariantArray(const AValues : array of const;<br>
var ADest: TVariantArray);<br>
var<br>
i : Integer;<br>
begin<br>
SetLength(ADest, Length(AValues));<br>
for i := Low(AValues) to High(AValues) do<br>
begin<br>
with AValues[i] do<br>
begin<br>
case VType of<br>
vtInteger: ADest[i] := VInteger;<br>
vtInt64: ADest[i] := VInt64^;<br>
vtBoolean: ADest[i] := VBoolean;<br>
vtChar: ADest[i] := VChar;<br>
vtExtended: ADest[i] := VExtended^;<br>
vtString: ADest[i] := VString^;<br>
vtPointer: ADest[i] := Integer(VPointer);<br>
vtPChar: ADest[i] := StrPas(VPChar);<br>
vtObject: ADest[i]:= Pointer(VObject);<br>
vtAnsiString: ADest[i] := String(VAnsiString);<br>
vtCurrency: ADest[i] := VCurrency^;<br>
vtVariant: ADest[i] := VVariant^;<br>
vtInterface: ADest[i]:= Integer(VPointer);<br>
else<br>
raise Exception.Create ('invalid data type ' + IntToStr(VType))<br>
end;<br>
end;<br>
end;<br>
end;<br>
<br>
<br>
// VariantArrayToString<br>
//<br>
function VariantArrayToString(const AVarArray: TVariantArray): string;<br>
var<br>
I: Integer;<br>
begin<br>
Result := '';<br>
for i := Low(AVarArray) to High(AVarArray) do<br>
begin<br>
if Length(Result) > 0 then<br>
Result := Result + ', ';<br>
if VarIsNull(AVarArray[I]) then<br>
Result := Result + 'ignored'<br>
else<br>
Result := Result + VarToStr(AVarArray[I]);<br>
end;<br>
Result := '('+Result+')';<br>
end;<br>
<br>
<br>
function Var2Int(Value: Variant): Integer;<br>
begin<br>
Result := Value;<br>
end;<br>
<br>
function Var2Ptr(Value: Variant): Pointer;<br>
begin<br>
Result := Pointer(Var2Int(Value));<br>
end;<br>
<br>
function Ptr2Var(Value: Pointer): Variant;<br>
begin<br>
Result := Integer(Value);<br>
end;<br>
<br>
function Var2Obj(Value: Variant): TObject;<br>
begin<br>
Result := TObject(Var2Ptr(Value));<br>
end;<br>
<br>
function Obj2Var(Value: TObject): Variant;<br>
begin<br>
Result := pointer(Value);<br>
end;<br>
<br>
function Var2Intf(Value: Variant): IInterface;<br>
begin<br>
Result := IInterface(Var2Ptr(Value));<br>
end;<br>
<br>
function Intf2Var(Value: IInterface): Variant;<br>
begin<br>
Result := Ptr2Var(Value);<br>
end;<br>
<br>
end.<br>
</code><br>
<br>
Tiene buena pinta.<br>
<br>
Un cordial saludo.<br>
<br>
______________________________<u></u>_________________<br>
Lazarus-es mailing list<br>
<a href="mailto:Lazarus-es@lists.lazarus.freepascal.org" target="_blank">Lazarus-es@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus-es" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus-es</a><br>
</blockquote></div><br></div>