Skip to content

Commit

Permalink
Class imports: Use .Create functions. Removed .Init procedures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Aug 2, 2023
1 parent ecbb09a commit be34980
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 652 deletions.
141 changes: 38 additions & 103 deletions Source/script/imports/lcl/simba.import_lcl_comctrls.pas

Large diffs are not rendered by default.

36 changes: 15 additions & 21 deletions Source/script/imports/lcl/simba.import_lcl_controls.pas
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ procedure _LapeControl_SetBounds(const Params: PParamArray); LAPE_WRAPPER_CALLIN
PControl(Params^[0])^.SetBounds(Pinteger(Params^[1])^, Pinteger(Params^[2])^, Pinteger(Params^[3])^, Pinteger(Params^[4])^);
end;

procedure _LapeControl_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeControl_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PControl(Params^[0])^ := TControl.Create(PComponent(Params^[1])^);
PControl(Result)^ := TControl.Create(PComponent(Params^[0])^);
end;

procedure _LapeControl_BringToFront(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -563,14 +563,9 @@ procedure _LapeWinControl_SetBounds(const Params: PParamArray); LAPE_WRAPPER_CAL
PWinControl(Params^[0])^.SetBounds(Pinteger(Params^[1])^, Pinteger(Params^[2])^, Pinteger(Params^[3])^, Pinteger(Params^[4])^);
end;

procedure _LapeWinControl_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeWinControl_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PWinControl(Params^[0])^ := TWinControl.Create(PComponent(Params^[1])^);
end;

procedure _LapeWinControl_CreateParented(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PWinControl(Params^[0])^ := TWinControl.CreateParented(Phandle(Params^[1])^);
PWinControl(Result)^ := TWinControl.Create(PComponent(Params^[0])^);
end;

procedure _LapeWinControl_CanFocus(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -648,9 +643,9 @@ procedure _LapeWinControl_SetShape(const Params: PParamArray); LAPE_WRAPPER_CALL
PWinControl(Params^[0])^.SetShape(PBitmap(Params^[1])^);
end;

procedure _LapeCustomControl_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeCustomControl_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PCustomControl(Params^[0])^ := TCustomControl.Create(PComponent(Params^[1])^);
PCustomControl(Result)^ := TCustomControl.Create(PComponent(Params^[0])^);
end;

procedure _LapeCustomControl_Canvas_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
Expand All @@ -673,9 +668,9 @@ procedure _LapeCustomControl_OnPaint_Write(const Params: PParamArray); LAPE_WRAP
PCustomControl(Params^[0])^.OnPaint := PNotifyEvent(Params^[1])^;
end;

procedure _LapeControlScrollBar_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeControlScrollBar_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PControlScrollBar(Params^[0])^ := TControlScrollBar.Create(PWinControl(Params^[1])^, PScrollBarKind(Params^[2])^);
PControlScrollBar(Result)^ := TControlScrollBar.Create(PWinControl(Params^[0])^, PScrollBarKind(Params^[1])^);
end;

procedure _LapeControlScrollBar_IsScrollBarVisible(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -783,9 +778,9 @@ procedure _LapeControlScrollBar_Visible_Write(const Params: PParamArray); LAPE_W
PControlScrollBar(Params^[0])^.Visible := PBoolean(Params^[1])^;
end;

procedure _LapeScrollingWinControl_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeScrollingWinControl_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PScrollingWinControl(Params^[0])^ := TScrollingWinControl.Create(PComponent(Params^[1])^);
PScrollingWinControl(Result)^ := TScrollingWinControl.Create(PComponent(Params^[0])^);
end;

procedure _LapeScrollingWinControl_UpdateScrollbars(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -878,7 +873,7 @@ procedure ImportLCLControls(Compiler: TSimbaScript_Compiler);
addClassVar('TLazControl', 'AnchorSideBottom', 'TLazAnchorSide', @_LapeControl_AnchorSideBottom_Read);

addGlobalFunc('procedure TLazControl.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);', @_LapeControl_SetBounds);
addGlobalFunc('procedure TLazControl.Init(AOwner: TLazComponent); override', @_LapeControl_Init);
addClassConstructor('TLazControl', '(AOwner: TLazComponent)', @_LapeControl_Create);
addGlobalFunc('procedure TLazControl.BringToFront;', @_LapeControl_BringToFront);
addGlobalFunc('procedure TLazControl.Hide;', @_LapeControl_Hide);
addGlobalFunc('procedure TLazControl.Refresh;', @_LapeControl_Refresh);
Expand Down Expand Up @@ -931,8 +926,7 @@ procedure ImportLCLControls(Compiler: TSimbaScript_Compiler);
addClassVar('TLazWinControl', 'OnKeyUp', 'TLazKeyEvent', nil, @_LapeWinControl_OnKeyUp_Write);
addClassVar('TLazWinControl', 'ParentWindow', 'TLazHandle', @_LapeWinControl_ParentWindow_Read, @_LapeWinControl_ParentWindow_Write);
addClassVar('TLazWinControl', 'Showing', 'Boolean', @_LapeWinControl_Showing_Read);
addGlobalFunc('procedure TLazWinControl.Init(TheOwner: TLazComponent); override', @_LapeWinControl_Init);
addGlobalFunc('procedure TLazWinControl.CreateParented(AParentWindow: TLazHandle);', @_LapeWinControl_CreateParented);
addClassConstructor('TLazWinControl', '(TheOwner: TLazComponent)', @_LapeWinControl_Create);
addGlobalFunc('function TLazWinControl.CanFocus: Boolean;', @_LapeWinControl_CanFocus);
addGlobalFunc('function TLazWinControl.Focused: Boolean;', @_LapeWinControl_Focused);
addGlobalFunc('function TLazWinControl.FindChildControl(const ControlName: String): TLazControl;', @_LapeWinControl_FindChildControl);
Expand All @@ -947,12 +941,12 @@ procedure ImportLCLControls(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TLazWinControl.SetShape(AShape: TLazBitmap);', @_LapeWinControl_SetShape);

addClass('TLazCustomControl', 'TLazWinControl');
addGlobalFunc('procedure TLazCustomControl.Init(AOwner: TLazComponent); override', @_LapeCustomControl_Init);
addClassConstructor('TLazCustomControl', '(AOwner: TLazComponent)', @_LapeCustomControl_Create);
addClassVar('TLazCustomControl', 'Canvas', 'TLazCanvas', @_LapeCustomControl_Canvas_Read, @_LapeCustomControl_Canvas_Write);
addClassVar('TLazCustomControl', 'OnPaint', 'TLazNotifyEvent', @_LapeCustomControl_OnPaint_Read, @_LapeCustomControl_OnPaint_Write);

addClass('TLazControlScrollBar');
addGlobalFunc('procedure TLazControlScrollBar.Init(AControl: TLazWinControl; AKind: TLazScrollBarKind)', @_LapeControlScrollBar_Init);
addClassConstructor('TLazControlScrollBar' ,'(AControl: TLazWinControl; AKind: TLazScrollBarKind)', @_LapeControlScrollBar_Create);
addGlobalFunc('function TLazControlScrollBar.IsScrollBarVisible: Boolean;', @_LapeControlScrollBar_IsScrollBarVisible);
addGlobalFunc('function TLazControlScrollBar.ScrollPos: Integer;', @_LapeControlScrollBar_ScrollPos);
addGlobalFunc('function TLazControlScrollBar.GetOtherScrollBar: TLazControlScrollBar;', @_LapeControlScrollBar_GetOtherScrollBar);
Expand All @@ -969,7 +963,7 @@ procedure ImportLCLControls(Compiler: TSimbaScript_Compiler);
addClassVar('TLazControlScrollBar', 'Visible', 'Boolean', @_LapeControlScrollBar_Visible_Read, @_LapeControlScrollBar_Visible_Write);

addClass('TLazScrollingWinControl', 'TLazCustomControl');
addGlobalFunc('procedure TLazScrollingWinControl.Init(AOwner: TLazComponent); override', @_LapeScrollingWinControl_Init);
addClassConstructor('TLazScrollingWinControl', '(AOwner: TLazComponent)', @_LapeScrollingWinControl_Create);
addGlobalFunc('procedure TLazScrollingWinControl.UpdateScrollbars;', @_LapeScrollingWinControl_UpdateScrollbars);
addClassVar('TLazScrollingWinControl', 'HorzScrollBar', 'TLazControlScrollBar', @_LapeScrollingWinControl_HorzScrollBar_Read, @_LapeScrollingWinControl_HorzScrollBar_Write);
addClassVar('TLazScrollingWinControl', 'VertScrollBar', 'TLazControlScrollBar', @_LapeScrollingWinControl_VertScrollBar_Read, @_LapeScrollingWinControl_VertScrollBar_Write);
Expand Down
78 changes: 18 additions & 60 deletions Source/script/imports/lcl/simba.import_lcl_extctrls.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ implementation
PMouseEvent = ^TMouseEvent;
PMouseMoveEvent = ^TMouseMoveEvent;

procedure _LapeCustomTimer_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeCustomTimer_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PCustomTimer(Params^[0])^ := TCustomTimer.Create(PComponent(Params^[1])^);
PCustomTimer(Result)^ := TCustomTimer.Create(PComponent(Params^[0])^);
end;

procedure _LapeCustomTimer_Enabled_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -88,29 +88,14 @@ procedure _LapeCustomTimer_OnStopTimer_Write(const Params: PParamArray); LAPE_WR
PCustomTimer(Params^[0])^.OnStopTimer := PNotifyEvent(Params^[1])^;
end;

procedure _LapeCustomTimer_Free(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeTimer_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PCustomTimer(Params^[0])^.Free();
PTimer(Result)^ := TTimer.Create(PComponent(Params^[0])^);
end;

procedure _LapeTimer_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeCustomImage_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PTimer(Params^[0])^ := TTimer.Create(PComponent(Params^[1])^);
end;

procedure _LapeTimer_Free(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PTimer(Params^[0])^.Free();
end;

procedure _LapeCustomImage_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PCustomImage(Params^[0])^ := TCustomImage.Create(PComponent(Params^[1])^);
end;

procedure _LapeCustomImage_Canvas_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PCanvas(Result)^ := PCustomImage(Params^[0])^.Canvas;
PCustomImage(Result)^ := TCustomImage.Create(PComponent(Params^[0])^);
end;

procedure _LapeCustomImage_DestRect(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -178,11 +163,6 @@ procedure _LapeCustomImage_OnPictureChanged_Write(const Params: PParamArray); LA
PCustomImage(Params^[0])^.OnPictureChanged := PNotifyEvent(Params^[1])^;
end;

procedure _LapeCustomImage_Free(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PCustomImage(Params^[0])^.Free;
end;

procedure _LapeCustomImage_OnMouseDown_Write(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PCustomImage(Params^[0])^.OnMouseDown := PMouseEvent(Params^[1])^;
Expand All @@ -193,14 +173,9 @@ procedure _LapeCustomImage_OnMouseUp_Write(const Params: PParamArray); LAPE_WRAP
PCustomImage(Params^[0])^.OnMouseUp := PMouseEvent(Params^[1])^;
end;

procedure _LapeImage_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeImage_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PImage(Params^[0])^ := TImage.Create(PComponent(Params^[1])^);
end;

procedure _LapeImage_Free(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PImage(Params^[0])^.Free();
PImage(Result)^ := TImage.Create(PComponent(Params^[0])^);
end;

procedure _LapeImage_OnMouseEnter_Read(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
Expand Down Expand Up @@ -273,46 +248,33 @@ procedure _LapeCustomPanel_BevelWidth_Write(const Params: PParamArray); LAPE_WRA
PCustomPanel(Params^[0])^.BevelWidth := PBevelWidth(Params^[1])^;
end;

procedure _LapeCustomPanel_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PCustomPanel(Params^[0])^ := TCustomPanel.Create(PComponent(Params^[1])^);
end;

procedure _LapeCustomPanel_Free(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
PCustomPanel(Params^[0])^.Free();
end;

procedure _LapePanel_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapeCustomPanel_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPanel(Params^[0])^ := TPanel.Create(PComponent(Params^[1])^);
PCustomPanel(Result)^ := TCustomPanel.Create(PComponent(Params^[0])^);
end;

procedure _LapePanel_Free(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
procedure _LapePanel_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
PPanel(Params^[0])^.Free();
PPanel(Result)^ := TPanel.Create(PComponent(Params^[0])^);
end;

procedure ImportLCLExtCtrls(Compiler: TSimbaScript_Compiler);
begin
with Compiler do
begin
addClass('TLazCustomTimer', 'TLazComponent');
addGlobalFunc('procedure TLazCustomTimer.Init(AOwner: TLazComponent); override', @_LapeCustomTimer_Init);
addClassConstructor('TLazCustomTimer', '(AOwner: TLazComponent)', @_LapeCustomTimer_Create);
addClassVar('TLazCustomTimer', 'Enabled', 'Boolean', @_LapeCustomTimer_Enabled_Read, @_LapeCustomTimer_Enabled_Write);
addClassVar('TLazCustomTimer', 'Interval', 'UInt32', @_LapeCustomTimer_Interval_Read, @_LapeCustomTimer_Interval_Write);
addClassVar('TLazCustomTimer', 'OnTimer', 'TLazNotifyEvent', @_LapeCustomTimer_OnTimer_Read, @_LapeCustomTimer_OnTimer_Write);
addClassVar('TLazCustomTimer', 'OnStartTimer', 'TLazNotifyEvent', @_LapeCustomTimer_OnStartTimer_Read, @_LapeCustomTimer_OnStartTimer_Write);
addClassVar('TLazCustomTimer', 'OnStopTimer', 'TLazNotifyEvent', @_LapeCustomTimer_OnStopTimer_Read, @_LapeCustomTimer_OnStopTimer_Write);
//addGlobalFunc('procedure TLazCustomTimer.Free;', @_LapeCustomTimer_Free);

addClass('TLazTimer', 'TLazCustomTimer');
addGlobalFunc('procedure TLazTimer.Init(AOwner: TLazComponent); override', @_LapeTimer_Init);
//addGlobalFunc('procedure TLazTimer.Free;', @_LapeTimer_Free);
addClassConstructor('TLazTimer', '(AOwner: TLazComponent)', @_LapeTimer_Create);

addClass('TLazCustomImage', 'TLazGraphicControl');
addGlobalFunc('procedure TLazCustomImage.Init(AOwner: TLazComponent); override', @_LapeCustomImage_Init);
//addClassVar('TLazCustomImage', 'Canvas', 'TLazCanvas', @_LapeCustomImage_Canvas_Read);
addClassConstructor('TLazCustomImage', '(AOwner: TLazComponent)', @_LapeCustomImage_Create);
addGlobalFunc('function TLazCustomImage.DestRect: TLazRect;', @_LapeCustomImage_DestRect);
addClassVar('TLazCustomImage', 'Center', 'Boolean', @_LapeCustomImage_Center_Read, @_LapeCustomImage_Center_Write);
addClassVar('TLazCustomImage', 'Picture', 'TLazPicture', @_LapeCustomImage_Picture_Read, @_LapeCustomImage_Picture_Write);
Expand All @@ -322,11 +284,9 @@ procedure ImportLCLExtCtrls(Compiler: TSimbaScript_Compiler);
addClassVar('TLazCustomImage', 'OnPictureChanged', 'TLazNotifyEvent', @_LapeCustomImage_OnPictureChanged_Read, @_LapeCustomImage_OnPictureChanged_Write);
addClassVar('TLazCustomImage', 'OnMouseDown', 'TLazMouseEvent', nil, @_LapeCustomImage_OnMouseDown_Write);
addClassVar('TLazCustomImage', 'OnMouseUp', 'TLazMouseEvent', nil, @_LapeCustomImage_OnMouseUp_Write);
//addGlobalFunc('procedure TLazCustomImage.Free;', @_LapeCustomImage_Free);

addClass('TLazImage', 'TLazCustomImage');
addGlobalFunc('procedure TLazImage.Init(AOwner: TLazComponent); override', @_LapeImage_Init);
//addGlobalFunc('procedure TLazImage.Free;', @_LapeImage_Free);
addClassConstructor('TLazImage', '(AOwner: TLazComponent)', @_LapeImage_Create);
addClassVar('TLazImage', 'OnMouseEnter', 'TLazNotifyEvent', @_LapeImage_OnMouseEnter_Read, @_LapeImage_OnMouseEnter_Write);
addClassVar('TLazImage', 'OnMouseLeave', 'TLazNotifyEvent', @_LapeImage_OnMouseLeave_Read, @_LapeImage_OnMouseLeave_Write);
addClassVar('TLazImage', 'OnMouseMove', 'TLazMouseMoveEvent', @_LapeImage_OnMouseMove_Read, @_LapeImage_OnMouseMove_Write);
Expand All @@ -337,12 +297,10 @@ procedure ImportLCLExtCtrls(Compiler: TSimbaScript_Compiler);
addClassVar('TLazCustomPanel', 'BevelInner', 'TLazPanelBevel', @_LapeCustomPanel_BevelInner_Read, @_LapeCustomPanel_BevelInner_Write);
addClassVar('TLazCustomPanel', 'BevelOuter', 'TLazPanelBevel', @_LapeCustomPanel_BevelOuter_Read, @_LapeCustomPanel_BevelOuter_Write);
addClassVar('TLazCustomPanel', 'BevelWidth', 'Integer', @_LapeCustomPanel_BevelWidth_Read, @_LapeCustomPanel_BevelWidth_Write);
addGlobalFunc('procedure TLazCustomPanel.Init(TheOwner: TLazComponent); override', @_LapeCustomPanel_Init);
//addGlobalFunc('procedure TLazCustomPanel.Free;', @_LapeCustomPanel_Free);
addClassConstructor('TLazCustomPanel', '(TheOwner: TLazComponent)', @_LapeCustomPanel_Create);

addClass('TLazPanel', 'TLazCustomPanel');
addGlobalFunc('procedure TLazPanel.Init(TheOwner: TLazComponent); override', @_LapePanel_Init);
//addGlobalFunc('procedure TLazPanel.Free;', @_LapePanel_Free);
addClassConstructor('TLazPanel', '(TheOwner: TLazComponent)', @_LapePanel_Create);
end;
end;

Expand Down
Loading

0 comments on commit be34980

Please sign in to comment.