Skip to content

Commit 8813e78

Browse files
committed
sync WrapDelphi*
1 parent ed17210 commit 8813e78

16 files changed

+16654
-16651
lines changed

python4lazarus/Sources/Core/WrapDelphi.pas

Lines changed: 3417 additions & 2971 deletions
Large diffs are not rendered by default.
Lines changed: 191 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -1,195 +1,191 @@
1-
{$I Definition.Inc}
2-
3-
unit WrapDelphiActnList;
4-
5-
interface
6-
7-
uses
8-
Classes, PythonEngine, WrapDelphi, WrapDelphiClasses, ActnList;
9-
10-
type
11-
{
12-
Access to the Action items of the TCustomActionList collection.
13-
}
14-
TActionListAccess = class(TContainerAccess)
15-
private
16-
function GetContainer: TCustomActionList;
17-
public
18-
function GetItem(AIndex : Integer) : PPyObject; override;
19-
function GetSize : Integer; override;
20-
function IndexOf(AValue : PPyObject) : Integer; override;
21-
22-
class function ExpectedContainerClass : TClass; override;
23-
class function SupportsIndexOf : Boolean; override;
24-
class function Name : String; override;
25-
26-
property Container : TCustomActionList read GetContainer;
27-
end;
28-
29-
{
30-
PyObject wrapping TCustomActionList
31-
Exposes properties ActionCount and Actions
32-
}
33-
TPyDelphiCustomActionList = class (TPyDelphiComponent)
34-
private
35-
function GetDelphiObject: TCustomActionList;
36-
procedure SetDelphiObject(const Value: TCustomActionList);
37-
protected
38-
// property getters
39-
function Get_ActionCount(AContext : Pointer) : PPyObject; cdecl;
40-
function Get_Actions(AContext : Pointer) : PPyObject; cdecl;
41-
public
42-
// Class methods
43-
class function DelphiObjectClass : TClass; override;
44-
class procedure RegisterGetSets( PythonType : TPythonType ); override;
45-
class function GetContainerAccessClass : TContainerAccessClass; override;
46-
// Properties
47-
property DelphiObject: TCustomActionList read GetDelphiObject write SetDelphiObject;
48-
end;
49-
50-
51-
implementation
52-
53-
{ Register the wrappers, the globals and the constants }
54-
type
55-
TActnListRegistration = class(TRegisteredUnit)
56-
public
57-
function Name : String; override;
58-
procedure RegisterWrappers(APyDelphiWrapper : TPyDelphiWrapper); override;
59-
procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper); override;
60-
end;
61-
62-
{ TActnListRegistration }
63-
64-
procedure TActnListRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);
65-
begin
66-
inherited;
67-
end;
68-
69-
function TActnListRegistration.Name: String;
70-
begin
71-
Result := 'ActnList';
72-
end;
73-
74-
procedure TActnListRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper);
75-
begin
76-
inherited;
77-
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomActionList);
78-
end;
79-
80-
{ TPyDelphiCustomActionList }
81-
82-
class function TPyDelphiCustomActionList.DelphiObjectClass: TClass;
83-
begin
84-
Result := TCustomActionList;
85-
end;
86-
87-
class function TPyDelphiCustomActionList.GetContainerAccessClass: TContainerAccessClass;
88-
begin
89-
Result := TActionListAccess;
90-
end;
91-
92-
function TPyDelphiCustomActionList.GetDelphiObject: TCustomActionList;
93-
begin
94-
Result := TCustomActionList(inherited DelphiObject);
95-
end;
96-
97-
function TPyDelphiCustomActionList.Get_ActionCount(AContext: Pointer): PPyObject;
98-
begin
99-
with GetPythonEngine do begin
100-
Adjust(@Self);
101-
Result := PyInt_FromLong(DelphiObject.ActionCount);
102-
end;
103-
end;
104-
105-
function TPyDelphiCustomActionList.Get_Actions(AContext: Pointer): PPyObject;
106-
begin
107-
with GetPythonEngine do begin
108-
Adjust(@Self);
109-
Result := PyDelphiWrapper.DefaultContainerType.CreateInstance;
110-
with PythonToDelphi(Result) as TPyDelphiContainer do
111-
Setup(Self.PyDelphiWrapper, TActionListAccess.Create(Self.PyDelphiWrapper, Self.DelphiObject));
112-
end;
113-
end;
114-
115-
class procedure TPyDelphiCustomActionList.RegisterGetSets(
116-
PythonType: TPythonType);
117-
begin
118-
inherited;
119-
with PythonType do
120-
begin
121-
AddGetSet('ActionCount', @TPyDelphiCustomActionList.Get_ActionCount, nil,
122-
'Indicates the number of actions in the action list.', nil);
123-
AddGetSet('Actions', @TPyDelphiCustomActionList.Get_Actions, nil,
124-
'Lists the actions maintained by the action list.', nil);
125-
end;
126-
end;
127-
128-
procedure TPyDelphiCustomActionList.SetDelphiObject(
129-
const Value: TCustomActionList);
130-
begin
131-
inherited DelphiObject := Value;
132-
end;
133-
134-
{ TActionListAccess }
135-
136-
class function TActionListAccess.ExpectedContainerClass: TClass;
137-
begin
138-
Result := TCustomActionList;
139-
end;
140-
141-
function TActionListAccess.GetContainer: TCustomActionList;
142-
begin
143-
Result := TCustomActionList(inherited Container);
144-
end;
145-
146-
function TActionListAccess.GetItem(AIndex: Integer): PPyObject;
147-
begin
148-
Result := Wrap(Container.Actions[AIndex]);
149-
end;
150-
151-
function TActionListAccess.GetSize: Integer;
152-
begin
153-
Result := Container.ActionCount;
154-
end;
155-
156-
function TActionListAccess.IndexOf(AValue: PPyObject): Integer;
157-
var
158-
i : Integer;
159-
_obj : TPyObject;
160-
_item : TBasicAction;
161-
begin
162-
Result := -1;
163-
with GetPythonEngine do
164-
begin
165-
if IsDelphiObject(AValue) then
166-
begin
167-
_obj := PythonToDelphi(AValue);
168-
if (_obj is TPyDelphiObject) and (TPyDelphiObject(_obj).DelphiObject is TBasicAction) then
169-
begin
170-
_item := TBasicAction(TPyDelphiObject(_obj).DelphiObject);
171-
for i := 0 to Container.ActionCount-1 do
172-
if Container.Actions[i] = _item then
173-
begin
174-
Result := i;
175-
Break;
176-
end;
177-
end;
178-
end;
179-
end;
180-
end;
181-
182-
class function TActionListAccess.Name: String;
183-
begin
184-
Result := 'TCustomActionList.Actions';
185-
end;
186-
187-
class function TActionListAccess.SupportsIndexOf: Boolean;
188-
begin
189-
Result := True;
190-
end;
191-
192-
193-
initialization
194-
RegisteredUnits.Add( TActnListRegistration.Create );
195-
end.
1+
{$I Definition.Inc}
2+
3+
unit WrapDelphiActnList;
4+
5+
interface
6+
7+
uses
8+
Classes, PythonEngine, WrapDelphi, WrapDelphiClasses, ActnList;
9+
10+
type
11+
{
12+
Access to the Action items of the TCustomActionList collection.
13+
}
14+
TActionListAccess = class(TContainerAccess)
15+
private
16+
function GetContainer: TCustomActionList;
17+
public
18+
function GetItem(AIndex : Integer) : PPyObject; override;
19+
function GetSize : Integer; override;
20+
function IndexOf(AValue : PPyObject) : Integer; override;
21+
22+
class function ExpectedContainerClass : TClass; override;
23+
class function SupportsIndexOf : Boolean; override;
24+
class function Name : String; override;
25+
26+
property Container : TCustomActionList read GetContainer;
27+
end;
28+
29+
{
30+
PyObject wrapping TCustomActionList
31+
Exposes properties ActionCount and Actions
32+
}
33+
TPyDelphiCustomActionList = class (TPyDelphiComponent)
34+
private
35+
function GetDelphiObject: TCustomActionList;
36+
procedure SetDelphiObject(const Value: TCustomActionList);
37+
protected
38+
// property getters
39+
function Get_ActionCount(AContext : Pointer) : PPyObject; cdecl;
40+
function Get_Actions(AContext : Pointer) : PPyObject; cdecl;
41+
public
42+
// Class methods
43+
class function DelphiObjectClass : TClass; override;
44+
class procedure RegisterGetSets( PythonType : TPythonType ); override;
45+
class function GetContainerAccessClass : TContainerAccessClass; override;
46+
// Properties
47+
property DelphiObject: TCustomActionList read GetDelphiObject write SetDelphiObject;
48+
end;
49+
50+
51+
implementation
52+
53+
{ Register the wrappers, the globals and the constants }
54+
type
55+
TActnListRegistration = class(TRegisteredUnit)
56+
public
57+
function Name : String; override;
58+
procedure RegisterWrappers(APyDelphiWrapper : TPyDelphiWrapper); override;
59+
procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper); override;
60+
end;
61+
62+
{ TActnListRegistration }
63+
64+
procedure TActnListRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);
65+
begin
66+
inherited;
67+
end;
68+
69+
function TActnListRegistration.Name: String;
70+
begin
71+
Result := 'ActnList';
72+
end;
73+
74+
procedure TActnListRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper);
75+
begin
76+
inherited;
77+
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomActionList);
78+
end;
79+
80+
{ TPyDelphiCustomActionList }
81+
82+
class function TPyDelphiCustomActionList.DelphiObjectClass: TClass;
83+
begin
84+
Result := TCustomActionList;
85+
end;
86+
87+
class function TPyDelphiCustomActionList.GetContainerAccessClass: TContainerAccessClass;
88+
begin
89+
Result := TActionListAccess;
90+
end;
91+
92+
function TPyDelphiCustomActionList.GetDelphiObject: TCustomActionList;
93+
begin
94+
Result := TCustomActionList(inherited DelphiObject);
95+
end;
96+
97+
function TPyDelphiCustomActionList.Get_ActionCount(AContext: Pointer): PPyObject;
98+
begin
99+
Adjust(@Self);
100+
Result := GetPythonEngine.PyInt_FromLong(DelphiObject.ActionCount);
101+
end;
102+
103+
function TPyDelphiCustomActionList.Get_Actions(AContext: Pointer): PPyObject;
104+
begin
105+
Adjust(@Self);
106+
Result := PyDelphiWrapper.DefaultContainerType.CreateInstance;
107+
with PythonToDelphi(Result) as TPyDelphiContainer do
108+
Setup(Self.PyDelphiWrapper, TActionListAccess.Create(Self.PyDelphiWrapper, Self.DelphiObject));
109+
end;
110+
111+
class procedure TPyDelphiCustomActionList.RegisterGetSets(
112+
PythonType: TPythonType);
113+
begin
114+
inherited;
115+
with PythonType do
116+
begin
117+
AddGetSet('ActionCount', @TPyDelphiCustomActionList.Get_ActionCount, nil,
118+
'Indicates the number of actions in the action list.', nil);
119+
AddGetSet('Actions', @TPyDelphiCustomActionList.Get_Actions, nil,
120+
'Lists the actions maintained by the action list.', nil);
121+
end;
122+
end;
123+
124+
procedure TPyDelphiCustomActionList.SetDelphiObject(
125+
const Value: TCustomActionList);
126+
begin
127+
inherited DelphiObject := Value;
128+
end;
129+
130+
{ TActionListAccess }
131+
132+
class function TActionListAccess.ExpectedContainerClass: TClass;
133+
begin
134+
Result := TCustomActionList;
135+
end;
136+
137+
function TActionListAccess.GetContainer: TCustomActionList;
138+
begin
139+
Result := TCustomActionList(inherited Container);
140+
end;
141+
142+
function TActionListAccess.GetItem(AIndex: Integer): PPyObject;
143+
begin
144+
Result := Wrap(Container.Actions[AIndex]);
145+
end;
146+
147+
function TActionListAccess.GetSize: Integer;
148+
begin
149+
Result := Container.ActionCount;
150+
end;
151+
152+
function TActionListAccess.IndexOf(AValue: PPyObject): Integer;
153+
var
154+
i : Integer;
155+
_obj : TPyObject;
156+
_item : TBasicAction;
157+
begin
158+
Result := -1;
159+
with GetPythonEngine do
160+
begin
161+
if IsDelphiObject(AValue) then
162+
begin
163+
_obj := PythonToDelphi(AValue);
164+
if (_obj is TPyDelphiObject) and (TPyDelphiObject(_obj).DelphiObject is TBasicAction) then
165+
begin
166+
_item := TBasicAction(TPyDelphiObject(_obj).DelphiObject);
167+
for i := 0 to Container.ActionCount-1 do
168+
if Container.Actions[i] = _item then
169+
begin
170+
Result := i;
171+
Break;
172+
end;
173+
end;
174+
end;
175+
end;
176+
end;
177+
178+
class function TActionListAccess.Name: String;
179+
begin
180+
Result := 'TCustomActionList.Actions';
181+
end;
182+
183+
class function TActionListAccess.SupportsIndexOf: Boolean;
184+
begin
185+
Result := True;
186+
end;
187+
188+
189+
initialization
190+
RegisteredUnits.Add( TActnListRegistration.Create );
191+
end.

0 commit comments

Comments
 (0)