forked from dim-s/soulengine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathguiForms.pas
142 lines (114 loc) · 2.78 KB
/
guiForms.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
{$I PHP.inc}
unit guiForms;
{$I PHP.inc}
{$ifdef fpc}
{$mode delphi}{$H+}
{$endif}
interface
uses
Classes, SysUtils, UITypes, Dialogs, Controls, Forms,
{$ifdef fpc}
LCLType,
{$endif}
zendTypes,
ZENDAPI,
phpTypes,
PHPAPI,
php4delphi,
mainLCL,
uPhpEvents,
uForms;
procedure InitializeGuiForms(PHPEngine: TPHPEngine);
procedure gui_formShowModal(ht: integer; return_value: pzval;
return_value_ptr: pzval; this_ptr: pzval; return_value_used: integer;
TSRMLS_DC: pointer); cdecl;
procedure gui_formSetMain(ht: integer; return_value: pzval;
return_value_ptr: pzval; this_ptr: pzval; return_value_used: integer;
TSRMLS_DC: pointer); cdecl;
procedure gui_Message(ht: integer; return_value: pzval; return_value_ptr: pzval;
this_ptr: pzval; return_value_used: integer; TSRMLS_DC: pointer); cdecl;
procedure gui_SafeMessage(ht: integer; return_value: pzval;
return_value_ptr: pzval; this_ptr: pzval; return_value_used: integer;
TSRMLS_DC: pointer); cdecl;
implementation
procedure gui_formShowModal;
var
p: pzval_array;
begin
if ht < 1 then
begin
zend_wrong_param_count(TSRMLS_DC);
Exit;
end;
zend_get_parameters_my(ht, p, TSRMLS_DC);
VariantToZend(Form_ShowModal(Z_LVAL(p[0]^)), return_value);
dispose_pzval_array(p);
end;
procedure gui_formSetMain(ht: integer; return_value: pzval;
return_value_ptr: pzval; this_ptr: pzval; return_value_used: integer;
TSRMLS_DC: pointer); cdecl;
procedure SetAsMainForm(aForm: TForm);
var
P: Pointer;
begin
P := @Application.Mainform;
Pointer(P^) := aForm;
end;
var
p: pzval_array;
obj: TObject;
begin
if ht < 1 then
begin
zend_wrong_param_count(TSRMLS_DC);
Exit;
end;
zend_get_parameters_my(ht, p, TSRMLS_DC);
obj := toObject(Z_LVAL(p[0]^));
if (obj = nil) or not (obj is TForm) then
begin
ZVALVAL(return_value, False);
end
else
begin
SetAsMainForm(TForm(Obj));
end;
dispose_pzval_array(p);
end;
procedure gui_Message;
var
p: pzval_array;
begin
if ht < 1 then
begin
zend_wrong_param_count(TSRMLS_DC);
Exit;
end;
zend_get_parameters_my(ht, p, TSRMLS_DC);
ShowMessage( Z_STRVAL(p[0]^) );
dispose_pzval_array(p);
end;
procedure gui_SafeMessage;
var
p: pzval_array;
msg: zend_pstr;
begin
if ht < 1 then
begin
zend_wrong_param_count(TSRMLS_DC);
Exit;
end;
zend_get_parameters_my(ht, p, TSRMLS_DC);
New(Msg);
Msg^ := Z_STRVAL(p[0]^);
TScriptSafeCommand_Message.Create(Msg);
dispose_pzval_array(p);
end;
procedure InitializeGuiForms(PHPEngine: TPHPEngine);
begin
PHPEngine.AddFunction('gui_formShowModal', @gui_formShowModal);
PHPEngine.AddFunction('gui_formSetMain', @gui_formSetMain);
PHPEngine.AddFunction('gui_message', @gui_Message);
PHPEngine.AddFunction('gui_safeMessage', @gui_safeMessage);
end;
end.