-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.cpp
125 lines (99 loc) · 2.24 KB
/
app.cpp
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
/**
* @author Mário Soares
*
* @license
* This file is part of wxPHP check the LICENSE file for information.
*
* @description
* Manual binding implemetation of the wxApp class
*
*/
#include "php_wxwidgets.h"
#include "app.h"
int wxAppWrapper::OnExit()
{
zval *retval;
zval func_name;
ZVAL_STRINGL(&func_name, (char *)"OnExit", sizeof("OnExit")-1, 0);
if(call_user_function_ex(NULL, &phpObj, &func_name, &retval, 0, NULL, 0, NULL TSRMLS_CC) == FAILURE)
{
wxMessageBox(_T("Failed Call!\n"));
}
return 0;
}
bool wxAppWrapper::OnInit()
{
zval *retval;
zval func_name;
ZVAL_STRINGL(&func_name, (char *)"OnInit", sizeof("OnInit")-1, 0);
wxFileSystem::AddHandler(new wxZipFSHandler);
if(call_user_function_ex(NULL, &phpObj, &func_name, &retval, 0, NULL, 0, NULL TSRMLS_CC) == FAILURE)
{
wxMessageBox(_T("Failed Call!\n"));
}
return true;
}
IMPLEMENT_APP_NO_MAIN(wxAppWrapper);
PHP_METHOD(php_wxApp, helloWorld)
{
php_printf("Hello World\n");
}
PHP_METHOD(php_wxApp, __construct)
{
wxAppWrapper* my = new wxAppWrapper();
my->phpObj = getThis();
#ifdef ZTS
my->tsrm_ls = tsrm_ls;
#endif
add_property_resource(getThis(),(char *)"wxResource", zend_list_insert(my, le_wxApp));
}
PHP_METHOD(php_wxApp, SetInstance)
{
zval **tmp;
int id_to_find;
void *property;
zval *objvar;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, (char *)"O", &objvar, php_wxApp_entry) == FAILURE)
{
RETURN_NULL();
}
if(zend_hash_find(Z_OBJPROP_P(objvar), (char *)"wxResource", sizeof("wxResource"), (void **)&tmp) == FAILURE)
{
return;
}
id_to_find = Z_LVAL_PP(tmp);
property = zend_list_find(id_to_find, &le_wxApp);
wxApp::SetInstance((wxAppWrapper*) property);
}
PHP_METHOD(php_wxApp, Yield)
{
zval **tmp;
int rsrc_type;
int id_to_find;
int valid = 1;
void *_this;
if (zend_hash_find(Z_OBJPROP_P(getThis()), (char *)"wxResource", sizeof("wxResource"), (void **)&tmp) == FAILURE)
{
return;
}
id_to_find = Z_RESVAL_P(*tmp);
_this = zend_list_find(id_to_find, &rsrc_type);
valid=1;
if (ZEND_NUM_ARGS()==0)
{
if(valid)
{
bool ret0;
int gr = ZEND_NUM_ARGS();
switch(gr)
{
case 0:
ret0 = ((wxApp*)_this)->Yield();
break;
default:
break;
}
RETURN_BOOL(ret0)
}
}
}