30
30
#include "php.h"
31
31
32
32
33
-
34
33
/**
35
- *
36
- *
37
- * Henrique Borba <henrique.borba.dev>
34
+ * @author Henrique Borba <henrique.borba.dev>
38
35
* @param obj
39
36
* @param uuid
40
37
*/
41
38
void set_obj_uuid (zval * obj , long uuid ) {
42
39
zend_update_property_long (phpsci_sc_entry , obj , "uuid" , sizeof ("uuid" ) - 1 , uuid );
43
40
}
44
41
42
+ /**
43
+ * @author Henrique Borba <henrique.borba.dev>
44
+ * @param rtn
45
+ * @param x_rows_width
46
+ * @param y_cols
47
+ */
48
+ void generate_carray_object (zval * rtn , long uuid , long x_rows_width , long y_cols ) {
49
+ }
50
+
45
51
/**
46
52
* PHPSci Constructor
47
53
*/
48
54
PHP_METHOD (CArray , __construct )
49
55
{
50
- array_init (return_value );
56
+ long uuid , x , y ;
57
+ ZEND_PARSE_PARAMETERS_START (3 ,3 )
58
+ Z_PARAM_LONG (uuid )
59
+ Z_PARAM_LONG (x )
60
+ Z_PARAM_LONG (y )
61
+ ZEND_PARSE_PARAMETERS_END ();
62
+ zval * obj = getThis ();
63
+ set_obj_uuid (obj , uuid );
64
+ zend_update_property_long (phpsci_sc_entry , obj , "x ", sizeof ("x ") - 1 , x );
65
+ zend_update_property_long (phpsci_sc_entry , obj , "y ", sizeof ("y ") - 1, y);
51
66
}
52
67
53
68
/**
@@ -65,8 +80,10 @@ PHP_METHOD(CArray, identity)
65
80
carray_init ((int )m , (int )m , & ptr );
66
81
CArray arr = ptr_to_carray (& ptr );
67
82
identity (& arr , (int )m );
68
- object_init (return_value );
83
+ object_init_ex (return_value , phpsci_sc_entry );
69
84
set_obj_uuid (return_value , ptr .uuid );
85
+ zend_update_property_long (phpsci_sc_entry , return_value , "x" , sizeof ("x" ) - 1 , m );
86
+ zend_update_property_long (phpsci_sc_entry , return_value , "y" , sizeof ("y" ) - 1 , m );
70
87
}
71
88
PHP_METHOD (CArray , zeros )
72
89
{
@@ -80,7 +97,7 @@ PHP_METHOD(CArray, zeros)
80
97
carray_init ((int )x , (int )y , & ptr );
81
98
CArray arr = ptr_to_carray (& ptr );
82
99
zeros (& arr , (int )x , (int )y );
83
- object_init (return_value );
100
+ object_init_ex (return_value , phpsci_sc_entry );
84
101
set_obj_uuid (return_value , ptr .uuid );
85
102
}
86
103
PHP_METHOD (CArray , fromArray )
@@ -94,7 +111,7 @@ PHP_METHOD(CArray, fromArray)
94
111
MemoryPointer ptr ;
95
112
ptr .uuid = NULL ;
96
113
array_to_carray_ptr (& ptr , array , & a_rows , & a_cols );
97
- object_init (return_value );
114
+ object_init_ex (return_value , phpsci_sc_entry );
98
115
set_obj_uuid (return_value , ptr .uuid );
99
116
zend_update_property_long (phpsci_sc_entry , return_value , "x" , sizeof ("x" ) - 1 , a_rows );
100
117
zend_update_property_long (phpsci_sc_entry , return_value , "y" , sizeof ("y" ) - 1 , a_cols );
@@ -124,7 +141,7 @@ PHP_METHOD(CArray, transpose)
124
141
MemoryPointer rtn ;
125
142
ptr .uuid = (int )uuid ;
126
143
transpose (& rtn , & ptr , (int )rows , (int )cols );
127
- object_init (return_value );
144
+ object_init_ex (return_value , phpsci_sc_entry );
128
145
set_obj_uuid (return_value , rtn .uuid );
129
146
}
130
147
PHP_METHOD (CArray , print_r ) {
@@ -162,7 +179,7 @@ PHP_METHOD(CArray, linspace)
162
179
ZEND_PARSE_PARAMETERS_END ();
163
180
MemoryPointer * ptr ;
164
181
linspace (ptr , (float )start , (float )stop , (float )num );
165
- object_init (return_value );
182
+ object_init_ex (return_value , phpsci_sc_entry );
166
183
set_obj_uuid (return_value , ptr -> uuid );
167
184
zend_update_property_long (phpsci_sc_entry , return_value , "x ", sizeof ("x ") - 1, num);
168
185
zend_update_property_long (phpsci_sc_entry , return_value , "y" , sizeof ("y" ) - 1 , 0 );
@@ -179,7 +196,7 @@ PHP_METHOD(CArray, logspace)
179
196
ZEND_PARSE_PARAMETERS_END ();
180
197
MemoryPointer * ptr ;
181
198
logspace (ptr , (float )start , (float )stop , num , (float )base );
182
- object_init (return_value );
199
+ object_init_ex (return_value , phpsci_sc_entry );
183
200
set_obj_uuid (return_value , ptr -> uuid );
184
201
zend_update_property_long (phpsci_sc_entry , return_value , "x" , sizeof ("x" ) - 1 , num );
185
202
zend_update_property_long (phpsci_sc_entry , return_value , "y" , sizeof ("y" ) - 1 , 0 );
@@ -210,7 +227,7 @@ PHP_METHOD(CArray, matmul)
210
227
a_ptr .uuid = (int )a_uuid ;
211
228
b_ptr .uuid = (int )b_uuid ;
212
229
matmul (& rtn_ptr , (int )a_rows , (int )a_cols , & a_ptr , (int )b_cols , & b_ptr );
213
- object_init (return_value );
230
+ object_init_ex (return_value , phpsci_sc_entry );
214
231
set_obj_uuid (return_value , rtn_ptr .uuid );
215
232
}
216
233
PHP_METHOD (CArray , arange )
@@ -224,7 +241,7 @@ PHP_METHOD(CArray, arange)
224
241
ZEND_PARSE_PARAMETERS_END ();
225
242
MemoryPointer * ptr ;
226
243
arange (ptr , start , stop , step , & width );
227
- object_init (return_value );
244
+ object_init_ex (return_value , phpsci_sc_entry );
228
245
set_obj_uuid (return_value , ptr -> uuid );
229
246
zend_update_property_long (phpsci_sc_entry , return_value , "x ", sizeof ("x ") - 1 , width );
230
247
zend_update_property_long (phpsci_sc_entry , return_value , "y ", sizeof ("y ") - 1, 0);
@@ -235,7 +252,7 @@ PHP_METHOD(CArray, arange)
235
252
*/
236
253
static zend_function_entry phpsci_class_methods [] =
237
254
{
238
- PHP_ME (CArray , __construct , NULL , ZEND_ACC_PUBLIC )
255
+ // PHP_ME(CArray, __construct, NULL, ZEND_ACC_PUBLIC)
239
256
// RANGES SECTION
240
257
PHP_ME (CArray , arange , NULL , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
241
258
PHP_ME (CArray , linspace , NULL , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
0 commit comments