summaryrefslogtreecommitdiff
path: root/hhvm
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-06 22:51:12 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-06 22:51:12 +0200
commit43cfaa8a4730ea1fa7d9c01f58ddcf6f42b4fb46 (patch)
tree19a42d30fb2d416f2c10fea158eef2f35203611e /hhvm
parent35fd3ccbeb4def71b4d8a59dfbb5c31201b099b9 (diff)
introduced common directory that will contain implementation files that are used for hhvm and zend, and introduced hhvm file for the implementation of hhvmcpp
Diffstat (limited to 'hhvm')
-rw-r--r--hhvm/extension.cpp103
-rw-r--r--hhvm/extensionimpl.h55
-rw-r--r--hhvm/includes.h53
3 files changed, 211 insertions, 0 deletions
diff --git a/hhvm/extension.cpp b/hhvm/extension.cpp
new file mode 100644
index 0000000..9685b32
--- /dev/null
+++ b/hhvm/extension.cpp
@@ -0,0 +1,103 @@
+/**
+ * Extension.cpp
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2013, 2014 Copernica BV
+ */
+#include "includes.h"
+
+/**
+ * Set up namespace
+ */
+namespace Php {
+
+/**
+ * Constructor that defines a number of functions right away
+ * @param name Extension name
+ * @param version Extension version string
+ */
+Extension::Extension(const char *name, const char *version) :
+ Namespace(""), _impl(new ExtensionImpl(this, name, version)) {}
+
+/**
+ * Destructor
+ */
+Extension::~Extension()
+{
+ // get rid of the implementation object
+ delete _impl;
+}
+
+/**
+ * Register a function to be called when the PHP engine is ready
+ * @param callback
+ * @return Extension
+ */
+Extension &Extension::onStartup(const Callback &callback)
+{
+ // pass on to the implementation
+ _impl->onStartup(callback);
+
+ // allow chaining
+ return *this;
+}
+
+/**
+ * Register a function to be called when the PHP engine is going to stop
+ * @param callback
+ * @return Extension
+ */
+Extension &Extension::onShutdown(const Callback &callback)
+{
+ // pass on to the implementation
+ _impl->onShutdown(callback);
+
+ // allow chaining
+ return *this;
+}
+
+/**
+ * Register a callback that is called at the beginning of each pageview/request
+ * @param callback
+ */
+Extension &Extension::onRequest(const Callback &callback)
+{
+ // pass on to the implementation
+ _impl->onRequest(callback);
+
+ // allow chaining
+ return *this;
+}
+
+/**
+ * Register a callback that is called to cleanup things after a pageview/request
+ * @param callback
+ */
+Extension &Extension::onIdle(const Callback &callback)
+{
+ // pass on to the implementation
+ _impl->onIdle(callback);
+
+ // allow chaining
+ return *this;
+}
+
+/**
+ * Retrieve the module pointer
+ *
+ * This is the memory address that should be exported by the get_module()
+ * function.
+ *
+ * @return void*
+ */
+void *Extension::module()
+{
+ // pass on to the implementation
+ return _impl->module();
+}
+
+/**
+ * End of namespace
+ */
+}
+
diff --git a/hhvm/extensionimpl.h b/hhvm/extensionimpl.h
new file mode 100644
index 0000000..deb80a6
--- /dev/null
+++ b/hhvm/extensionimpl.h
@@ -0,0 +1,55 @@
+/**
+ * ExtensionImpl.h
+ *
+ * Implementation of the extension object for the HHVM engine
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2014 Copernica BV
+ */
+
+/**
+ * Namespace
+ */
+namespace Php {
+
+/**
+ * Class definition
+ */
+class ExtensionImpl : public ExtensionBase
+{
+private:
+ /**
+ * Pointer to the extension object that is filled by the extension programmer
+ * @var Extension
+ */
+ Extension *_data;
+
+public:
+ /**
+ * Constructor
+ * @param data Pointer to the extension object created by the extension programmer
+ * @param name Name of the extension
+ * @param version Version identifier of the extension
+ */
+ ExtensionImpl(Extension *data, const char *name, const char *version) : ExtensionBase(data) {}
+
+ /**
+ * Destructor
+ */
+ virtual ~ExtensionImpl() {}
+
+ /**
+ * Pointer to the module that is loaded by HHVM
+ * @return void*
+ */
+ void *module()
+ {
+ return nullptr;
+ }
+};
+
+/**
+ * End of namespace
+ */
+}
+
diff --git a/hhvm/includes.h b/hhvm/includes.h
new file mode 100644
index 0000000..b6f25c1
--- /dev/null
+++ b/hhvm/includes.h
@@ -0,0 +1,53 @@
+/**
+ * Includes.h
+ *
+ * All includes for compiling the HHVM implementation of PHP-CPP
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2014 Copernica BV
+ */
+
+/**
+ * Standard C and C++ libraries
+ */
+#include <functional>
+#include <list>
+#include <memory>
+#include <vector>
+#include <map>
+#include <string.h>
+
+/**
+ * HHVM includes
+ */
+
+
+/**
+ * Public include files
+ */
+#include "../include/type.h"
+#include "../include/hashparent.h"
+#include "../include/value.h"
+#include "../include/parameters.h"
+#include "../include/classtype.h"
+#include "../include/argument.h"
+#include "../include/modifiers.h"
+#include "../include/classbase.h"
+#include "../include/interface.h"
+#include "../include/iterator.h"
+#include "../include/traversable.h"
+#include "../include/serializable.h"
+#include "../include/class.h"
+#include "../include/namespace.h"
+#include "../include/extension.h"
+
+/**
+ * Generic implementation header files
+ */
+#include "../common/extensionbase.h"
+
+/**
+ * Specific HHVM header files for the implementation only
+ */
+#include "extensionimpl.h"
+