From dbb94be50c67ce2d4a132b0811c2a8dac825b49b Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sat, 25 Oct 2014 00:01:56 +0000 Subject: 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 --- src/core/script/Object.hpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src/core/script/Object.hpp') 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 &signature); - const std::map &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 &getProperties() const { return properties; } - const std::map &getMethods() + const std::map &getMethods() const { return methods; } -- cgit v1.2.3