summaryrefslogtreecommitdiff
path: root/zend/compileroptions.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-11 00:08:41 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-11 00:08:41 +0100
commit1efade1a7667e4e1a34265fb3cf310faf8c80bb6 (patch)
treebd311ac3de5500daae633fbfdb585faf737607ba /zend/compileroptions.h
parent825049026dd2b2e906cdb46279faa39580d931d1 (diff)
refactored script class to have a seperate opcodes class, added file class that uses this same opcodes class
Diffstat (limited to 'zend/compileroptions.h')
-rw-r--r--zend/compileroptions.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/zend/compileroptions.h b/zend/compileroptions.h
new file mode 100644
index 0000000..798cb59
--- /dev/null
+++ b/zend/compileroptions.h
@@ -0,0 +1,57 @@
+/**
+ * CompilerOptions.h
+ *
+ * Helper class to temporarily set compiler options
+ *
+ * When an object is destructed, it automatically restored the previous compiler settings
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2014 Copernica BV
+ */
+
+/**
+ * Open PHP namespace
+ */
+namespace Php {
+
+/**
+ * Class definition
+ */
+class CompilerOptions
+{
+private:
+ /**
+ * The original compiler options
+ * @var int
+ */
+ zend_uint _original;
+
+public:
+ /**
+ * Constructor
+ * @param options
+ */
+ CompilerOptions(zend_uint options)
+ {
+ // remember the old compiler options before we set temporary compile options
+ _original = CG(compiler_options);
+
+ // we're going to evaluate only once
+ CG(compiler_options) = options;
+ }
+
+ /**
+ * Destructor
+ */
+ virtual ~CompilerOptions()
+ {
+ // restore original options
+ CG(compiler_options) = _original;
+ }
+};
+
+/**
+ * End of namespace
+ */
+}
+