2 Star 6 Fork 5

吕不为 / dbhelper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
复件 UIntfApp.pas 7.90 KB
一键复制 编辑 原始数据 按行查看 历史
吕不为 提交于 2017-08-30 09:00 . init
unit UIntfApp;
interface
uses
SysUtils, Windows, Classes, Forms, MainFrm, UDM, USQLOperator, WrapDelphi, WrapDelphiClasses,
USQLEditorControl, PythonEngine,frmEditor;
type
IModifyObjectEditor = interface
function SetObjectName(OBjectType: TsType; TableObj: TBaseTableItems; FieldObj: TBaseTableItems): boolean;
end;
type
TPyMainForm = class(TPyDelphiPersistent)
constructor Create(APythonType: TPythonType); override;
constructor CreateWith(PythonType: TPythonType; args: PPyObject); override;
function Repr: PPyObject; override;
class function DelphiObjectClass: TClass; override;
end;
//SQLҳ
{$METHODINFO ON}
TSQLPage = class(TPersistent)
private
procedure SetText(const Value: string);
function GetText: string;
published
public
constructor Create;
destructor Destroy; override;
published
procedure Clear;
property Text: string read GetText write SetText;
end;
{$METHODINFO OFF}
{$METHODINFO ON}
TEditor = class(TCollectionItem)
private
procedure SetText(const Value: string);
function GetText: string;
published
public
constructor Create;
destructor Destroy; override;
published
procedure Clear;
property Text: string read GetText write SetText;
end;
TEditorsAccess = class(TContainerAccess)
function GetContainer: TEditorList;
public
function GetItem(AIndex: Integer): PPyObject; override;
function GetSize: Integer; override;
function IndexOf(AValue: PPyObject): Integer; override;
class function ExpectedContainerClass: TClass; override;
class function SupportsIndexOf: Boolean; override;
class function Name: string; override;
property Container: TEditorList read GetContainer;
end;
TPyEditors = class(TPyDelphiPersistent)
constructor Create(APythonType: TPythonType); override;
constructor CreateWith(PythonType: TPythonType; args: PPyObject); override;
function Repr: PPyObject; override;
class procedure RegisterMethods(PythonType: TPythonType); override;
class function DelphiObjectClass: TClass; override;
function GetCount(args: PPyObject): PPyObject; cdecl;
function DoAdd(args: PPyObject): PPyObject; cdecl;
function DoActiveEditor(args: PPyObject): PPyObject; cdecl;
function DoGetItem(args: PPyObject): PPyObject; cdecl;
class function GetContainerAccessClass: TContainerAccessClass; override;
end;
var
GI_ModifyObjectEditor: IModifyObjectEditor;
SQLPage: TSQLPage;
// Editors: TEditors;
implementation
uses frmEditor;
{ TPyMainForm }
constructor TPyMainForm.Create(APythonType: TPythonType);
begin
inherited;
DelphiObject := TMainForm.Create(nil);
Owned := True;
end;
constructor TPyMainForm.CreateWith(PythonType: TPythonType; args: PPyObject);
begin
inherited;
end;
class function TPyMainForm.DelphiObjectClass: TClass;
begin
Result := TMainForm;
end;
function TPyMainForm.Repr: PPyObject;
begin
Result := GetPythonEngine.VariantAsPyObject('TMainForm');
end;
{ TSQLPage }
procedure TSQLPage.Clear;
begin
MainForm.edtSQLViewer.Clear;
end;
constructor TSQLPage.Create;
begin
end;
destructor TSQLPage.Destroy;
begin
inherited;
end;
function TSQLPage.GetText: string;
begin
Result := MainForm.edtSQLViewer.Text;
end;
procedure TSQLPage.SetText(const Value: string);
begin
MainForm.edtSQLViewer.Text := Value;
end;
{ TEditor }
procedure TEditor.Clear;
begin
end;
constructor TEditor.Create;
begin
end;
destructor TEditor.Destroy;
begin
inherited;
end;
function TEditor.GetText: string;
begin
end;
procedure TEditor.SetText(const Value: string);
begin
end;
{ TEditors }
procedure TEditors.CloaseAll;
begin
end;
constructor TEditors.Create(pc: TSQLEditorControl);
begin
Fpc := pc;
end;
destructor TEditors.Destroy;
begin
inherited;
end;
function TEditors.GetCount: integer;
begin
Result := GI_EditorFactory.GetEditorCount;
end;
function TEditors.GetItem(Index: Integer): TEditor;
begin
Result := TEditor(inherited Items[Index]);
end;
function TEditors.GetText: string;
begin
end;
procedure TEditors.SetItem(Index: Integer; const Value: TEditor);
begin
inherited Items[Index] := Value;
end;
procedure TEditors.SetText(const Value: string);
begin
end;
{ TPyEditors }
constructor TPyEditors.Create(APythonType: TPythonType);
begin
inherited;
DelphiObject := TEditors.Create(MainForm.pgcSQLEditor);
Owned := True;
end;
constructor TPyEditors.CreateWith(PythonType: TPythonType; args: PPyObject);
begin
inherited;
end;
class function TPyEditors.DelphiObjectClass: TClass;
begin
Result := TEditors;
end;
function TPyEditors.DoActiveEditor(args: PPyObject): PPyObject;
begin
with GetPythonEngine do
begin
if (PyArg_ParseTuple(args, ':TEditor', []) <> 0) then
begin
end;
end;
end;
function TPyEditors.DoAdd(args: PPyObject): PPyObject;
var
LEditor: IEditor;
sFileName: Pchar;
FileName: string;
i: Integer;
begin
with GetPythonEngine do
begin
if (PyArg_ParseTuple(args, 's:TEditor', [@sFileName]) <> 0) then
begin
if GI_EditorFactory <> nil then
begin
FileName := ExpandFileName(sFileName);
if FileExists(FileName) then
begin
// CommandsDataModule.RemoveMRUEntry(FileName);
Assert(GI_EditorFactory <> nil);
for i := GI_EditorFactory.GetEditorCount - 1 downto 0 do
begin
LEditor := GI_EditorFactory.Editor[i];
if CompareText(LEditor.GetFileName, sFileName) = 0 then
begin
LEditor.Activate;
Result := ReturnNone;
exit;
end;
end;
end;
LEditor := GI_EditorFactory.CreateTabSheet(MainForm.pgcSQLEditor);
if sFileName = '.py' then
begin
LEditor.SetEditorType(etPython);
FileName := '';
end;
if sFileName = '.sql' then
begin
LEditor.SetEditorType(etSQL);
FileName := '';
end;
if LEditor <> nil then
LEditor.OpenFile(FileName);
Result := ReturnNone;
GI_ActiveEditor := LEditor;
end;
end;
end;
end;
function TPyEditors.DoGetItem(args: PPyObject): PPyObject;
begin
with GetPythonEngine do
begin
Adjust(@Self);
Result := Py_BuildValue('i', [2]);
end;
end;
class function TPyEditors.GetContainerAccessClass: TContainerAccessClass;
begin
Result := TEditorsAccess;
end;
function TPyEditors.GetCount(args: PPyObject): PPyObject;
begin
with GetPythonEngine do
begin
Adjust(@Self);
Result := Py_BuildValue('i', [GI_EditorFactory.GetEditorCount]);
end;
end;
class procedure TPyEditors.RegisterMethods(PythonType: TPythonType);
begin
inherited;
PythonType.AddMethod('__GetItem', @TPyEditors.DoGetItem, '');
PythonType.AddMethod('Add', @TPyEditors.DoAdd, '');
PythonType.AddGetSet('Count', @TPyEditors.GetCount, nil, '', nil);
end;
function TPyEditors.Repr: PPyObject;
begin
with GetPythonEngine do begin
Result := VariantAsPyObject('TEditors');
end;
end;
{ TEditorsAccess }
class function TEditorsAccess.ExpectedContainerClass: TClass;
begin
Result := TEditors;
end;
function TEditorsAccess.GetContainer: TEditors;
begin
Result := TEditors(inherited Container);
end;
function TEditorsAccess.GetItem(AIndex: Integer): PPyObject;
begin
Result := Wrap(Container.Items[AIndex]);
end;
function TEditorsAccess.GetSize: Integer;
begin
Result := Container.Count;
end;
function TEditorsAccess.IndexOf(AValue: PPyObject): Integer;
begin
end;
class function TEditorsAccess.Name: string;
begin
Result := 'TEditors.Actions';
end;
class function TEditorsAccess.SupportsIndexOf: Boolean;
begin
Result := True;
end;
end.
Delphi
1
https://gitee.com/lvhongqing/dbhelper.git
git@gitee.com:lvhongqing/dbhelper.git
lvhongqing
dbhelper
dbhelper
master

搜索帮助