Add parse arginfo
Fix args naming
*/
typedef struct _bbcode_object {
*/
typedef struct _bbcode_object {
- /*zval *tag;
- zval *smiley;
- zval *flag;*/
+ HashTable *tag;
+ HashTable *smiley;
zval flag;
zend_object std;
} bbcode_object;
zval flag;
zend_object std;
} bbcode_object;
static zend_object *bbcode_clone(zval *obj TSRMLS_DC);
static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC);
static zend_object *bbcode_clone(zval *obj TSRMLS_DC);
static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC);
-/* BBCode object destroy call */
+/* {{{ static void bbcode_destroy(bbcode_object *obj TSRMLS_DC) {
+ * BBCode object destroy call */
static void bbcode_destroy(bbcode_object *obj TSRMLS_DC) {
//zend_objects_destroy_object(&obj->std);
zend_objects_destroy_object((zend_object *)obj);
static void bbcode_destroy(bbcode_object *obj TSRMLS_DC) {
//zend_objects_destroy_object(&obj->std);
zend_objects_destroy_object((zend_object *)obj);
-/* BBCode object free call */
+/* {{{ static void bbcode_free(bbcode_object *obj TSRMLS_DC) {
+ * BBCode object free call */
static void bbcode_free(bbcode_object *obj TSRMLS_DC) {
/*if (obj->flag) {
static void bbcode_free(bbcode_object *obj TSRMLS_DC) {
/*if (obj->flag) {
//efree(obj);
zend_object_std_dtor((zend_object *)obj);
}
//efree(obj);
zend_object_std_dtor((zend_object *)obj);
}
+/* {{{ static zend_object *bbcode_clone(zval *obj) {
+ * BBCode object clone call */
static zend_object *bbcode_clone(zval *obj) {
zend_object *oldobj = Z_OBJ_P(obj);
static zend_object *bbcode_clone(zval *obj) {
zend_object *oldobj = Z_OBJ_P(obj);
+/* {{{ static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC) {
+ * BBCode object create call */
static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC) {
bbcode_object *obj = (bbcode_object *)ecalloc(1, sizeof(bbcode_object) + zend_object_properties_size(ce));//emalloc(sizeof(bbcode_object));
static zend_object *bbcode_create(zend_class_entry *ce TSRMLS_DC) {
bbcode_object *obj = (bbcode_object *)ecalloc(1, sizeof(bbcode_object) + zend_object_properties_size(ce));//emalloc(sizeof(bbcode_object));
-/* {{{ PHP_METHOD(BBCode::__construct) {
- */
+/* {{{ ZEND_BEGIN_ARG_INFO_EX(bbcode_construct_arginfo) */
ZEND_BEGIN_ARG_INFO_EX(bbcode_construct_arginfo, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, tag, 1)
ZEND_ARG_ARRAY_INFO(0, smiley, 1)
ZEND_ARG_INFO(0, flag)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(bbcode_construct_arginfo, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, tag, 1)
ZEND_ARG_ARRAY_INFO(0, smiley, 1)
ZEND_ARG_INFO(0, flag)
ZEND_END_ARG_INFO()
+/* {{{ ZEND_BEGIN_ARG_INFO_EX(bbcode_parse_arginfo) */
+ZEND_BEGIN_ARG_INFO_EX(bbcode_parse_arginfo, 0, 0, 1)
+ ZEND_ARG_INFO(0, str)
+ZEND_END_ARG_INFO()
+/* }}} */
+/* { { { PHP_METHOD(BBCode, __construct) {
+ */
PHP_METHOD(BBCode, __construct) {
PHP_METHOD(BBCode, __construct) {
- zend_array *tag;
- zend_array *smiley;
+ HashTable *tag = NULL;
+ HashTable *smiley = NULL;
long flag = BBCODE_DEFAULT_FLAG;
long flag = BBCODE_DEFAULT_FLAG;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|al", &tag, &smiley, &flag) == FAILURE) {
+/*TODO: init tag with [
+ '' => [ ? ]
+]*/
+/* TODO: init smiley with default list
+ * TODO: use prefix in an ini parameter ? ini_setable ?
+ * TODO: make sure it's not really a global and per-app param ?
+ * */
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H|Hl", &tag, &smiley, &flag) == FAILURE) {
- bbcode_object *obj = bbcode_fetch(Z_OBJ_P(getThis()));
+ //bbcode_object *obj = bbcode_fetch(Z_OBJ_P(getThis()));
+ bbcode_object *obj = Z_BBCODE_P(getThis());
assert(obj != NULL);
//TODO: set tag and smiley
assert(obj != NULL);
//TODO: set tag and smiley
Z_LVAL(obj->flag) = flag;
}
Z_LVAL(obj->flag) = flag;
}
+ if (smiley) {
+ obj->smiley = smiley;
+ }
+
+ obj->tag = tag;
+
//obj = zend_object_store_get_object(getThis() TSRMLS_CC);
//if (error) {
//ZVAL_NULL(this);
//obj = zend_object_store_get_object(getThis() TSRMLS_CC);
//if (error) {
//ZVAL_NULL(this);
-/* {{{ PHP_METHOD(BBCode, __toString) {
+/* {{{ PHP_METHOD(BBCode, parse) {
-PHP_METHOD(BBCode, __toString) {
- //TODO:
+PHP_METHOD(BBCode, parse) {
+ zend_string *str = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
+ return;
+ }
+
+ //TODO: apply the parsing on string
+
+ RETURN_STR(str);
const zend_function_entry bbcode_methods[] = {
PHP_ME(BBCode, __construct, bbcode_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(BBCode, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
const zend_function_entry bbcode_methods[] = {
PHP_ME(BBCode, __construct, bbcode_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(BBCode, __destruct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
- PHP_ME(BBCode, __toString, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(BBCode, parse, bbcode_parse_arginfo, ZEND_ACC_PUBLIC)