浏览代码

FEAT(define): redister class property

viest 7 年之前
父节点
当前提交
8ce6de0c5c
共有 2 个文件被更改,包括 13 次插入11 次删除
  1. 10 10
      kernel/excel.c
  2. 3 1
      kernel/include.h

+ 10 - 10
kernel/excel.c

@@ -148,7 +148,7 @@ PHP_METHOD(vtiful_excel, fileName)
  */
 PHP_METHOD(vtiful_excel, header)
 {
-    zval rv, res_handle, *header, *header_value;
+    zval res_handle, *header, *header_value;
     zend_long header_l_key;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -171,7 +171,7 @@ PHP_METHOD(vtiful_excel, header)
  */
 PHP_METHOD(vtiful_excel, data)
 {
-    zval rv, *data, res_handle, *data_r_value, *data_l_value;
+    zval *data, res_handle, *data_r_value, *data_l_value;
     zend_long data_r_key, data_l_key;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -231,7 +231,7 @@ PHP_METHOD(vtiful_excel, getHandle)
  */
 PHP_METHOD(vtiful_excel, insertText)
 {
-    zval rv, res_handle;
+    zval res_handle;
     zval *data;
     zend_long row, column;
     zend_string *format = NULL;
@@ -257,7 +257,7 @@ PHP_METHOD(vtiful_excel, insertText)
  */
 PHP_METHOD(vtiful_excel, insertImage)
 {
-    zval rv, res_handle;
+    zval res_handle;
     zval *image;
     zend_long row, column;
 
@@ -280,7 +280,7 @@ PHP_METHOD(vtiful_excel, insertImage)
  */
 PHP_METHOD(vtiful_excel, insertFormula)
 {
-    zval rv, res_handle;
+    zval res_handle;
     zval *formula;
     zend_long row, column;
 
@@ -303,7 +303,7 @@ PHP_METHOD(vtiful_excel, insertFormula)
  */
 PHP_METHOD(vtiful_excel, autoFilter)
 {
-    zval rv, res_handle;
+    zval res_handle;
     zend_string *range;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -323,7 +323,7 @@ PHP_METHOD(vtiful_excel, autoFilter)
  */
 PHP_METHOD(vtiful_excel, mergeCells)
 {
-    zval rv, res_handle;
+    zval res_handle;
     zend_string *range, *data;
 
     ZEND_PARSE_PARAMETERS_START(2, 2)
@@ -429,9 +429,9 @@ VTIFUL_STARTUP_FUNCTION(excel) {
 
     vtiful_excel_ce = zend_register_internal_class(&ce);
 
-    zend_declare_property_null(vtiful_excel_ce, ZEND_STRL(V_EXCEL_COF), ZEND_ACC_PRIVATE);
-    zend_declare_property_null(vtiful_excel_ce, ZEND_STRL(V_EXCEL_FIL), ZEND_ACC_PRIVATE);
-    zend_declare_property_null(vtiful_excel_ce, ZEND_STRL(V_EXCEL_HANDLE), ZEND_ACC_PRIVATE);
+    REGISTER_CLASS_PROPERTY_NULL(vtiful_excel_ce, V_EXCEL_COF,    ZEND_ACC_PRIVATE);
+    REGISTER_CLASS_PROPERTY_NULL(vtiful_excel_ce, V_EXCEL_FIL,    ZEND_ACC_PRIVATE);
+    REGISTER_CLASS_PROPERTY_NULL(vtiful_excel_ce, V_EXCEL_HANDLE, ZEND_ACC_PRIVATE);
 
     return SUCCESS;
 }

+ 3 - 1
kernel/include.h

@@ -20,6 +20,9 @@
 #define REGISTER_CLASS_CONST_LONG(class_name, const_name, value) \
     zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (zend_long)value);
 
+#define REGISTER_CLASS_PROPERTY_NULL(class_name, property_name, acc) \
+    zend_declare_property_null(class_name, ZEND_STRL(property_name), acc);
+
 #define ROW(range) \
     lxw_name_to_row(range)
 
@@ -30,7 +33,6 @@ typedef struct {
 
 extern excel_resource_t *excel_res;
 
-
 excel_resource_t * zval_get_resource(zval *handle);
 lxw_format       * zval_get_format(zval *handle);