summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 15:19:49 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 15:19:49 -0700
commitf08f5850fa39c42974e12e42fa101ffe51eef594 (patch)
tree4b42f9cdf56c1bd909b3c7f8e5297640c367176e /src
parent37c38c70de43d9d9ee3c9f0e2f175e19bcc0b485 (diff)
Renamed request to environment
Diffstat (limited to 'src')
-rw-r--r--src/extension.cpp29
-rw-r--r--src/function.cpp4
-rw-r--r--src/includes.h2
-rw-r--r--src/nativefunction.h12
4 files changed, 26 insertions, 21 deletions
diff --git a/src/extension.cpp b/src/extension.cpp
index 9323bd3..37082b2 100644
--- a/src/extension.cpp
+++ b/src/extension.cpp
@@ -40,7 +40,7 @@ static Extension *extension = nullptr;
* one and only global variable
*/
ZEND_BEGIN_MODULE_GLOBALS(phpcpp)
- Request *request;
+ Environment *environment;
ZEND_END_MODULE_GLOBALS(phpcpp)
/**
@@ -49,9 +49,9 @@ ZEND_END_MODULE_GLOBALS(phpcpp)
* structure above.
*/
#ifdef ZTS
-#define REQUEST_G(v) TSRMG(phpcpp_globals_id, zend_phpcpp_globals *, v)
+#define PHPCPP_G(v) TSRMG(phpcpp_globals_id, zend_phpcpp_globals *, v)
#else
-#define REQUEST_G(v) (phpcpp_globals.v)
+#define PHPCPP_G(v) (phpcpp_globals.v)
#endif
/**
@@ -69,7 +69,7 @@ static ZEND_DECLARE_MODULE_GLOBALS(phpcpp)
* method (crazy)
* @param globals
*/
-static void php_phpcpp_init_globals(zend_phpcpp_globals *globals) {}
+static void init_globals(zend_phpcpp_globals *globals) {}
@@ -81,11 +81,8 @@ static void php_phpcpp_init_globals(zend_phpcpp_globals *globals) {}
*/
static int extension_startup(INIT_FUNC_ARGS)
{
-
-
-
// initialize and allocate the "global" variables
-// ZEND_INIT_MODULE_GLOBALS(hello, php_phpcpp_init_globals, NULL);
+ ZEND_INIT_MODULE_GLOBALS(phpcpp, init_globals, NULL);
// initialize the extension
return BOOL2SUCCESS(extension->initialize());
@@ -111,8 +108,11 @@ static int extension_shutdown(SHUTDOWN_FUNC_ARGS)
*/
static int request_startup(INIT_FUNC_ARGS)
{
- // create the request
- return BOOL2SUCCESS(extension->startRequest());
+ // create the environment
+ PHPCPP_G(environment) = extension->createEnvironment();
+
+ // start the request
+ return BOOL2SUCCESS(extension->startRequest(*(PHPCPP_G(environment))));
}
/**
@@ -124,10 +124,15 @@ static int request_startup(INIT_FUNC_ARGS)
static int request_shutdown(INIT_FUNC_ARGS)
{
// end the request
- return BOOL2SUCCESS(extension->endRequest());
+ bool success = extension->endRequest(*(PHPCPP_G(environment)));
+
+ // deallocate the environment
+ extension->deleteEnvironment(PHPCPP_G(environment));
+
+ // done
+ return BOOL2SUCCESS(success);
}
-
/**
* Constructor
* @param name Name of the extension
diff --git a/src/function.cpp b/src/function.cpp
index 755bb48..10b47b9 100644
--- a/src/function.cpp
+++ b/src/function.cpp
@@ -38,10 +38,10 @@ void invoke_function(INTERNAL_FUNCTION_PARAMETERS)
Parameters params(ZEND_NUM_ARGS());
// @todo get the appropriate request (or environment)
- Request request(NULL);
+ Environment environment(NULL);
// get the result
- result = function->invoke(request, params);
+ result = function->invoke(environment, params);
}
/**
diff --git a/src/includes.h b/src/includes.h
index 22f2891..cfcff2a 100644
--- a/src/includes.h
+++ b/src/includes.h
@@ -36,7 +36,7 @@
*/
#include "../include/hiddenpointer.h"
#include "../include/type.h"
-#include "../include/request.h"
+#include "../include/environment.h"
#include "../include/argument.h"
#include "../include/byval.h"
#include "../include/byref.h"
diff --git a/src/nativefunction.h b/src/nativefunction.h
index e8281ce..88d629f 100644
--- a/src/nativefunction.h
+++ b/src/nativefunction.h
@@ -40,21 +40,21 @@ public:
/**
* Method that gets called every time the function is executed
- * @param request Request environment
+ * @param environment Environment
* @param params The parameters that were passed
* @return Variable Return value
*/
- virtual Value invoke(Request &request, Parameters &params) override
+ virtual Value invoke(Environment &environment, Parameters &params) override
{
switch (_type) {
case 0: _function.f0(); return Value();
case 1: _function.f1(params); return Value();
- case 2: _function.f2(request); return Value();
- case 3: _function.f3(request, params); return Value();
+ case 2: _function.f2(environment); return Value();
+ case 3: _function.f3(environment, params); return Value();
case 4: return _function.f4();
case 5: return _function.f5(params);
- case 6: return _function.f6(request);
- case 7: return _function.f7(request, params);
+ case 6: return _function.f6(environment);
+ case 7: return _function.f7(environment, params);
default: return Value();
}
}