summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Context.h
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/Context.h')
-rw-r--r--Sencha-lang/Context.h66
1 files changed, 57 insertions, 9 deletions
diff --git a/Sencha-lang/Context.h b/Sencha-lang/Context.h
index c432924..bd537b1 100644
--- a/Sencha-lang/Context.h
+++ b/Sencha-lang/Context.h
@@ -24,29 +24,77 @@
*/
class Context {
public:
+ /**
+ * Context has unique name, which is passed to it in constructor.
+ */
Context(std::string name);
std::string name;
+
+ /**
+ * Typedef to make further declarations easier to read.
+ */
typedef SenchaObject (*PointerToNativeFunction)(std::vector<ASTExpression *>);
+
+ /**
+ * Function have to be declared, which means here, registered before usage.
+ * You can register them with register_function functions.
+ */
void register_function(std::string name, PointerToNativeFunction f);
void register_function(std::string name, SenchaFunction * f);
+ /**
+ * Map with function written in C++ stored like {"my_function" : &my_function}
+ */
+ std::map<std::string, PointerToNativeFunction> registered_functions;
+ /**
+ * Map with function written in Sencha stored like {"my_function" : &my_function}
+ */
+ std::map<std::string, SenchaFunction *> registered_sfunctions;
+
+ /**
+ * contains_function("x") returns true if x can be found in registered native (c++) or sencha functions.
+ */
+ bool contains_function(std::string name);
+
+ /**
+ * contains_function("x") returns true if x can be found in registered sencha functions.
+ */
+ bool contains_sfunction(std::string name);
+
+ /**
+ * contains_function("x") returns true if x can be found in registered native (c++).
+ */
+ bool contains_nfunction(std::string name);
+
+ /**
+ * Executes function written in c++
+ */
SenchaObject execute_native_function(std::string name, std::vector<ASTExpression *> arguments);
+
+ /**
+ * get_updated_string(name) return string of given name with all updates done on its elements such as name[9] = "a";
+ */
SenchaObject get_updated_string(std::string name);
+
+ /**
+ * debug() provides very useful info about context. What variables are stored, what are their values.
+ */
std::string debug() ;
+
+ /**
+ * add(name, value) adds value called name to object store.
+ */
void add(std::string name, SenchaObject object);
- void set(std::string name, SenchaObject object);
+
+ /**
+ * get(name) returns value from object store. If there isn't such a value. It returns SenchaObject();
+ */
SenchaObject get(std::string name);
- bool contains_function(std::string name);
- bool contains_sfunction(std::string name);
- bool contains_nfunction(std::string name);
- std::map<std::string, PointerToNativeFunction> registered_functions;
- std::map<std::string, SenchaFunction *> registered_sfunctions;
+
+
virtual ~Context();
private:
unsigned int index;
-
-
-
std::map<std::string, SenchaObject> object_store;
};