GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
chaiscript_engine.hpp
Go to the documentation of this file.
1// This file is distributed under the BSD License.
2// See "license.txt" for details.
3// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
4// Copyright 2009-2017, Jason Turner (jason@emptycrate.com)
5// http://www.chaiscript.com
6
7// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9
10
11#ifndef CHAISCRIPT_ENGINE_HPP_
12#define CHAISCRIPT_ENGINE_HPP_
13
14#include <cassert>
15#include <exception>
16#include <fstream>
17#include <functional>
18#include <map>
19#include <memory>
20#include <mutex>
21#include <set>
22#include <stdexcept>
23#include <vector>
24#include <cstring>
25
33#include "chaiscript_common.hpp"
34
35#if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
36#include <unistd.h>
37#endif
38
39#if !defined(CHAISCRIPT_NO_DYNLOAD) && defined(_POSIX_VERSION) && !defined(__CYGWIN__)
40#include <dlfcn.h>
41#endif
42
43#if defined(CHAISCRIPT_NO_DYNLOAD)
45#elif defined(CHAISCRIPT_WINDOWS)
47#elif _POSIX_VERSION
48#include "chaiscript_posix.hpp"
49#else
51#endif
52
53
55
56namespace chaiscript
57{
60
61 namespace detail
62 {
63 typedef std::shared_ptr<Loadable_Module> Loadable_Module_Ptr;
64 }
65
66
69
71 mutable chaiscript::detail::threading::recursive_mutex m_use_mutex;
72
73 std::set<std::string> m_used_files;
74 std::map<std::string, detail::Loadable_Module_Ptr> m_loaded_modules;
75 std::set<std::string> m_active_loaded_modules;
76
77 std::vector<std::string> m_module_paths;
78 std::vector<std::string> m_use_paths;
79
80 std::unique_ptr<parser::ChaiScript_Parser_Base> m_parser;
81
83
84 std::map<std::string, std::function<Namespace&()>> m_namespace_generators;
85
87 Boxed_Value do_eval(const std::string &t_input, const std::string &t_filename = "__EVAL__", bool /* t_internal*/ = false)
88 {
89 try {
90 const auto p = m_parser->parse(t_input, t_filename);
91 return p->eval(chaiscript::detail::Dispatch_State(m_engine));
92 }
94 return rv.retval;
95 }
96 }
97
98
99
101 const Boxed_Value internal_eval_file(const std::string &t_filename) {
102 for (const auto &path : m_use_paths)
103 {
104 try {
105 const auto appendedpath = path + t_filename;
106 return do_eval(load_file(appendedpath), appendedpath, true);
107 } catch (const exception::file_not_found_error &) {
108 // failed to load, try the next path
109 } catch (const exception::eval_error &t_ee) {
110 throw Boxed_Value(t_ee);
111 }
112 }
113
114 // failed to load by any name
115 throw exception::file_not_found_error(t_filename);
116
117 }
118
119
120
122 const Boxed_Value internal_eval(const std::string &t_e) {
123 try {
124 return do_eval(t_e, "__EVAL__", true);
125 } catch (const exception::eval_error &t_ee) {
126 throw Boxed_Value(t_ee);
127 }
128 }
129
131 chaiscript::detail::Dispatch_Engine &get_eval_engine() {
132 return m_engine;
133 }
134
136 void build_eval_system(const ModulePtr &t_lib, const std::vector<Options> &t_opts) {
137 if (t_lib)
138 {
139 add(t_lib);
140 }
141
142 m_engine.add(fun([this](){ m_engine.dump_system(); }), "dump_system");
143 m_engine.add(fun([this](const Boxed_Value &t_bv){ m_engine.dump_object(t_bv); }), "dump_object");
144 m_engine.add(fun([this](const Boxed_Value &t_bv, const std::string &t_type){ return m_engine.is_type(t_bv, t_type); }), "is_type");
145 m_engine.add(fun([this](const Boxed_Value &t_bv){ return m_engine.type_name(t_bv); }), "type_name");
146 m_engine.add(fun([this](const std::string &t_f){ return m_engine.function_exists(t_f); }), "function_exists");
147 m_engine.add(fun([this](){ return m_engine.get_function_objects(); }), "get_functions");
148 m_engine.add(fun([this](){ return m_engine.get_scripting_objects(); }), "get_objects");
149
150 m_engine.add(
152 [this](const std::vector<Boxed_Value> &t_params) {
153 return m_engine.call_exists(t_params);
154 })
155 , "call_exists");
156
157
158 m_engine.add(fun(
159 [=](const dispatch::Proxy_Function_Base &t_fun, const std::vector<Boxed_Value> &t_params) -> Boxed_Value {
160 Type_Conversions_State s(this->m_engine.conversions(), this->m_engine.conversions().conversion_saves());
161 return t_fun(t_params, s);
162 }), "call");
163
164
165 m_engine.add(fun([this](const Type_Info &t_ti){ return m_engine.get_type_name(t_ti); }), "name");
166
167 m_engine.add(fun([this](const std::string &t_type_name, bool t_throw){ return m_engine.get_type(t_type_name, t_throw); }), "type");
168 m_engine.add(fun([this](const std::string &t_type_name){ return m_engine.get_type(t_type_name, true); }), "type");
169
170 m_engine.add(fun(
171 [=](const Type_Info &t_from, const Type_Info &t_to, const std::function<Boxed_Value (const Boxed_Value &)> &t_func) {
172 m_engine.add(chaiscript::type_conversion(t_from, t_to, t_func));
173 }
174 ), "add_type_conversion");
175
176
177
178 if (std::find(t_opts.begin(), t_opts.end(), Options::No_Load_Modules) == t_opts.end()
179 && std::find(t_opts.begin(), t_opts.end(), Options::Load_Modules) != t_opts.end())
180 {
181 m_engine.add(fun([this](const std::string &t_module, const std::string &t_file){ return load_module(t_module, t_file); }), "load_module");
182 m_engine.add(fun([this](const std::string &t_module){ return load_module(t_module); }), "load_module");
183 }
184
185 if (std::find(t_opts.begin(), t_opts.end(), Options::No_External_Scripts) == t_opts.end()
186 && std::find(t_opts.begin(), t_opts.end(), Options::External_Scripts) != t_opts.end())
187 {
188 m_engine.add(fun([this](const std::string &t_file){ return use(t_file); }), "use");
189 m_engine.add(fun([this](const std::string &t_file){ return internal_eval_file(t_file); }), "eval_file");
190 }
191
192 m_engine.add(fun([this](const std::string &t_str){ return internal_eval(t_str); }), "eval");
193 m_engine.add(fun([this](const AST_Node &t_ast){ return eval(t_ast); }), "eval");
194
195 m_engine.add(fun([this](const std::string &t_str, const bool t_dump){ return parse(t_str, t_dump); }), "parse");
196 m_engine.add(fun([this](const std::string &t_str){ return parse(t_str); }), "parse");
197
198
199 m_engine.add(fun([this](const Boxed_Value &t_bv, const std::string &t_name){ add_global_const(t_bv, t_name); }), "add_global_const");
200 m_engine.add(fun([this](const Boxed_Value &t_bv, const std::string &t_name){ add_global(t_bv, t_name); }), "add_global");
201 m_engine.add(fun([this](const Boxed_Value &t_bv, const std::string &t_name){ set_global(t_bv, t_name); }), "set_global");
202
203 m_engine.add(fun([this](const std::string& t_namespace_name) { register_namespace([](Namespace& /*space*/) {}, t_namespace_name); import(t_namespace_name); }), "namespace");
204 m_engine.add(fun([this](const std::string& t_namespace_name) { import(t_namespace_name); }), "import");
205 }
206
208 static bool skip_bom(std::ifstream &infile) {
209 size_t bytes_needed = 3;
210 char buffer[3];
211
212 memset(buffer, '\0', bytes_needed);
213
214 infile.read(buffer, static_cast<std::streamsize>(bytes_needed));
215
216 if ((buffer[0] == '\xef')
217 && (buffer[1] == '\xbb')
218 && (buffer[2] == '\xbf')) {
219
220 infile.seekg(3);
221 return true;
222 }
223
224 infile.seekg(0);
225
226 return false;
227 }
228
230 static std::string load_file(const std::string &t_filename) {
231 std::ifstream infile(t_filename.c_str(), std::ios::in | std::ios::ate | std::ios::binary );
232
233 if (!infile.is_open()) {
235 }
236
237 auto size = infile.tellg();
238 infile.seekg(0, std::ios::beg);
239
240 assert(size >= 0);
241
242 if (skip_bom(infile)) {
243 size-=3; // decrement the BOM size from file size, otherwise we'll get parsing errors
244 assert(size >= 0); //and check if there's more text
245 }
246
247 if (size == std::streampos(0))
248 {
249 return std::string();
250 } else {
251 std::vector<char> v(static_cast<size_t>(size));
252 infile.read(&v[0], static_cast<std::streamsize>(size));
253 return std::string(v.begin(), v.end());
254 }
255 }
256
257 std::vector<std::string> ensure_minimum_path_vec(std::vector<std::string> paths)
258 {
259 if (paths.empty()) { return {""}; }
260 else { return paths; }
261 }
262
263 public:
264
270 std::unique_ptr<parser::ChaiScript_Parser_Base> &&parser,
271 std::vector<std::string> t_module_paths = {},
272 std::vector<std::string> t_use_paths = {},
273 const std::vector<chaiscript::Options> &t_opts = chaiscript::default_options())
274 : m_module_paths(ensure_minimum_path_vec(std::move(t_module_paths))),
275 m_use_paths(ensure_minimum_path_vec(std::move(t_use_paths))),
276 m_parser(std::move(parser)),
277 m_engine(*m_parser)
278 {
279#if !defined(CHAISCRIPT_NO_DYNLOAD) && defined(_POSIX_VERSION) && !defined(__CYGWIN__)
280 // If on Unix, add the path of the current executable to the module search path
281 // as windows would do
282
283 union cast_union
284 {
285 Boxed_Value (ChaiScript_Basic::*in_ptr)(const std::string&);
286 void *out_ptr;
287 };
288
289 Dl_info rInfo;
290 memset( &rInfo, 0, sizeof(rInfo) );
291 cast_union u;
292 u.in_ptr = &ChaiScript_Basic::use;
293 if ( (dladdr(static_cast<void*>(u.out_ptr), &rInfo) != 0) && (rInfo.dli_fname != nullptr) ) {
294 std::string dllpath(rInfo.dli_fname);
295 const size_t lastslash = dllpath.rfind('/');
296 if (lastslash != std::string::npos)
297 {
298 dllpath.erase(lastslash);
299 }
300
301 // Let's see if this is a link that we should expand
302 std::vector<char> buf(2048);
303 const auto pathlen = readlink(dllpath.c_str(), &buf.front(), buf.size());
304 if (pathlen > 0 && static_cast<size_t>(pathlen) < buf.size())
305 {
306 dllpath = std::string(&buf.front(), static_cast<size_t>(pathlen));
307 }
308
309 m_module_paths.insert(m_module_paths.begin(), dllpath+"/");
310 }
311#endif
312 build_eval_system(t_lib, t_opts);
313 }
314
315#ifndef CHAISCRIPT_NO_DYNLOAD
323 explicit ChaiScript_Basic(std::unique_ptr<parser::ChaiScript_Parser_Base> &&parser,
324 std::vector<std::string> t_module_paths = {},
325 std::vector<std::string> t_use_paths = {},
326 const std::vector<chaiscript::Options> &t_opts = chaiscript::default_options())
327 : ChaiScript_Basic({}, std::move(parser), t_module_paths, t_use_paths, t_opts)
328 {
329 try {
330 // attempt to load the stdlib
331 load_module("chaiscript_stdlib-" + Build_Info::version());
332 } catch (const exception::load_module_error &t_err) {
333 std::cout << "An error occured while trying to load the chaiscript standard library.\n"
334 << "\n"
335 << "You must either provide a standard library, or compile it in.\n"
336 << "For an example of compiling the standard library in,\n"
337 << "see: https://gist.github.com/lefticus/9456197\n"
338 << "Compiling the stdlib in is the recommended and MOST SUPPORTED method.\n"
339 << "\n"
340 << "\n"
341 << t_err.what();
342 throw;
343 }
344 }
345#else // CHAISCRIPT_NO_DYNLOAD
346explicit ChaiScript_Basic(std::unique_ptr<parser::ChaiScript_Parser_Base> &&parser,
347 std::vector<std::string> t_module_paths = {},
348 std::vector<std::string> t_use_paths = {},
349 const std::vector<chaiscript::Options> &t_opts = chaiscript::default_options()) = delete;
350#endif
351
353 {
354 return *m_parser;
355 }
356
357 const Boxed_Value eval(const AST_Node &t_ast)
358 {
359 try {
360 return t_ast.eval(chaiscript::detail::Dispatch_State(m_engine));
361 } catch (const exception::eval_error &t_ee) {
362 throw Boxed_Value(t_ee);
363 }
364 }
365
366 AST_NodePtr parse(const std::string &t_input, const bool t_debug_print = false)
367 {
368 auto ast = m_parser->parse(t_input, "PARSE");
369 if (t_debug_print) {
370 m_parser->debug_print(*ast);
371 }
372 return ast;
373 }
374
375
376 std::string get_type_name(const Type_Info &ti) const
377 {
378 return m_engine.get_type_name(ti);
379 }
380
381 template<typename T>
382 std::string get_type_name() const
383 {
384 return get_type_name(user_type<T>());
385 }
386
387
393 Boxed_Value use(const std::string &t_filename)
394 {
395 for (const auto &path : m_use_paths)
396 {
397 const auto appendedpath = path + t_filename;
398 try {
399
402
403 Boxed_Value retval;
404
405 if (m_used_files.count(appendedpath) == 0)
406 {
407 l2.unlock();
408 retval = eval_file(appendedpath);
409 l2.lock();
410 m_used_files.insert(appendedpath);
411 }
412
413 return retval; // return, we loaded it, or it was already loaded
414 } catch (const exception::file_not_found_error &e) {
415 if (e.filename != appendedpath) {
416 // a nested file include failed
417 throw;
418 }
419 // failed to load, try the next path
420 }
421 }
422
423 // failed to load by any name
424 throw exception::file_not_found_error(t_filename);
425 }
426
432 ChaiScript_Basic &add_global_const(const Boxed_Value &t_bv, const std::string &t_name)
433 {
435 m_engine.add_global_const(t_bv, t_name);
436 return *this;
437 }
438
444 ChaiScript_Basic &add_global(const Boxed_Value &t_bv, const std::string &t_name)
445 {
447 m_engine.add_global(t_bv, t_name);
448 return *this;
449 }
450
451 ChaiScript_Basic &set_global(const Boxed_Value &t_bv, const std::string &t_name)
452 {
454 m_engine.set_global(t_bv, t_name);
455 return *this;
456 }
457
463 struct State
464 {
465 std::set<std::string> used_files;
467 std::set<std::string> active_loaded_modules;
468 };
469
484 {
487
488 State s;
489 s.used_files = m_used_files;
490 s.engine_state = m_engine.get_state();
491 s.active_loaded_modules = m_active_loaded_modules;
492 return s;
493 }
494
509 void set_state(const State &t_state)
510 {
513
514 m_used_files = t_state.used_files;
515 m_active_loaded_modules = t_state.active_loaded_modules;
516 m_engine.set_state(t_state.engine_state);
517 }
518
520 std::map<std::string, Boxed_Value> get_locals() const
521 {
522 return m_engine.get_locals();
523 }
524
530 void set_locals(const std::map<std::string, Boxed_Value> &t_locals)
531 {
532 m_engine.set_locals(t_locals);
533 }
534
550 template<typename T>
551 ChaiScript_Basic &add(const T &t_t, const std::string &t_name)
552 {
554 m_engine.add(t_t, t_name);
555 return *this;
556 }
557
568 {
569 m_engine.add(d);
570 return *this;
571 }
572
577 {
578 t_p->apply(*this, this->get_eval_engine());
579 return *this;
580 }
581
594 std::string load_module(const std::string &t_module_name)
595 {
596#ifdef CHAISCRIPT_NO_DYNLOAD
597 (void)t_module_name; // -Wunused-parameter
598 throw chaiscript::exception::load_module_error("Loadable module support was disabled (CHAISCRIPT_NO_DYNLOAD)");
599#else
600 std::vector<exception::load_module_error> errors;
601 std::string version_stripped_name = t_module_name;
602 size_t version_pos = version_stripped_name.find("-" + Build_Info::version());
603 if (version_pos != std::string::npos)
604 {
605 version_stripped_name.erase(version_pos);
606 }
607
608 std::vector<std::string> prefixes{"lib", "cyg", ""};
609
610 std::vector<std::string> postfixes{".dll", ".so", ".bundle", ""};
611
612 for (auto & elem : m_module_paths)
613 {
614 for (auto & prefix : prefixes)
615 {
616 for (auto & postfix : postfixes)
617 {
618 try {
619 const auto name = elem + prefix + t_module_name + postfix;
620 // std::cerr << "trying location: " << name << '\n';
621 load_module(version_stripped_name, name);
622 return name;
624 // std::cerr << "error: " << e.what() << '\n';
625 errors.push_back(e);
626 // Try next set
627 }
628 }
629 }
630 }
631
632 throw chaiscript::exception::load_module_error(t_module_name, errors);
633#endif
634 }
635
643 void load_module(const std::string &t_module_name, const std::string &t_filename)
644 {
646
647 if (m_loaded_modules.count(t_module_name) == 0)
648 {
649 detail::Loadable_Module_Ptr lm(new detail::Loadable_Module(t_module_name, t_filename));
650 m_loaded_modules[t_module_name] = lm;
651 m_active_loaded_modules.insert(t_module_name);
652 add(lm->m_moduleptr);
653 } else if (m_active_loaded_modules.count(t_module_name) == 0) {
654 m_active_loaded_modules.insert(t_module_name);
655 add(m_loaded_modules[t_module_name]->m_moduleptr);
656 }
657 }
658
659
668 Boxed_Value operator()(const std::string &t_script, const Exception_Handler &t_handler = Exception_Handler())
669 {
670 return eval(t_script, t_handler);
671 }
672
686 template<typename T>
687 T eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler(), const std::string &t_filename="__EVAL__")
688 {
689 return m_engine.boxed_cast<T>(eval(t_input, t_handler, t_filename));
690 }
691
693 template<typename Type>
694 decltype(auto) boxed_cast(const Boxed_Value &bv) const
695 {
696 return(m_engine.boxed_cast<Type>(bv));
697 }
698
699
710 Boxed_Value eval(const std::string &t_input, const Exception_Handler &t_handler = Exception_Handler(), const std::string &t_filename="__EVAL__")
711 {
712 try {
713 return do_eval(t_input, t_filename);
714 } catch (Boxed_Value &bv) {
715 if (t_handler) {
716 t_handler->handle(bv, m_engine);
717 }
718 throw;
719 }
720 }
721
727 Boxed_Value eval_file(const std::string &t_filename, const Exception_Handler &t_handler = Exception_Handler()) {
728 return eval(load_file(t_filename), t_handler, t_filename);
729 }
730
739 template<typename T>
740 T eval_file(const std::string &t_filename, const Exception_Handler &t_handler = Exception_Handler()) {
741 return m_engine.boxed_cast<T>(eval_file(t_filename, t_handler));
742 }
743
747 void import(const std::string& t_namespace_name)
748 {
750
751 if (m_engine.get_scripting_objects().count(t_namespace_name)) {
752 throw std::runtime_error("Namespace: " + t_namespace_name + " was already defined");
753 }
754 else if (m_namespace_generators.count(t_namespace_name)) {
755 m_engine.add_global(var(std::ref(m_namespace_generators[t_namespace_name]())), t_namespace_name);
756 }
757 else {
758 throw std::runtime_error("No registered namespace: " + t_namespace_name);
759 }
760 }
761
766 void register_namespace(const std::function<void(Namespace&)>& t_namespace_generator, const std::string& t_namespace_name)
767 {
769
770 if (!m_namespace_generators.count(t_namespace_name)) {
771 // contain the namespace object memory within the m_namespace_generators map
772 m_namespace_generators.emplace(std::make_pair(t_namespace_name, [=, space = Namespace()]() mutable -> Namespace& { t_namespace_generator(space); return space; }));
773 }
774 else {
775 throw std::runtime_error("Namespace: " + t_namespace_name + " was already registered.");
776 }
777 }
778 };
779
780}
781#endif /* CHAISCRIPT_ENGINE_HPP_ */
782
Env e
Definition Common.cc:2
Type
Definition Database.hh:9
A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects.
Definition boxed_value.hpp:28
void load_module(const std::string &t_module_name, const std::string &t_filename)
Load a binary module from a dynamic library. Works on platforms that support dynamic libraries.
Definition chaiscript_engine.hpp:643
ChaiScript_Basic & add(const Type_Conversion &d)
Add a new conversion for upcasting to a base class.
Definition chaiscript_engine.hpp:567
std::map< std::string, Boxed_Value > get_locals() const
Definition chaiscript_engine.hpp:520
const Boxed_Value eval(const AST_Node &t_ast)
Definition chaiscript_engine.hpp:357
T eval_file(const std::string &t_filename, const Exception_Handler &t_handler=Exception_Handler())
Loads the file specified by filename, evaluates it, and returns the type safe result.
Definition chaiscript_engine.hpp:740
std::string load_module(const std::string &t_module_name)
Load a binary module from a dynamic library. Works on platforms that support dynamic libraries.
Definition chaiscript_engine.hpp:594
ChaiScript_Basic(std::unique_ptr< parser::ChaiScript_Parser_Base > &&parser, std::vector< std::string > t_module_paths={}, std::vector< std::string > t_use_paths={}, const std::vector< chaiscript::Options > &t_opts=chaiscript::default_options())
Constructor for ChaiScript.
Definition chaiscript_engine.hpp:323
void set_locals(const std::map< std::string, Boxed_Value > &t_locals)
Sets all of the locals for the current thread state.
Definition chaiscript_engine.hpp:530
ChaiScript_Basic & add_global_const(const Boxed_Value &t_bv, const std::string &t_name)
Adds a constant object that is available in all contexts and to all threads.
Definition chaiscript_engine.hpp:432
Boxed_Value eval(const std::string &t_input, const Exception_Handler &t_handler=Exception_Handler(), const std::string &t_filename="__EVAL__")
Evaluates a string.
Definition chaiscript_engine.hpp:710
decltype(auto) boxed_cast(const Boxed_Value &bv) const
casts an object while applying any Dynamic_Conversion available
Definition chaiscript_engine.hpp:694
ChaiScript_Basic & add(const T &t_t, const std::string &t_name)
Adds a type, function or object to ChaiScript. Objects are added to the local thread state.
Definition chaiscript_engine.hpp:551
AST_NodePtr parse(const std::string &t_input, const bool t_debug_print=false)
Definition chaiscript_engine.hpp:366
State get_state() const
Returns a state object that represents the current state of the global system.
Definition chaiscript_engine.hpp:483
Boxed_Value eval_file(const std::string &t_filename, const Exception_Handler &t_handler=Exception_Handler())
Loads the file specified by filename, evaluates it, and returns the result.
Definition chaiscript_engine.hpp:727
void register_namespace(const std::function< void(Namespace &)> &t_namespace_generator, const std::string &t_namespace_name)
Registers a namespace generator, which delays generation of the namespace until it is imported,...
Definition chaiscript_engine.hpp:766
ChaiScript_Basic(const ModulePtr &t_lib, std::unique_ptr< parser::ChaiScript_Parser_Base > &&parser, std::vector< std::string > t_module_paths={}, std::vector< std::string > t_use_paths={}, const std::vector< chaiscript::Options > &t_opts=chaiscript::default_options())
Constructor for ChaiScript.
Definition chaiscript_engine.hpp:269
void set_state(const State &t_state)
Sets the state of the system.
Definition chaiscript_engine.hpp:509
Boxed_Value operator()(const std::string &t_script, const Exception_Handler &t_handler=Exception_Handler())
Evaluates a string. Equivalent to ChaiScript::eval.
Definition chaiscript_engine.hpp:668
T eval(const std::string &t_input, const Exception_Handler &t_handler=Exception_Handler(), const std::string &t_filename="__EVAL__")
Evaluates a string and returns a typesafe result.
Definition chaiscript_engine.hpp:687
Boxed_Value use(const std::string &t_filename)
Loads and parses a file. If the file is already, it is not reloaded The use paths specified at ChaiSc...
Definition chaiscript_engine.hpp:393
ChaiScript_Basic & add_global(const Boxed_Value &t_bv, const std::string &t_name)
Adds a mutable object that is available in all contexts and to all threads.
Definition chaiscript_engine.hpp:444
ChaiScript_Basic & set_global(const Boxed_Value &t_bv, const std::string &t_name)
Definition chaiscript_engine.hpp:451
std::string get_type_name() const
Definition chaiscript_engine.hpp:382
std::string get_type_name(const Type_Info &ti) const
Definition chaiscript_engine.hpp:376
ChaiScript_Basic & add(const ModulePtr &t_p)
Adds all elements of a module to ChaiScript runtime.
Definition chaiscript_engine.hpp:576
parser::ChaiScript_Parser_Base & get_parser()
Definition chaiscript_engine.hpp:352
Definition type_conversions.hpp:512
Conversion_Saves & conversion_saves() const
Definition type_conversions.hpp:466
Compile time deduced information about a type.
Definition type_info.hpp:34
Definition dispatchkit.hpp:438
void add(const Type_Conversion &d)
Add a new conversion for upcasting to a base class.
Definition dispatchkit.hpp:469
const Type_Conversions & conversions() const
Definition dispatchkit.hpp:933
Definition dispatchkit.hpp:1513
Definition dynamic_object.hpp:44
Definition proxy_functions.hpp:196
Definition chaiscript_common.hpp:623
d
Definition meshpage.php:3895
iVBORw0KGgoAAAANSUhEUgAAANcAAAB5CAMAAACdtUQZAAAA51BMVEX</div ></div >< div style="padding: 0px 0px; width: 1324px;">< div style="height: 400px; width: 1324px;"></div >< div itemscope itemtype="https: </div><div itemscope itemtype="https:</div >< div itemscope itemtype="https: </div></div><p><div style="padding:0px 0px;width:1324px;"><div></div><div itemscope itemtype="https:< ul >< li >< b > Application name
8AkrcAgqgAs9wqQ0ey2tkAo8gAuuQfeI4hPUH09fXHy8z4+fng4uNKXF/Lz9BzfoAcgpkQMTUAKjAbOT4Qr9AXhJ8Rl7ktMCwTosA...
Definition meshpage.php:1610
n< br > font size
Definition meshpage.php:3536
std::lock_guard< T > lock_guard
Definition chaiscript_threading.hpp:55
std::unique_lock< T > shared_lock
Definition chaiscript_threading.hpp:52
std::mutex shared_mutex
Definition chaiscript_threading.hpp:58
std::unique_lock< T > unique_lock
Definition chaiscript_threading.hpp:49
Classes and functions reserved for internal use. Items in this namespace are not supported.
std::shared_ptr< Loadable_Module > Loadable_Module_Ptr
Definition chaiscript_engine.hpp:63
Proxy_Function make_dynamic_proxy_function(Callable &&c, Arg &&... a)
Definition proxy_functions.hpp:504
Classes and functions used during the parsing process.
Definition dispatchkit.hpp:44
Namespace chaiscript contains every API call that the average user will be concerned with.
Type_Conversion type_conversion(const Type_Info &t_from, const Type_Info &t_to, const Callable &t_func)
Definition type_conversions.hpp:583
constexpr Type_Info user_type(const T &)
Creates a Type_Info object representing the type passed in.
Definition type_info.hpp:221
@ No_External_Scripts
Definition chaiscript_defines.hpp:231
@ External_Scripts
Definition chaiscript_defines.hpp:232
@ No_Load_Modules
Definition chaiscript_defines.hpp:229
@ Load_Modules
Definition chaiscript_defines.hpp:230
dispatch::Dynamic_Object Namespace
Namespace alias to provide cleaner and more explicit syntax to users.
Definition chaiscript_engine.hpp:59
Proxy_Function fun(const T &t)
Creates a new Proxy_Function object from a free function, member function or data member.
Definition register_function.hpp:43
std::shared_ptr< chaiscript::detail::Type_Conversion_Base > Type_Conversion
Definition type_conversions.hpp:538
Boxed_Value var(T &&t)
Creates a Boxed_Value. If the object passed in is a value type, it is copied. If it is a pointer,...
Definition boxed_value.hpp:387
std::shared_ptr< detail::Exception_Handler_Base > Exception_Handler
Used in the automatic unboxing of exceptions thrown during script evaluation.
Definition exception_specification.hpp:104
std::shared_ptr< Module > ModulePtr
Convenience typedef for Module objects to be added to the ChaiScript runtime.
Definition dispatchkit.hpp:263
std::unique_ptr< AST_Node > AST_NodePtr
Typedef for pointers to AST_Node objects. Used in building of the AST_Node tree.
Definition proxy_functions.hpp:44
STL namespace.
Definition GameApi.h:42
Struct that doubles as both a parser ast_node and an AST node.
Definition chaiscript_common.hpp:497
virtual Boxed_Value eval(const chaiscript::detail::Dispatch_State &t_e) const =0
static std::string version()
Definition chaiscript_defines.hpp:122
Represents the current state of the ChaiScript system. State and be saved and restored.
Definition chaiscript_engine.hpp:464
std::set< std::string > active_loaded_modules
Definition chaiscript_engine.hpp:467
std::set< std::string > used_files
Definition chaiscript_engine.hpp:465
chaiscript::detail::Dispatch_Engine::State engine_state
Definition chaiscript_engine.hpp:466
static void validate_object_name(const std::string &name)
Definition chaiscript_common.hpp:48
Definition dispatchkit.hpp:446
Definition chaiscript_posix.hpp:15
Special type for returned values.
Definition chaiscript_common.hpp:651
Boxed_Value retval
Definition chaiscript_common.hpp:652
Errors generated during parsing or evaluation.
Definition chaiscript_common.hpp:168
Errors generated when loading a file.
Definition chaiscript_common.hpp:481
Thrown if an error occurs while attempting to load a binary module.
Definition chaiscript_common.hpp:138