summaryrefslogtreecommitdiff
path: root/src/callable.cpp
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-28 23:11:57 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-08-28 23:11:57 +0200
commit5ab6927a5fa17e73161d7126ca506e5e51ba0e55 (patch)
tree321186e3f01c09c5f739725da5a06abc31104b67 /src/callable.cpp
parentd69d5ca8f8f6a8c75099052f8541d7144385572c (diff)
added parameter handling, and return value handling
Diffstat (limited to 'src/callable.cpp')
-rw-r--r--src/callable.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/callable.cpp b/src/callable.cpp
index 494e9ed..b4b1a6e 100644
--- a/src/callable.cpp
+++ b/src/callable.cpp
@@ -104,6 +104,13 @@ void Callable::process(const std::initializer_list<Argument> &arguments)
}
}
+int do_test(int a, int b)
+{
+ std::cout << "do_test: " << a << " " << b << std::endl;
+
+ return 77;
+}
+
/**
* Invoke the method
* @param ht
@@ -116,11 +123,46 @@ void Callable::process(const std::initializer_list<Argument> &arguments)
*/
int Callable::invoke(INTERNAL_FUNCTION_PARAMETERS)
{
+ std::cout << "args: " << ZEND_NUM_ARGS() << std::endl;
+ std::cout << "required: " << _required << std::endl;
+ std::cout << "argc: " << _argc << std::endl;
+
+ // number of arguments should be sufficient // @todo show error message
+// if (ZEND_NUM_ARGS() < _required) return FAILURE;
+ // and not be too much // @todo show error message
+// if (ZEND_NUM_ARGS() > _argc) return FAILURE;
+ // number of arguments on the stack
+ int arg_count = (int)(zend_uintptr_t) *(zend_vm_stack_top(TSRMLS_C) - 1);
+ // loop through the arguments
+ Arguments args(ZEND_NUM_ARGS());
+
+ for (auto iter = args.begin(); iter != args.end(); iter++)
+ {
+ Value val = *iter;
+
+ val = 1234;
+
+ std::cout << "argument: " << iter->stringValue() << std::endl;
+ }
+
+ int result = do_test(args[1], args[2]);
+
+ return SUCCESS;
+
+ Value ret(return_value, true);
+
+ ret = result;
+
+ // done
+ return SUCCESS;
}
+
+
+
/**
* End of namespace
*/