summaryrefslogtreecommitdiff
path: root/include/extension.h
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-04-09 11:00:05 +0600
committervalmat <ufabiz@gmail.com>2014-04-09 11:00:05 +0600
commit6c7c846edd5b74450b76532da33c25e6cc6a10a4 (patch)
tree51b0e0be5c43ddba6ca9351026fc94bf8ae7bc07 /include/extension.h
parent08ed8866a5bba0b23a8d5587116a968512df2568 (diff)
parent33760c3efba4207eac826ff080b5f9b9672fc60e (diff)
Merge branch 'master' into ini-master
Conflicts: include/namespace.h zend/extensionimpl.cpp
Diffstat (limited to 'include/extension.h')
-rw-r--r--include/extension.h129
1 files changed, 24 insertions, 105 deletions
diff --git a/include/extension.h b/include/extension.h
index 6d1fa0c..fcc0f72 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -6,7 +6,7 @@
* apache process starts - and will be used for all subsequent requests that
* are handled by Apache.
*
- * For some environments (for example CLI scripts and FastCGI calls) only one
+ * For some environments (for example CLI scripts and CGI calls) only one
* request is handled by an extension instance, but for others (when PHP runs
* as module in a webserver) many requests are handled by the same extension
* instance.
@@ -16,11 +16,6 @@
*/
/**
- * Structures referenced in this class
- */
-struct _zend_module_entry;
-
-/**
* Set up namespace
*/
namespace Php {
@@ -28,7 +23,7 @@ namespace Php {
/**
* Forward declaration
*/
-class Extension;
+class ExtensionImpl;
/**
* Signature of a callback
@@ -46,7 +41,7 @@ public:
* @param name Extension name
* @param version Extension version string
*/
- Extension(const char *name = NULL, const char *version = NULL);
+ Extension(const char *name, const char *version = "1.0");
/**
* No copy'ing and no moving
@@ -67,13 +62,10 @@ public:
* is handled. You can register this callback if you want to be notified
* when the engine is ready, for example to initialize certain things.
*
- * @param callback
+ * @param callback Function to be called
+ * @return Extension Same object to allow chaining
*/
- void onStartup(const Callback &callback)
- {
- // copy callback
- _onStartup = callback;
- }
+ Extension &onStartup(const Callback &callback);
/**
* Register a function to be called when the PHP engine is going to stop
@@ -81,13 +73,10 @@ public:
* The callback will be called right before the process is going to stop.
* You can register a function if you want to clean up certain things.
*
- * @param callback
+ * @param callback Function to be called
+ * @return Extension Same object to allow chaining
*/
- void onShutdown(const Callback &callback)
- {
- // copy callback
- _onShutdown = callback;
- }
+ Extension &onShutdown(const Callback &callback);
/**
* Register a callback that is called at the beginning of each pageview/request
@@ -97,13 +86,10 @@ public:
* multiple requests after each other, and you may want to set back certain
* global variables to their initial variables in front of each request
*
- * @param callback
+ * @param callback Function to be called
+ * @return Extension Same object to allow chaining
*/
- void onRequest(const Callback &callback)
- {
- // copy callback
- _onRequest = callback;
- }
+ Extension &onRequest(const Callback &callback);
/**
* Register a callback that is called to cleanup things after a pageview/request
@@ -113,105 +99,38 @@ public:
* This method is called onIdle because the extension is idle in between
* requests.
*
- * @param callback
+ * @param callback Function to be called
+ * @return Extension Same object to allow chaining
*/
- void onIdle(const Callback &callback)
- {
- // copy callback
- _onIdle = callback;
- }
+ Extension &onIdle(const Callback &callback);
/**
- * Retrieve the module entry
+ * Retrieve the module pointer
*
* This is the memory address that should be exported by the get_module()
* function.
*
- * @return _zend_module_entry
+ * @return void*
*/
- _zend_module_entry *module();
+ void *module();
/**
* Cast to a module entry
- * @return _zend_module_entry*
+ *
+ * @return void*
*/
- operator _zend_module_entry * ()
+ operator void * ()
{
return module();
}
private:
/**
- * The information that is passed to the Zend engine
- *
- * Although it would be slightly faster to not make this a pointer, this
- * would require that client code also includes the PHP header files, which
- * we try to prevent with the PHP-CPP library, so we allocate it dynamically.
+ * The implementation object
*
- * @var zend_module_entry
- */
- _zend_module_entry *_entry;
-
- /**
- * Callback that is called after the engine is initialized and before the
- * pageviews are going to be handled
- * @var Callback
- */
- Callback _onStartup;
-
- /**
- * Callback that is called in front of each request
- * @var Callback
- */
- Callback _onRequest;
-
- /**
- * Callback that is called right after each request
- * @var Callback
- */
- Callback _onIdle;
-
- /**
- * Callback that is called right before the engine is closing down
- * @var Callback
- */
- Callback _onShutdown;
-
- /**
- * Function that is called when the extension initializes
- * @param type Module type
- * @param number Module number
- * @param tsrm_ls
- * @return int 0 on success
- */
- static int onStartup(int type, int module_number TSRMLS_DC);
-
- /**
- * Function that is called when the extension is about to be stopped
- * @param type Module type
- * @param number Module number
- * @param tsrm_ls
- * @return int
- */
- static int onShutdown(int type, int module_number TSRMLS_DC);
-
- /**
- * Function that is called when a request starts
- * @param type Module type
- * @param number Module number
- * @param tsrm_ls
- * @return int 0 on success
- */
- static int onRequest(int type, int module_number TSRMLS_DC);
-
- /**
- * Function that is called when a request is ended
- * @param type Module type
- * @param number Module number
- * @param tsrm_ls
- * @return int 0 on success
+ * @var ExtensionImpl
*/
- static int onIdle(int type, int module_number TSRMLS_DC);
+ ExtensionImpl *_impl;
};
/**