Changeset 257 for trunk/ext/php
- Timestamp:
- 07/03/2007 11:46:43 (17 months ago)
- Location:
- trunk/ext/php
- Files:
-
- 1 added
- 2 modified
-
php_syck.h (modified) (3 diffs)
-
phpext.c (modified) (4 diffs)
-
phpunit-tests (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/php_syck.h
r254 r257 20 20 21 21 #ifndef PHP_SYCK_H 22 # define PHP_SYCK_H22 # define PHP_SYCK_H 23 23 24 24 extern zend_module_entry syck_module_entry; 25 # define phpext_syck_ptr &syck_module_entry25 # define phpext_syck_ptr &syck_module_entry 26 26 27 # ifdef PHP_WIN3228 # define PHP_SYCK_API __declspec(dllexport)29 # else30 # define PHP_SYCK_API31 # endif27 # ifdef PHP_WIN32 28 # define PHP_SYCK_API __declspec(dllexport) 29 # else 30 # define PHP_SYCK_API 31 # endif 32 32 33 # ifdef ZTS34 # include "TSRM.h"35 # endif33 # ifdef ZTS 34 # include "TSRM.h" 35 # endif 36 36 37 37 PHP_MINIT_FUNCTION(syck); … … 39 39 40 40 PHP_FUNCTION(syck_load); 41 PHP_FUNCTION(syck_dump); 41 42 42 43 /* 43 Declare any global variables you may need between the BEGIN44 Declare any global variables you may need between the BEGIN 44 45 and END macros here: 45 46 … … 48 49 char *global_string; 49 50 ZEND_END_MODULE_GLOBALS(syck) 50 */51 52 /* In every utility function you add that needs to use variables53 in php_syck_globals, call TSRM_FETCH(); after declaring other54 variables used by that function, or better yet, pass in TSRMLS_CC55 after the last function argument and declare your utility function56 with TSRMLS_DC after the last declared argument. Always refer to57 the globals in your function as SYCK_G(variable). You are58 encouraged to rename these macros something shorter, see59 examples in any other php module directory.60 */61 51 62 52 #ifdef ZTS 63 # define SYCK_G(v) TSRMG(syck_globals_id, zend_syck_globals *, v)53 # define SYCK_G(v) TSRMG(syck_globals_id, zend_syck_globals *, v) 64 54 #else 65 # define SYCK_G(v) (syck_globals.v)55 # define SYCK_G(v) (syck_globals.v) 66 56 #endif 57 */ 67 58 68 59 #endif /* PHP_SYCK_H */ -
trunk/ext/php/phpext.c
r255 r257 21 21 #include "php_syck.h" 22 22 23 #define PHP_SYCK_VERSION "0. 2"23 #define PHP_SYCK_VERSION "0.3" 24 24 25 25 /** … … 61 61 static double inline nanphp() { return zero() / zero(); } 62 62 63 typedef struct { 64 char *output; 65 size_t output_size; 66 zval **stack; 67 unsigned char level; 68 } php_syck_emitter_xtra; 69 70 psex_add_output(php_syck_emitter_xtra *ptr) 71 { 72 73 } 74 63 75 64 76 function_entry syck_functions[] = { 65 77 PHP_FE(syck_load, NULL) 78 PHP_FE(syck_dump, NULL) 66 79 {NULL, NULL, NULL} /* Must be the last line in syck_functions[] */ 67 80 }; … … 222 235 } 223 236 237 void php_syck_emitter_handler(SyckEmitter *e, st_data_t data) 238 { 239 240 } 241 242 void php_syck_output_handler(SyckEmitter *e, char *str, long len) 243 { 244 245 } 224 246 225 247 /* {{{ proto object syck_load(string arg) … … 261 283 262 284 syck_free_parser(parser); 285 } 286 /* }}} */ 287 288 289 /* {{{ proto object syck_load(string arg) 290 Convert PHP object into YAML string */ 291 PHP_FUNCTION(syck_dump) 292 { 293 SyckEmitter *emitter; 294 emitter_extra *extra; 295 zval *ptr; 296 297 if (ZEND_NUM_ARGS() != 1) { 298 WRONG_PARAM_COUNT; 299 } 300 301 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &ptr) == FAILURE) { 302 return; 303 } 304 305 emitter = syck_new_emitter(); 306 emitter->bonus = emalloc(sizeof(emitter_extra)); 307 emitter->bonus.output = emalloc(8192); 308 emitter->bonus.output_size = 8192; 309 310 syck_emitter_handler(emitter, php_syck_emitter_handler); 311 syck_output_handler(emitter, php_syck_output_handler); 312 313 syck_emit(emitter, 0); 314 syck_emitter_flush(emitter, 0); 315 316 efree(emitter->bonus); 317 syck_free_emitter(emitter); 263 318 } 264 319 /* }}} */