diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-10-25 00:01:56 +0000 |
---|---|---|
committer | andreas <andreas@daaaf23c-2e50-4459-9457-1e69db5a47bf> | 2014-10-25 00:01:56 +0000 |
commit | dbb94be50c67ce2d4a132b0811c2a8dac825b49b (patch) | |
tree | 7cf2dcfd4a8ec992a832911d8867d493ad337858 /src/core/script/Object.hpp | |
parent | 16d900d3e8341663e53cb1f4c719578e12df829d (diff) |
started unit test for Object, fixed possible used of already freed ArgumentValidator when copying ValidatingFunction
git-svn-id: file:///var/local/svn/basicwriter@77 daaaf23c-2e50-4459-9457-1e69db5a47bf
Diffstat (limited to 'src/core/script/Object.hpp')
-rw-r--r-- | src/core/script/Object.hpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/core/script/Object.hpp b/src/core/script/Object.hpp index 20e0f0f..fafe632 100644 --- a/src/core/script/Object.hpp +++ b/src/core/script/Object.hpp @@ -38,7 +38,7 @@ struct Property { * @param get is the getter that should be used for the property. * @param set is the setter that should be used for the property. */ - Property(const Getter &get, const Setter &set) : get(get), set(set){}; + Property(const Getter &get, const Setter &set) : get(get), set(set) {}; /** * Constructor of the Property struct. Creates new Getter and Setter @@ -51,7 +51,7 @@ struct Property { */ Property(VariantType type, const GetterCallback get, const SetterCallback set, void *data = nullptr) - : get(get, data), set(type, set, data){}; + : get(get, data), set(type, set, data) {}; /** * Getter function. @@ -92,35 +92,45 @@ private: public: Object() : data(nullptr){}; - + Object(void *data) : data(data){}; - bool hasElement(std::string name) const; + bool hasElement(const std::string &name) const; - void addProperty(std::string name, const Property &property); + void addProperty(const std::string &name, const Property &property); - void addProperty(std::string name, const Getter &get, const Setter &set); + void addProperty(const std::string &name, const Getter &get, const Setter &set); - void addProperty(std::string name, VariantType type, + void addProperty(const std::string &name, VariantType type, const GetterCallback get, const SetterCallback set); - void addReadonlyProperty(std::string name, const Getter &get); + void addReadonlyProperty(const std::string &name, const Getter &get); - void addReadonlyProperty(std::string name, const GetterCallback get); + void addReadonlyProperty(const std::string &name, const GetterCallback get); - void addMethod(std::string name, const HostFunction &fun); + void addMethod(const std::string &name, const HostFunction &fun); - void addMethod(std::string name, const HostFunctionCallback fun); + void addMethod(const std::string &name, const HostFunctionCallback fun); - void addMethod(std::string name, const HostFunctionCallback fun, + void addMethod(const std::string &name, const HostFunctionCallback fun, const std::vector<Argument> &signature); - const std::map<std::string, Property> &getProperties() + const Property *getProperty(const std::string &name) const; + + const Function *getMethod(const std::string &name) const; + + bool removeElement(const std::string &name); + + bool removeProperty(const std::string &name); + + bool removeMethod(const std::string &name); + + const std::map<std::string, Property> &getProperties() const { return properties; } - const std::map<std::string, HostFunction> &getMethods() + const std::map<std::string, HostFunction> &getMethods() const { return methods; } |