2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#pragma once
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "ref.hpp"
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "types.hpp"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <string>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <map>
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								extern "C" {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "libabacus.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "table.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "value.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "util.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class abacus {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    private:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        libab ab;
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ref scope;
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 20:58:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ref rc_scope;
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        std::map<std::string, ref> compiled_types;
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        libab_basetype basetype_string = { [](void* s) { delete ((string*) s); }, NULL, 0 };
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    public:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        abacus();
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-02 16:21:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        const libab_basetype* get_basetype_string();
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        void add_variable(const std::string& name, ref val);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        void add_function(const std::string& name, libab_function_ptr ptr, const std::string& type);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        void add_operator_infix(const std::string& op, const std::string& func, int assoc, int prec);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        void add_operator_prefix(const std::string& op, const std::string& func);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        void add_operator_postfix(const std::string& op, const std::string& func);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-31 23:27:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        void add_standard();
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-27 20:58:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        void add_rc(const std::string& file);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ref run(const std::string& code);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        template <typename ... Ts>
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ref call(const std::string& bane, Ts...params);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        std::string to_string(ref& value);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ~abacus();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								template <typename ... Ts>
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:34:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								ref abacus::call(const std::string& name, Ts...params) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ref value;
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-13 22:32:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    libab_call_function_scoped(&ab, name.c_str(), scope, value, sizeof...(params), (libab_ref*) params...);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-17 01:13:21 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    libab_gc_run(&ab.containers);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |