Initial version - Not usable yet
This commit is contained in:
2
bepascal/bepascal/codegen/README
Normal file
2
bepascal/bepascal/codegen/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This tool read XML description of BeAPIs and generate pascal and C/C++ source code
|
||||
to access this API from pascal source code
|
||||
87
bepascal/bepascal/codegen/apireader.pp
Normal file
87
bepascal/bepascal/codegen/apireader.pp
Normal file
@@ -0,0 +1,87 @@
|
||||
unit apireader;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
xmlread, dom;
|
||||
|
||||
type
|
||||
TNode = class(TObject)
|
||||
private
|
||||
FNode : TDOMNode;
|
||||
public
|
||||
constructor Create(Node : TDOMNode); virtual;
|
||||
end;
|
||||
TClassess = class(TNode)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
TNamedItem = class(TNode)
|
||||
private
|
||||
protected
|
||||
function GetName : string;
|
||||
public
|
||||
property Name : string read GetName;
|
||||
end;
|
||||
|
||||
TClasse = class(TNamedItem)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
TFunction = class(TNamedItem)
|
||||
private
|
||||
protected
|
||||
public
|
||||
function IsDestructor : boolean;
|
||||
end;
|
||||
TTypedItem = class(TNamedItem)
|
||||
private
|
||||
protected
|
||||
function GetType : string;
|
||||
public
|
||||
property Typ : string read GetType;
|
||||
end;
|
||||
TParam = class(TTypedItem)
|
||||
private
|
||||
protected
|
||||
public
|
||||
end;
|
||||
TResultType = class(TNode)
|
||||
private
|
||||
protected
|
||||
function GetType : string;
|
||||
public
|
||||
property Typ : string read GetType;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
constructor TNode.Create(Node : TDOMNode);
|
||||
begin
|
||||
inherited Create;
|
||||
FNode := Node;
|
||||
end;
|
||||
|
||||
function TNamedItem.GetName : string;
|
||||
begin
|
||||
Result := FNode.Attributes.GetNamedItem('NAME').NodeValue;
|
||||
end;
|
||||
|
||||
function TFunction.IsDestructor : boolean;
|
||||
begin
|
||||
Result := (Name[1] = '~');
|
||||
end;
|
||||
|
||||
function TTypedItem.GetType : string;
|
||||
begin
|
||||
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;
|
||||
end;
|
||||
|
||||
function TResultType.GetType : string;
|
||||
begin
|
||||
Result := FNode.Attributes.GetNamedItem('TYPE').NodeValue;
|
||||
end;
|
||||
|
||||
end.
|
||||
20
bepascal/bepascal/codegen/codegen.pp
Normal file
20
bepascal/bepascal/codegen/codegen.pp
Normal file
@@ -0,0 +1,20 @@
|
||||
program codegen;
|
||||
|
||||
uses
|
||||
dom, xmlread, apireader;
|
||||
|
||||
var
|
||||
aDoc : TXMLDocument;
|
||||
Classes : TClassess;
|
||||
begin
|
||||
if ParamCount > 0 then
|
||||
begin
|
||||
ReadXMLFile(aDoc, Paramstr(1));
|
||||
Classes := TClassess.Create(aDoc);
|
||||
try
|
||||
finally
|
||||
Classes.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user