Begining of writing support

This commit is contained in:
ocoursiere
2002-10-27 18:21:49 +00:00
parent 53c034aa85
commit 961db320c9
6 changed files with 1013 additions and 10 deletions

View File

@@ -1,40 +1,104 @@
{ BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit apireader;
{$H+} // use AnsiStrings
interface
uses
xmlread, dom;
Classes, SysUtils, xmlread, dom;
type
TNode = class(TObject)
private
function GetCount : integer;
function GetNode(Index : integer) : TNode;
protected
FNode : TDOMNode;
FChildren : TStringList;
public
constructor Create(Node : TDOMNode); virtual;
destructor Destroy; override;
procedure Start; virtual;
procedure Middle; virtual;
procedure Ends; virtual;
property Count : integer read GetCount;
property Nodes[Index : integer] : TNode read GetNode;
end;
TClassess = class(TNode)
TClassess = class;
TDocument = class(TNode)
private
function GetClasses(Index : integer) : TClassess;
protected
public
constructor Create(Node : TDOMNode); override;
procedure Start; override;
procedure Middle; override;
procedure Ends; override;
property Classes[Index : integer] : TClassess read GetClasses;
end;
TClasse = class;
TClassess = class(TNode)
private
function GetClasse(Index : integer) : TClasse;
protected
public
constructor Create(Node : TDOMNode); override;
procedure Start; override;
procedure Middle; override;
procedure Ends; override;
property Classes[Index : integer] : TClasse read GetClasse;
end;
TNamedItem = class(TNode)
private
private
protected
function GetName : string;
public
property Name : string read GetName;
end;
TFunction = class;
TClasse = class(TNamedItem)
private
private
function GetFunction(Index : integer) : TFunction;
protected
function GetAncestor : string;
public
constructor Create(Node : TDOMNode); override;
procedure Start; override;
procedure Ends; override;
property Ancestor : string read GetAncestor;
property Functions[Index : integer] : TFunction read GetFunction;
end;
TResultType = class;
TParam = class;
TFunction = class(TNamedItem)
private
FResultType : TResultType;
function GetParam(Index : integer) : TParam;
protected
public
constructor Create(Node : TDOMNode); override;
destructor Destroy; override;
function IsDestructor : boolean;
property ResultType : TResultType read FResultType;
property Params[Index : integer] : TParam read GetParam;
end;
TTypedItem = class(TNamedItem)
private
@@ -58,15 +122,266 @@ type
implementation
uses
sourcewrite, typmap;
// Debug proc
procedure NodeInfo(Node : TDOMNode);
begin
WriteLn(Node.NodeName + ',' + Node.NodeValue + ',' + IntToStr(Node.NodeType));
end;
constructor TNode.Create(Node : TDOMNode);
begin
inherited Create;
FNode := Node;
end;
function TNamedItem.GetName : string;
destructor TNode.Destroy;
var
i : integer;
begin
Result := FNode.Attributes.GetNamedItem('NAME').NodeValue;
if FChildren <> nil then
begin
for i := 0 to FChildren.Count - 1 do
begin
if FChildren.Objects[i] <> nil then
FChildren.Objects[i].Free;
end;
FChildren.Free;
end;
inherited;
end;
function TNode.GetCount : integer;
begin
if FChildren <> nil then
Result := FChildren.Count
else
Result := 0;
end;
function TNode.GetNode(Index : integer) : TNode;
begin
Result := FChildren.Objects[Index] as TNode;
end;
procedure TNode.Start;
begin
Write('Start : ');
if FNode <> nil then
NodeInfo(FNode);
end;
procedure TNode.Middle;
var
i : integer;
begin
Write('Middle : ');
if FNode <> nil then
begin
NodeInfo(FNode);
for i := 0 to Count - 1 do
begin
Nodes[i].Start;
Nodes[i].Middle;
Nodes[i].Ends;
end;
end;
end;
procedure TNode.Ends;
begin
Write('Ends : ');
if FNode <> nil then
NodeInfo(FNode);
end;
constructor TDocument.Create(Node : TDOMNode);
var
i : integer;
aClasses : TClassess;
List : TStringList;
begin
if Node.HasChildNodes then
begin
List := TStringList.Create;
for i := 0 to Node.ChildNodes.count - 1 do
begin
aClasses := TClassess.Create(Node.ChildNodes.Item[i]);
List.AddObject(IntToStr(i), aClasses);
end;
FChildren := List;
end;
end;
function TDocument.GetClasses(Index : integer) : TClassess;
begin
Result := FChildren.Objects[Index] as TClassess;
end;
procedure TDocument.Start;
begin
end;
procedure TDocument.Middle;
var
i : integer;
begin
for i := 0 to Count - 1 do
begin
Classes[i].Start;
Classes[i].Middle;
Classes[i].Ends;
end;
end;
procedure TDocument.Ends;
begin
end;
constructor TClassess.Create(Node : TDOMNode);
var
i : integer;
aClasse : TClasse;
List : TStringList;
begin
inherited;
if Node.HasChildNodes then
begin
List := TStringList.Create;
for i := 0 to Node.ChildNodes.count - 1 do
begin
aClasse := TClasse.Create(Node.ChildNodes.Item[i]);
List.AddObject(aClasse.Name, aClasse);
end;
FChildren := List;
end;
end;
function TClassess.GetClasse(Index : integer) : TClasse;
begin
Result := FChildren.Objects[Index] as TClasse;
end;
function TNamedItem.GetName : string;
var
DomNode : TDOMNode;
begin
DomNode := FNode.Attributes.GetNamedItem('NAME');
if DomNode <> nil then
begin
Result := DomNode.NodeValue;
end;
end;
procedure TClassess.Start;
begin
SourceWriter.Pas.Add('');
end;
procedure TClassess.Middle;
var
i : integer;
begin
for i := 0 to Count - 1 do
begin
Nodes[i].Start;
Nodes[i].Middle;
Nodes[i].Ends;
end;
end;
procedure TClassess.Ends;
begin
end;
constructor TClasse.Create(Node : TDOMNode);
var
i : integer;
aFunc : TFunction;
List : TStringList;
begin
inherited;
if Node.HasChildNodes then
begin
List := TStringList.Create;
for i := 0 to Node.ChildNodes.count - 1 do
begin
aFunc := TFunction.Create(Node.ChildNodes.Item[i]);
WriteLn(aFunc.Name);
WriteLn('');
List.AddObject(aFunc.Name, aFunc);
end;
FChildren := List;
end;
end;
function TClasse.GetAncestor : string;
begin
if FNode.Attributes.GetNamedItem('ANCESTOR') <> nil then
Result := FNode.Attributes.GetNamedItem('ANCESTOR').NodeValue
else
Result := '';
end;
function TClasse.GetFunction(Index : integer) : TFunction;
begin
Result := FChildren.Objects[Index] as TFunction;
end;
procedure TClasse.Start;
begin
with SourceWriter.InterfacePas do
begin
Add('type');
Add(Format(' %s = class(%s)', [CppToPas(Name + ' *'), CppToPas(Ancestor + ' *')]));
Add(' private');
Add(' public');
end;
end;
procedure TClasse.Ends;
begin
with SourceWriter.InterfacePas do
begin
Add(' end;');
end;
end;
constructor TFunction.Create(Node : TDOMNode);
var
i : integer;
aParam : TParam;
List : TStringList;
begin
inherited;
if Node.HasChildNodes then
begin
List := TStringList.Create;
for i := 0 to Node.ChildNodes.count - 1 do
begin
if Node.ChildNodes.Item[i].Attributes.GetNamedItem('NAME') <> nil then
begin
aParam := TParam.Create(Node.ChildNodes.Item[i]);
WriteLn('Param : ' + aParam.Name + '; ' + 'Type : ' + aParam.Typ);
List.AddObject(aParam.Name, aParam);
end
else
begin
FResultType := TResultType.Create(Node.ChildNodes.Item[i]);
WriteLn('ResultType : ' + FResultType.Typ);
end;
end;
FChildren := List;
end;
end;
destructor TFunction.Destroy;
begin
if Assigned(FResultType) then
FResultType.Free;
inherited;
end;
function TFunction.IsDestructor : boolean;
@@ -74,6 +389,11 @@ begin
Result := (Name[1] = '~');
end;
function TFunction.GetParam(Index : integer) : TParam;
begin
Result := FChildren.Objects[Index] as TParam;
end;
function TTypedItem.GetType : string;
begin
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;

View File

@@ -1,17 +1,51 @@
{ BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
program codegen;
{$H+} // use AnsiStrings
uses
dom, xmlread, apireader;
dom, xmlread, apireader, typmap, codewrite, SysUtils;
var
aDoc : TXMLDocument;
Classes : TClassess;
HooksDoc : TXMLDocument;
Classes, Hooks : TDocument;
SrcGen : TSourceGen;
begin
if ParamCount > 0 then
begin
ReadXMLFile(aDoc, Paramstr(1));
Classes := TClassess.Create(aDoc);
ReadXMLFile(HooksDoc, 'hooks.xml');
Classes := TDocument.Create(aDoc);
try
Hooks := TDocument.Create(HooksDoc);
try
SrcGen := TSourceGen.Create(Classes, Hooks, StringReplace(Paramstr(1), '.xml', '', []));
try
SrcGen.Gen;
WriteLn('After gen');
finally
SrcGen.Free;
end;
finally
Hooks.Free;
end;
finally
Classes.Free;
end;

View File

@@ -0,0 +1,80 @@
{ BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit codewrite;
interface
{$H+} // use AnsiStrings
uses
Classes, SysUtils, apireader, sourcewrite;
type
TSourceGen = class(TObject)
private
FClasses : TDocument;
FHooks : TDocument;
protected
procedure Enum(Node : TNode);
public
constructor Create(Classes, Hooks : TDocument; FileName : string); virtual;
destructor Destroy; override;
procedure Gen;
end;
implementation
constructor TSourceGen.Create(Classes, Hooks : TDocument; FileName : string);
begin
inherited Create;
FClasses := Classes;
FHooks := Hooks;
SourceWriter := TSourceWriter.Create(FileName);
end;
destructor TSourceGen.Destroy;
begin
SourceWriter.Free;
inherited;
end;
procedure TSourceGen.Gen;
begin
Enum(FClasses);
end;
procedure TSourceGen.Enum(Node : TNode);
var
i : integer;
begin
if Node <> nil then
begin
for i := 0 to Node.Count - 1 do
begin
Node.Start;
WriteLn('Before Enum');
Node.Middle;
WriteLn('After enum');
Node.Ends;
end;
end;
end;
end.

View File

@@ -0,0 +1,396 @@
<?xml version="1.0"?>
<CLASSES>
<CLASSE NAME="BLooper" ANCESTOR="BHandler">
<FUNCTION NAME="DispatchMessage">
<PARAM NAME="message" TYPE="BMessage *"/>
<PARAM NAME="target" TYPE="BHandler *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="QuitRequested">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="bool"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BMessageFilter">
<FUNCTION NAME="Filter">
<PARAM NAME="message" TYPE="BMessage *"/>
<PARAM NAME="target" TYPE="BHandler **"/>
<RESULT TYPE="filter_result"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BHandler" ANCESTOR="BArchivable">
<FUNCTION NAME="MessageReceived">
<PARAM NAME="message" TYPE="BMessage *"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BApplication" ANCESTOR="BLooper">
<FUNCTION NAME="AboutRequested">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="AppActivated">
<PARAM NAME="active" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="ArgvReceived">
<PARAM NAME="argc" TYPE="int32"/>
<PARAM NAME="argv" TYPE="char **"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Pulse">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="ReadyToRun">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="RefsReceived">
<PARAM NAME="message" TYPE="BMessage *"/>
<RESULT NAME="" TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BWindow" ANCESTOR="BLooper">
<FUNCTION NAME="FrameMoved">
<PARAM NAME="origin" TYPE="BPoint *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="FrameResized">
<PARAM NAME="width" TYPE="float"/>
<PARAM NAME="height" TYPE="float"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="MenusBeginning">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="MenusEnded">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Minimize">
<PARAM NAME="minimize" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="ScreenChanged">
<PARAM NAME="frame" TYPE="BRect"/>
<PARAM NAME="mode" TYPE="color_space"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="WindowActivated">
<PARAM NAME="active" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="WorkspaceActivated">
<PARAM NAME="workspace" TYPE="int32"/>
<PARAM NAME="active" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="WorkspacesChanged">
<PARAM NAME="oldWorkspaces" TYPE="uint32"/>
<PARAM NAME="newWorkspaces" TYPE="uint32"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Zoom">
<PARAM NAME="origin" TYPE="BPoint"/>
<PARAM NAME="width" TYPE="float"/>
<PARAM NAME="height" TYPE="float"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BView" ANCESTOR="BHandler">
<FUNCTION NAME="AllAttached">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="AllDetached">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="AttachedToWindow">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DetachedFromWindow">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Draw">
<PARAM NAME="updateRect" TYPE="BRect"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawAfterChildren">
<PARAM NAME="updateRect" TYPE="BRect"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="FrameMoved">
<PARAM NAME="parentPoint" TYPE="BPoint"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="FrameResized">
<PARAM NAME="width" TYPE="float"/>
<PARAM NAME="height" TYPE="float"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="GetPreferredSize">
<PARAM NAME="width" TYPE="float *"/>
<PARAM NAME="height" TYPE="float *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="ResizeToPreferred">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="KeyDown">
<PARAM NAME="bytes" TYPE="char *"/>
<PARAM NAME="numBytes" TYPE="int32"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="KeyUp">
<PARAM NAME="bytes" TYPE="char *"/>
<PARAM NAME="numBytes" TYPE="int32"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="MouseDown">
<PARAM NAME="point" TYPE="BPoint"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="MouseMoved">
<PARAM NAME="point" TYPE="BPoint"/>
<PARAM NAME="transit" TYPE="uint32"/>
<PARAM NAME="message" TYPE="BMessage *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="MouseUp">
<PARAM NAME="point" TYPE="BPoint"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Pulse">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="TargetedByScrollView">
<PARAM NAME="scroller" TYPE="BScrollView *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="WindowActivated">
<PARAM NAME="active" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BControl" ANCESTOR="BView">
<FUNCTION NAME="SetEnabled">
<PARAM NAME="enabled" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetValue">
<PARAM NAME="value" TYPE="int32"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BMenu" ANCESTOR="BView">
<FUNCTION NAME="ScreenLocation">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="BPoint"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BMenuItem">
<FUNCTION NAME="Draw">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawContent">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BListView" ANCESTOR="BView" ANCESTOR="BInvoker">
<FUNCTION NAME="InitiateDrag">
<PARAM NAME="point" TYPE="BPoint"/>
<PARAM NAME="index" TYPE="int32"/>
<PARAM NAME="wasSelected" TYPE="bool"/>
<RESULT TYPE="bool"/>
</FUNCTION>
<FUNCTION NAME="SelectionChanged">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BListItem">
<FUNCTION NAME="DrawItem">
<PARAM NAME="owner" TYPE="BView *"/>
<PARAM NAME="itemRect" TYPE="BRect"/>
<PARAM NAME="drawEverything" TYPE="bool" DEFAULT="false"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Update">
<PARAM NAME="owner" TYPE="BView *"/>
<PARAM NAME="font" TYPE="BFont *"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BScrollBar" ANCESTOR="BView">
<FUNCTION NAME="ValueChanged">
<PARAM NAME="newValue" TYPE="float"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BShelf" ANCESTOR="BHandler">
<FUNCTION NAME="CanAcceptReplicantMessage">
<PARAM NAME="archive" TYPE="BMessage *"/>
<RESULT TYPE="bool"/>
</FUNCTION>
<FUNCTION NAME="CanAcceptReplicantView">
<PARAM NAME="destRect" TYPE="BRect"/>
<PARAM NAME="view" TYPE="BView *"/>
<PARAM NAME="archive" TYPE="BMessage *"/>
<RESULT TYPE="bool"/>
</FUNCTION>
<FUNCTION NAME="AdjustReplicantBy">
<PARAM NAME="destRect" TYPE="BRect"/>
<PARAM NAME="archive" TYPE="BMessage *"/>
<RESULT TYPE="BPoint"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BTab" ANCESTOR="BArchivable">
<FUNCTION NAME="Deselect">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawFocusMark">
<PARAM NAME="owner" TYPE="BView *"/>
<PARAM NAME="frame" TYPE="BRect"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawTab">
<PARAM NAME="owner" TYPE="BView *"/>
<PARAM NAME="frame" TYPE="BRect"/>
<PARAM NAME="position" TYPE="tab_position"/>
<PARAM NAME="full" TYPE="bool" DEFAULT="true"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawLabel">
<PARAM NAME="owner" TYPE="BView *"/>
<PARAM NAME="frame" TYPE="BRect"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Select">
<PARAM NAME="owner" TYPE="BView *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetEnabled">
<PARAM NAME="enabled" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetLabel">
<PARAM NAME="label" TYPE="char *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetView">
<PARAM NAME="view" TYPE="BView *"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BTabView" ANCESTOR="BView">
<FUNCTION NAME="AddTab">
<PARAM NAME="target" TYPE="BView *"/>
<PARAM NAME="tab" TYPE="BTab *" DEFAULT="NULL"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Draw">
<PARAM NAME="updateRect" TYPE="BRect"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawBox">
<PARAM NAME="selfTabRect" TYPE="BRect"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="DrawTabs">
<PARAM NAME="" TYPE="void"/>
<RESULT TYPE="BRect"/>
</FUNCTION>
<FUNCTION NAME="MakeFocus">
<PARAM NAME="focused" TYPE="bool" DEFAULT="true"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="RemoveTab">
<PARAM NAME="tab_index" TYPE="int32"/>
<RESULT TYPE="BTab *"/>
</FUNCTION>
<FUNCTION NAME="Select">
<PARAM NAME="tab" TYPE="int32"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetFocusTab">
<PARAM NAME="tab" TYPE="int32"/>
<PARAM NAME="focused" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetTabHeight">
<PARAM NAME="height" TYPE="float"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="SetTabWidth">
<PARAM NAME="width" TYPE="button_width"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="TabAt">
<PARAM NAME="tab_index" TYPE="int32"/>
<RESULT TYPE="BTab *"/>
</FUNCTION>
<FUNCTION NAME="TabFrame">
<PARAM NAME="tab_index" TYPE="int32"/>
<RESULT TYPE="BRect"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BTextView" ANCESTOR="BView">
<FUNCTION NAME="AcceptsDrop">
<PARAM NAME="message" TYPE="BMessage *"/>
<RESULT TYPE="bool"/>
</FUNCTION>
<FUNCTION NAME="AcceptsPaste">
<PARAM NAME="clipboard" TYPE="BClipboard *"/>
<RESULT TYPE="bool"/>
</FUNCTION>
<FUNCTION NAME="CanEndLine">
<PARAM NAME="offset" TYPE="int32"/>
<RESULT TYPE="bool"/>
</FUNCTION>
<FUNCTION NAME="DeleteText">
<PARAM NAME="start" TYPE="int32"/>
<PARAM NAME="finish" TYPE="int32"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="FindWord">
<PARAM NAME="offset" TYPE="int32"/>
<PARAM NAME="start" TYPE="int32 *"/>
<PARAM NAME="finish" TYPE="int32 *"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="GetDragParameters">
<PARAM NAME="drag" TYPE="BMessage *"/>
<PARAM NAME="bitmap" TYPE="BBitmap **"/>
<PARAM NAME="point" TYPE="BPoint *"/>
<PARAM NAME="handler" TYPE="BHandler **"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="InsertText">
<PARAM NAME="text" TYPE="char *"/>
<PARAM NAME="length" TYPE="int32"/>
<PARAM NAME="offset" TYPE="int32"/>
<PARAM NAME="runs" TYPE="text_run_array"/>
<RESULT TYPE="void"/>
</FUNCTION>
<FUNCTION NAME="Undo">
<PARAM NAME="clipboard" TYPE="BClipboard *"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
<CLASSE NAME="BButton" ANCESTOR="BControl">
<FUNCTION NAME="MakeDefault">
<PARAM NAME="flag" TYPE="bool"/>
<RESULT TYPE="void"/>
</FUNCTION>
</CLASSE>
</CLASSES>

View File

@@ -0,0 +1,133 @@
{ BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit sourcewrite;
{$H+} // use AnsiStrings
interface
uses
SysUtils, Classes, apireader;
const
Eol = #10;
CLicense =
'/* BePascal - A pascal wrapper around the BeOS API ' + Eol +
' Copyright (C) 2002 Olivier Coursiere ' + Eol +
' Eric Jourde ' + Eol +
' ' + Eol +
' This library is free software; you can redistribute it and/or ' + Eol +
' modify it under the terms of the GNU Library General Public ' + Eol +
' License as published by the Free Software Foundation; either ' + Eol +
' version 2 of the License, or (at your option) any later version. ' + Eol +
' ' + Eol +
' This library is distributed in the hope that it will be useful, ' + Eol +
' but WITHOUT ANY WARRANTY; without even the implied warranty of ' + Eol +
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ' + Eol +
' Library General Public License for more details. ' + Eol +
' ' + Eol +
' You should have received a copy of the GNU Library General Public ' + Eol +
' License along with this library; if not, write to the Free ' + Eol +
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ' + Eol +
'*/ ';
PasLicense =
'{ BePascal - A pascal wrapper around the BeOS API ' + Eol +
' Copyright (C) 2002 Olivier Coursiere ' + Eol +
' Eric Jourde ' + Eol +
' ' + Eol +
' This library is free software; you can redistribute it and/or ' + Eol +
' modify it under the terms of the GNU Library General Public ' + Eol +
' License as published by the Free Software Foundation; either ' + Eol +
' version 2 of the License, or (at your option) any later version. ' + Eol +
' ' + Eol +
' This library is distributed in the hope that it will be useful, ' + Eol +
' but WITHOUT ANY WARRANTY; without even the implied warranty of ' + Eol +
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ' + Eol +
' Library General Public License for more details. ' + Eol +
' ' + Eol +
' You should have received a copy of the GNU Library General Public ' + Eol +
' License along with this library; if not, write to the Free ' + Eol +
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ' + Eol +
'} ';
type
TSourceWriter = class(TObject)
private
FH : TStringList;
FCpp : TStringList;
FPas : TStringList;
FFileName : string;
FHooks : TDocument;
FInterfacePas : TStringList;
FImplementationPas : TStringList;
FImportFuncsPas : TStringList;
public
constructor Create(FileName : string); virtual;
destructor Destroy; override;
property H : TStringList read FH;
property Cpp : TStringList read FCpp;
property Pas : TStringList read FPas;
property Hooks : TDocument read FHooks write FHooks;
property InterfacePas : TStringList read FInterfacePas;
property ImplementationPas : TStringList read FImplementationPas;
property ImportFuncsPas : TStringList read FImportFuncsPas;
end;
var
SourceWriter : TSourceWriter;
implementation
constructor TSourceWriter.Create(FileName : string);
begin
inherited Create;
FFileName := FileName;
FH := TStringList.Create;
FH.Add(CLicense);
FCpp := TStringList.Create;
FCpp.Add(CLicense);
FPas := TStringList.Create;
FPas.Add(PasLicense);
FPas.Add('unit ' + LowerCase(FFileName) + ';');
FInterfacePas := TStringList.Create;
FImplementationPas := TStringList.Create;
FImportFuncsPas := TStringList.Create;
end;
destructor TSourceWriter.Destroy;
begin
// Writing files
FH.SaveToFile(FFileName + '.h');
FH.Free;
FCpp.SaveToFile(FFileName + '.cpp');
FCpp.Free;
FPas.Add(FInterfacePas.Text);
FPas.Add(FImplementationPas.Text);
FPas.Add(FImportFuncsPas.Text);
// write the end of pascal unit
FPas.Add('end.');
FPas.SaveToFile(LowerCase(FFileName) + '.pp');
FPas.Free;
FInterfacePas.Free;
FImplementationPas.Free;
FImportFuncsPas.Free;
inherited;
end;
end.

View File

@@ -0,0 +1,40 @@
unit typmap;
interface
uses
SysUtils, Classes;
function CppToPas(CppType : string) : string;
function PasToCpp(PasType : string) : string;
implementation
const
TypMapFileName = 'typemap.txt';
var
aTypMap : TStringList;
function CppToPas(CppType : string) : string;
begin
Result := aTypMap.Values[CppType];
if Result = '' then
aTypMap.Values[CppType] := '';
end;
function PasToCpp(PasType : string) : string;
begin
// To implement if necessary
Result := '';
end;
initialization
aTypMap := TStringList.Create;
aTypMap.LoadFromFile(TypMapFileName);
aTypMap.Sorted := True;
finalization
aTypMap.SaveToFile(TypMapFileName);
aTypMap.Free;
end.