From dd5f3a635053aa03417cdab1228e03c94b9c3136 Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Tue, 17 May 2016 13:47:20 +0200 Subject: Fixed final compilation issues --- include/base.h | 2 +- include/file.h | 13 +++++++++---- include/global.h | 22 ++++++++++++---------- include/ini.h | 50 ++++++++------------------------------------------ include/type.h | 28 +++++++++++++++++----------- include/value.h | 41 ++++++++--------------------------------- 6 files changed, 55 insertions(+), 101 deletions(-) (limited to 'include') diff --git a/include/base.h b/include/base.h index 1a1643b..023d711 100644 --- a/include/base.h +++ b/include/base.h @@ -50,7 +50,7 @@ public: /** * Virtual destructor */ - virtual ~Base() {} + virtual ~Base() = default; /** * Get access to a property by name using the [] operator diff --git a/include/file.h b/include/file.h index fff3cd0..4fab1c5 100644 --- a/include/file.h +++ b/include/file.h @@ -8,6 +8,11 @@ * @copyright 2014 Copernica BV */ +/** + * Forward declarations + */ +struct _zend_string; + /** * Set up namespace */ @@ -81,15 +86,15 @@ public: private: /** * The full resolved path name - * @var const char * + * @var struct _zend_string* */ - char *_path = nullptr; + struct _zend_string *_path = nullptr; /** * The opcodes of this file - * @var Opcodes + * @var std::unique_ptr */ - Opcodes *_opcodes = nullptr; + std::unique_ptr _opcodes; /** * Compile the file diff --git a/include/global.h b/include/global.h index 7a66997..605aeec 100644 --- a/include/global.h +++ b/include/global.h @@ -9,9 +9,10 @@ */ /** - * Forward definitions + * Forward declarations */ struct _zval_struct; +struct _zend_string; /** * Namespace @@ -34,12 +35,12 @@ public: * Move constructor * @param global */ - Global(Global &&global) _NOEXCEPT : Value(std::move(global)), _name(std::move(global._name)), _exists(global._exists) {} + Global(Global &&global) _NOEXCEPT; /** * Destructor */ - virtual ~Global() {} + virtual ~Global(); /** * Assignment operator @@ -143,35 +144,36 @@ protected: private: /** * Constructor for non-existing var - * @param name + * + * @param name Name for the variable that does not exist */ - Global(const char *name) : Value(), _name(name), _exists(false) {} + Global(const char *name); /** * Alternative constructor for non-existing var * @param name */ - Global(const std::string &name) : Value(), _name(name), _exists(false) {} + Global(const std::string &name); /** * Constructor to wrap zval for existing global bar * @param name * @param val */ - Global(const char *name, struct _zval_struct *val) : Value(val, true), _name(name), _exists(true) {} + Global(const char *name, struct _zval_struct *val); /** * Alternative constructor to wrap zval * @param name * @param val */ - Global(const std::string &name, struct _zval_struct *val) : Value(val, true), _name(name), _exists(true) {} + Global(const std::string &name, struct _zval_struct *val); /** * Name of the variable - * @var string + * @var struct _zend_string* */ - std::string _name; + struct _zend_string *_name; /** * Does it already exist? diff --git a/include/ini.h b/include/ini.h index 592fba3..a1899a4 100644 --- a/include/ini.h +++ b/include/ini.h @@ -47,68 +47,46 @@ public: * * @param name Name of the php.ini variable * @param value Default value - * @param orig Original value (if the user resets the variable, it is set back to this value) * @param place Place where the ini setting can be changed */ - Ini(const char *name, const char *value, const char *orig, const Place place = Place::All) : - _name(name), _value(value), _orig(orig), _place(place) {} - Ini(const char *name, const char *value, const Place place = Place::All) : - _name(name), _value(value), _orig_empty(true), _place(place) {} + _name(name), _value(value), _place(place) {} /** * Constructors for bool values * * @param name Name of the php.ini variable * @param value Default value - * @param orig Original value (if the user resets the variable, it is set back to this value) * @param place Place where the ini setting can be changed */ - Ini(const char *name,const bool value, const bool orig, const Place place = Place::All) : - _name(name), _value(bool2str(value)), _orig(bool2str(orig)), _place(place) {} - - Ini(const char *name, const bool value, const Place place = Place::All) : - _name(name), _value(bool2str(value)), _orig_empty(true), _place(place) {} + Ini(const char *name, bool value, const Place place = Place::All) : + _name(name), _value(bool2str(value)), _place(place) {} /** * Constructors for integer values * * @param name Name of the php.ini variable * @param value Default value - * @param orig Original value (if the user resets the variable, it is set back to this value) * @param place Place where the ini setting can be changed */ - Ini(const char *name, const int16_t value, const int16_t orig, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig(std::to_string(orig)), _place(place) {} - Ini(const char *name, const int16_t value, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig_empty(true), _place(place) {} - - Ini(const char *name, const int32_t value, const int32_t orig, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig(std::to_string(orig)), _place(place) {} + _name(name), _value(std::to_string(value)), _place(place) {} Ini(const char *name, const int32_t value, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig_empty(true), _place(place) {} - - Ini(const char *name, const int64_t value, const int64_t orig, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig(std::to_string(orig)), _place(place) {} + _name(name), _value(std::to_string(value)), _place(place) {} Ini(const char *name, const int64_t value, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig_empty(true), _place(place) {} + _name(name), _value(std::to_string(value)), _place(place) {} /** * Constructors for floating point values * * @param name Name of the php.ini variable * @param value Default value - * @param orig Original value (if the user resets the variable, it is set back to this value) * @param place Place where the ini setting can be changed */ - Ini(const char *name, const double value, const double orig, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig(std::to_string(orig)), _place(place) {} - Ini(const char *name, const double value, const Place place = Place::All) : - _name(name), _value(std::to_string(value)), _orig_empty(true), _place(place) {} + _name(name), _value(std::to_string(value)), _place(place) {} /** @@ -116,7 +94,7 @@ public: * @param ini_entry * @param module_number */ - void fill(struct _zend_ini_entry *ini_entry, int module_number); + void fill(struct _zend_ini_entry_def *ini_entry, int module_number); private: @@ -147,18 +125,6 @@ private: */ std::string _value; - /** - * ini entry original value - * @var std::string - */ - std::string _orig; - - /** - * Is the orig value set or empty? - * @var bool - */ - bool _orig_empty = false; - /** * Place where the configuration can be changed * @var Place diff --git a/include/type.h b/include/type.h index 151919c..fbffb1f 100644 --- a/include/type.h +++ b/include/type.h @@ -18,17 +18,23 @@ namespace Php { * The values are the same as the ones used internally in Zend */ enum class PHPCPP_EXPORT Type : unsigned char { - Null = 0, // Null will allow any type - Numeric = 1, - Float = 2, - Bool = 3, - Array = 4, - Object = 5, - String = 6, - Resource = 7, - Constant = 8, - ConstantArray = 9, - Callable = 10 + Undefined = 0, // Variable is not set + Null = 1, // Null will allow any type + False = 2, // Boolean false + True = 3, // Boolean true + Numeric = 4, // Integer type + Float = 5, // Floating point type + String = 6, // A string obviously + Array = 7, // An array of things + Object = 8, // An object + Resource = 9, // A resource + Reference = 10, // Reference to another value (can be any type!) + Constant = 11, // A constant value + ConstantAST = 12, // I think an Abstract Syntax tree, not quite sure + + // "fake types", not quite sure what that means + Bool = 13, // You will never get this back as a type + Callable = 14, // I don't know why this is a "fake" type }; /** diff --git a/include/value.h b/include/value.h index 8c10bd8..99c8cc9 100644 --- a/include/value.h +++ b/include/value.h @@ -382,7 +382,7 @@ public: */ bool isNull() const { return type() == Type::Null; } bool isNumeric() const { return type() == Type::Numeric; } - bool isBool() const { return type() == Type::Bool; } + bool isBool() const { return type() == Type::False || type() == Type::True; } bool isString() const { return type() == Type::String; } bool isFloat() const { return type() == Type::Float; } bool isObject() const { return type() == Type::Object; } @@ -402,18 +402,6 @@ public: */ char *buffer() const; - /** - * Resize buffer space. If you want to write directly to the buffer (which - * is returned by the buffer() method), you should first reserve enough - * space in it. This can be done with this reserve() method. This will also - * turn the Value object into a string (if it was not already a string). - * The writable buffer is returned. - * - * @param size - * @return char* - */ - char *reserve(size_t size); - /** * Get access to the raw buffer for read operations. Note that this * only works for string variables - other variables return nullptr. @@ -977,14 +965,9 @@ public: { // store arguments Value vargs[] = { static_cast(args)... }; - //Value vargs[] = { std::forward(args)... }; - - // array of parameters - _zval_struct **params[sizeof...(Args)]; - for(unsigned i=0; i < sizeof...(Args); i++) {params[i] = &vargs[i]._val;} // call the function - return exec(sizeof...(Args), params); + return exec(sizeof...(Args), vargs); } /** @@ -1021,12 +1004,8 @@ public: // store arguments Value vargs[] = { static_cast(args)... }; - // array of parameters - _zval_struct **params[sizeof...(Args)]; - for(unsigned i=0; i < sizeof...(Args); i++) {params[i] = &vargs[i]._val;} - // call the function - return exec(name, sizeof...(Args), params); + return exec(name, sizeof...(Args), vargs); } template @@ -1035,12 +1014,8 @@ public: // store arguments Value vargs[] = { static_cast(args)... }; - // array of parameters - _zval_struct **params[sizeof...(Args)]; - for(unsigned i=0; i < sizeof...(Args); i++) {params[i] = &vargs[i]._val;} - // call the function - return exec(name, sizeof...(Args), params); + return exec(name, sizeof...(Args), vargs); } /** @@ -1116,7 +1091,7 @@ private: * @param argv The parameters * @return Value */ - Value exec(int argc, struct _zval_struct ***params) const; + Value exec(int argc, Value *argv) const; /** * Call method with a number of parameters @@ -1125,8 +1100,8 @@ private: * @param argv The parameters * @return Value */ - Value exec(const char *name, int argc, struct _zval_struct ***params) const; - Value exec(const char *name, int argc, struct _zval_struct ***params); + Value exec(const char *name, int argc, Value *argv) const; + Value exec(const char *name, int argc, Value *argv); /** * Refcount - the number of references to the value @@ -1137,7 +1112,7 @@ private: protected: /** * The wrapped zval - * @var struct zval + * @var struct zval* */ struct _zval_struct *_val; -- cgit v1.2.3