LCOV - code coverage report
Current view: top level - http - php_http_object.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 33 37 89.2 %
Date: 2014-11-03 12:21:11 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :     +--------------------------------------------------------------------+
       3             :     | PECL :: http                                                       |
       4             :     +--------------------------------------------------------------------+
       5             :     | Redistribution and use in source and binary forms, with or without |
       6             :     | modification, are permitted provided that the conditions mentioned |
       7             :     | in the accompanying LICENSE file are met.                          |
       8             :     +--------------------------------------------------------------------+
       9             :     | Copyright (c) 2004-2014, Michael Wallner <mike@php.net>            |
      10             :     +--------------------------------------------------------------------+
      11             : */
      12             : 
      13             : #include "php_http_api.h"
      14             : 
      15          54 : zend_object_value php_http_object_new(zend_class_entry *ce TSRMLS_DC)
      16             : {
      17          54 :         return php_http_object_new_ex(ce, NULL, NULL TSRMLS_CC);
      18             : }
      19             : 
      20          54 : zend_object_value php_http_object_new_ex(zend_class_entry *ce, void *nothing, php_http_object_t **ptr TSRMLS_DC)
      21             : {
      22             :         php_http_object_t *o;
      23             : 
      24          54 :         o = ecalloc(1, sizeof(php_http_object_t));
      25          54 :         zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
      26          54 :         object_properties_init((zend_object *) o, ce);
      27             : 
      28          54 :         if (ptr) {
      29           0 :                 *ptr = o;
      30             :         }
      31             : 
      32          54 :         o->zv.handle = zend_objects_store_put(o, NULL, (zend_objects_free_object_storage_t) zend_objects_free_object_storage, NULL TSRMLS_CC);
      33          54 :         o->zv.handlers = zend_get_std_object_handlers();
      34             : 
      35          54 :         return o->zv;
      36             : }
      37             : 
      38          19 : STATUS php_http_new(zend_object_value *ovp, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC)
      39             : {
      40             :         zend_object_value ov;
      41             : 
      42          19 :         if (!ce) {
      43           0 :                 ce = parent_ce;
      44          19 :         } else if (parent_ce && !instanceof_function(ce, parent_ce TSRMLS_CC)) {
      45           0 :                 php_http_throw(unexpected_val, "Class %s does not extend %s", ce->name, parent_ce->name);
      46           0 :                 return FAILURE;
      47             :         }
      48             : 
      49          19 :         ov = create(ce, intern_ptr, obj_ptr TSRMLS_CC);
      50          19 :         if (ovp) {
      51           3 :                 *ovp = ov;
      52             :         }
      53          19 :         return SUCCESS;
      54             : }
      55             : 
      56          32 : STATUS php_http_method_call(zval *object, const char *method_str, size_t method_len, int argc, zval **argv[], zval **retval_ptr TSRMLS_DC)
      57             : {
      58             :         zend_fcall_info fci;
      59             :         zval zmethod;
      60             :         zval *retval;
      61             :         STATUS rv;
      62             : 
      63          32 :         fci.size = sizeof(fci);
      64          32 :         fci.object_ptr = object;
      65          32 :         fci.function_name = &zmethod;
      66          32 :         fci.retval_ptr_ptr = retval_ptr ? retval_ptr : &retval;
      67          32 :         fci.param_count = argc;
      68          32 :         fci.params = argv;
      69          32 :         fci.no_separation = 1;
      70          32 :         fci.symbol_table = NULL;
      71          32 :         fci.function_table = NULL;
      72             : 
      73          32 :         INIT_PZVAL(&zmethod);
      74          32 :         ZVAL_STRINGL(&zmethod, method_str, method_len, 0);
      75          32 :         rv = zend_call_function(&fci, NULL TSRMLS_CC);
      76             : 
      77          32 :         if (!retval_ptr && retval) {
      78          32 :                 zval_ptr_dtor(&retval);
      79             :         }
      80          32 :         return rv;
      81             : }
      82             : 
      83             : /*
      84             :  * Local variables:
      85             :  * tab-width: 4
      86             :  * c-basic-offset: 4
      87             :  * End:
      88             :  * vim600: noet sw=4 ts=4 fdm=marker
      89             :  * vim<600: noet sw=4 ts=4
      90             :  */
      91             : 

Generated by: LCOV version 1.11