:= operator changes.

This commit is contained in:
oscarl-2
2003-12-20 03:09:02 +00:00
parent c96a342645
commit 4c483f63e7
2 changed files with 56 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002 - 2003 Olivier Coursiere
Oscar Lesta
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@@ -15,8 +16,7 @@
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
unit BeObj;
unit beobj;
interface interface
@@ -39,7 +39,7 @@ type
protected protected
FCPlusObject : TCPlusObject; FCPlusObject : TCPlusObject;
public public
constructor Create; virtual; constructor Create; virtual; // XXX "An inherited method is hidden by TBEOBJECT.CREATE"
constructor CreatePas; virtual; constructor CreatePas; virtual;
constructor Wrap(ACPlusObject : TCPlusObject); virtual; constructor Wrap(ACPlusObject : TCPlusObject); virtual;
destructor UnWrap; virtual; destructor UnWrap; virtual;
@@ -52,11 +52,49 @@ type
procedure SendText(aText : string); procedure SendText(aText : string);
procedure SetSendTextProc(aProc : TSendTextProc); procedure SetSendTextProc(aProc : TSendTextProc);
{
This operator is added to mimic (at least to some point) BeAPI's
const uint32 B_SOME_CONST = '_SMC';
With this operator, we can do something like this on pascal:
const
_B_SOME_CONST = '_SMC';
var
B_SOME_CONST : Longword;
And in the initialization:
B_SOME_CONST := _B_SOME_CONST; // Or just use 'TEXT' here and avoid the const.
}
operator := (ValueStr : string) : Longword;
implementation implementation
uses uses
SysUtils; SysUtils;
operator := (ValueStr : string) : Longword;
const
kOpErrorMsg = 'This operator (:=) requires four-characters strings.';
var
Num : array[1..4] of Byte;
i : Integer;
begin
{$IFOPT C+} {$define assert_was_on} {$ENDIF}
{$C+}
Assert(Length(ValueStr) = 4, kOpErrorMsg);
{$IFNDEF assert_was_on} {$C-} {$ENDIF}
for i := 1 to 4 do
{$IFDEF ENDIAN_LITTLE}
Num[i] := Ord(ValueStr[5 - i]);
{$ELSE}
Num[i] := Ord(ValueStr[i]);
{$ENDIF}
Result := Longword(Num);
end;
var var
PasObject_GetPasClassName_hook : Pointer; cvar; external; PasObject_GetPasClassName_hook : Pointer; cvar; external;
SendTextProc : TSendTextProc; SendTextProc : TSendTextProc;
@@ -107,8 +145,10 @@ begin
end; end;
procedure TBeObject.Debug; procedure TBeObject.Debug;
{$IFDEF DEBUG}
var var
size : cardinal; size : cardinal;
{$ENDIF}
begin begin
{$IFDEF DEBUG} {$IFDEF DEBUG}
size := 0; size := 0;
@@ -133,7 +173,7 @@ begin
Self.CPlusObject := nil; Self.CPlusObject := nil;
end; end;
// end TBeObject // end TBeObject
initialization initialization
PasObject_GetPasClassName_hook := @PasObject_GetPasClassName_hook_func; PasObject_GetPasClassName_hook := @PasObject_GetPasClassName_hook_func;
@@ -142,5 +182,4 @@ initialization
finalization finalization
PasObject_GetPasClassName_hook := nil; PasObject_GetPasClassName_hook := nil;
end. end.

View File

@@ -1,5 +1,6 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002 - 2003 Olivier Coursiere
Oscar Lesta
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@@ -21,7 +22,6 @@ When this unit is used in a BePascal project, the SendText function
in beobj.pp send a "dbug" message to a fdb client. in beobj.pp send a "dbug" message to a fdb client.
When fdblib is not in the project, SendText in beobj just do nothing. When fdblib is not in the project, SendText in beobj just do nothing.
} }
unit fdblib; unit fdblib;
interface interface
@@ -31,10 +31,10 @@ procedure force;
implementation implementation
uses uses
appdefs, message, application, messenger, handler, os, supportdefs, beobj; BeObj, Application, Handler, Message, Messenger, OS, SupportDefs;
const const
B_DEBUG : array[0..3] of Char = ('d', 'b', 'u', 'g'); B_DEBUG = 'dbug';
procedure SendMessage(message : BMessage); procedure SendMessage(message : BMessage);
var var
@@ -68,7 +68,7 @@ begin
if be_app <> nil then if be_app <> nil then
begin begin
local := text + #0; local := text + #0;
message := BMessage.Create(trans(B_DEBUG)); message := BMessage.Create(Longword(B_DEBUG));
try try
message.AddString(PChar('dbstring'), @local[1]); message.AddString(PChar('dbstring'), @local[1]);
SendMessage(message); SendMessage(message);
@@ -90,7 +90,6 @@ begin
end; end;
} }
procedure force; procedure force;
begin begin
writeln('force'); writeln('force');
@@ -103,5 +102,4 @@ initialization
finalization finalization
SendText('App end'); SendText('App end');
end. end.