Documentation updates and namespace reorg for docs.
This commit is contained in:
@@ -27,8 +27,10 @@
|
|||||||
|
|
||||||
|
|
||||||
/// \namespace chaiscript
|
/// \namespace chaiscript
|
||||||
/// The chaiscript namespace contains every API call that the average user will be concerned with.
|
/// \brief Every API call that the average user will be concerned with.
|
||||||
|
|
||||||
|
/// \namespace chaiscript::detail
|
||||||
|
/// \brief Classes and functions reserved for internal use. Items in this namespace are not supported.
|
||||||
|
|
||||||
#include "dispatchkit/dispatchkit.hpp"
|
#include "dispatchkit/dispatchkit.hpp"
|
||||||
#include "dispatchkit/bootstrap.hpp"
|
#include "dispatchkit/bootstrap.hpp"
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
/// \brief Classes and functions useful for bootstrapping of ChaiScript and adding of new types
|
||||||
namespace bootstrap
|
namespace bootstrap
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
|
@@ -17,10 +17,7 @@
|
|||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/// \brief Represents any numeric type, generically. Used internally for generic operations between POD values
|
||||||
* Object which attempts to convert a Boxed_Value into a generic
|
|
||||||
* POD type and provide generic POD type operations
|
|
||||||
*/
|
|
||||||
class Boxed_POD_Value
|
class Boxed_POD_Value
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -23,12 +23,8 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
/**
|
/// \brief A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects
|
||||||
* Boxed_Value is the main tool of the dispatchkit. It allows
|
/// \sa chaiscript::boxed_cast
|
||||||
* for boxed / untyped containment of any C++ object. It uses
|
|
||||||
* boost::any internally but also provides user access the underlying
|
|
||||||
* stored type information
|
|
||||||
*/
|
|
||||||
class Boxed_Value
|
class Boxed_Value
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -26,8 +26,14 @@
|
|||||||
#include "dynamic_object.hpp"
|
#include "dynamic_object.hpp"
|
||||||
#include "../chaiscript_threading.hpp"
|
#include "../chaiscript_threading.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
/// \namespace chaiscript::dispatch
|
||||||
|
/// \brief Classes and functions specific to the runtime dispatch side of ChaiScript. Some items may be of use to the end user.
|
||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
/// \brief Holds a collection of ChaiScript settings which can be applied to the ChaiScript runtime.
|
||||||
|
/// Used to implement loadable module support.
|
||||||
class Module
|
class Module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -109,6 +115,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Convenience typedef for Module objects to be added to the ChaiScript runtime
|
||||||
typedef boost::shared_ptr<Module> ModulePtr;
|
typedef boost::shared_ptr<Module> ModulePtr;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
|
@@ -31,9 +31,7 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// \brief Compile time deduced information about a type
|
||||||
* compile time deduced information about a type
|
|
||||||
*/
|
|
||||||
class Type_Info
|
class Type_Info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -14,9 +14,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
typedef ModulePtr (*Create_Module_Func)();
|
typedef ModulePtr (*Create_Module_Func)();
|
||||||
|
|
||||||
/**
|
/// Types of AST nodes available to the parser and eval
|
||||||
* Types of AST nodes available to the parser and eval
|
|
||||||
*/
|
|
||||||
class AST_Node_Type {
|
class AST_Node_Type {
|
||||||
public:
|
public:
|
||||||
enum Type { Error, Int, Float, Id, Char, Str, Eol, Fun_Call, Inplace_Fun_Call, Arg_List, Variable, Equation, Var_Decl,
|
enum Type { Error, Int, Float, Id, Char, Str, Eol, Fun_Call, Inplace_Fun_Call, Arg_List, Variable, Equation, Var_Decl,
|
||||||
@@ -43,9 +41,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// \brief Convenience type for file positions
|
||||||
* Convenience type for file positions
|
|
||||||
*/
|
|
||||||
struct File_Position {
|
struct File_Position {
|
||||||
int line;
|
int line;
|
||||||
int column;
|
int column;
|
||||||
@@ -58,6 +54,8 @@ namespace chaiscript
|
|||||||
|
|
||||||
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
|
typedef boost::shared_ptr<struct AST_Node> AST_NodePtr;
|
||||||
|
|
||||||
|
|
||||||
|
/// \brief Classes which may be thrown during error cases when ChaiScript is executing.
|
||||||
namespace exception
|
namespace exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +97,8 @@ namespace chaiscript
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The struct that doubles as both a parser ast_node and an AST node
|
/// \brief Struct that doubles as both a parser ast_node and an AST node.
|
||||||
*/
|
|
||||||
struct AST_Node : boost::enable_shared_from_this<AST_Node> {
|
struct AST_Node : boost::enable_shared_from_this<AST_Node> {
|
||||||
public:
|
public:
|
||||||
const std::string text;
|
const std::string text;
|
||||||
@@ -171,9 +168,8 @@ namespace chaiscript
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
namespace eval
|
||||||
|
{
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +210,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
chaiscript::detail::Dispatch_Engine &m_de;
|
chaiscript::detail::Dispatch_Engine &m_de;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -219,6 +219,8 @@ namespace chaiscript
|
|||||||
typedef boost::shared_ptr<Loadable_Module> Loadable_Module_Ptr;
|
typedef boost::shared_ptr<Loadable_Module> Loadable_Module_Ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// \brief The main object that the ChaiScript user will use.
|
||||||
class ChaiScript {
|
class ChaiScript {
|
||||||
|
|
||||||
mutable chaiscript::detail::threading::shared_mutex m_mutex;
|
mutable chaiscript::detail::threading::shared_mutex m_mutex;
|
||||||
@@ -248,7 +250,7 @@ namespace chaiscript
|
|||||||
return Boxed_Value();
|
return Boxed_Value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const detail::Return_Value &rv) {
|
catch (const chaiscript::eval::detail::Return_Value &rv) {
|
||||||
return rv.retval;
|
return rv.retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,12 +13,16 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
/// \brief Classes and functions that are part of the runtime eval system
|
||||||
|
namespace eval
|
||||||
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Helper function that will set up the scope around a function call, including handling the named function parameters
|
* Helper function that will set up the scope around a function call, including handling the named function parameters
|
||||||
*/
|
*/
|
||||||
template <typename Eval_System>
|
static const Boxed_Value eval_function(chaiscript::detail::Dispatch_Engine &t_ss, const AST_NodePtr &t_node, const std::vector<std::string> &t_param_names, const std::vector<Boxed_Value> &t_vals) {
|
||||||
const Boxed_Value eval_function (Eval_System &t_ss, const AST_NodePtr &t_node, const std::vector<std::string> &t_param_names, const std::vector<Boxed_Value> &t_vals) {
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
detail::Scope_Push_Pop spp(t_ss);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < t_param_names.size(); ++i) {
|
for (unsigned int i = 0; i < t_param_names.size(); ++i) {
|
||||||
t_ss.add_object(t_param_names[i], t_vals[i]);
|
t_ss.add_object(t_param_names[i], t_vals[i]);
|
||||||
@@ -30,10 +34,8 @@ namespace chaiscript
|
|||||||
return rv.retval;
|
return rv.retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace eval
|
|
||||||
{
|
|
||||||
struct Binary_Operator_AST_Node : public AST_Node {
|
struct Binary_Operator_AST_Node : public AST_Node {
|
||||||
public:
|
public:
|
||||||
Binary_Operator_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Bitwise_Xor, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
|
Binary_Operator_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Bitwise_Xor, const boost::shared_ptr<std::string> &t_fname=boost::shared_ptr<std::string>(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) :
|
||||||
@@ -485,7 +487,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function
|
return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function
|
||||||
(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>, boost::ref(t_ss), this->children.back(), t_param_names, _1),
|
(boost::bind(chaiscript::eval::detail::eval_function, boost::ref(t_ss), this->children.back(), t_param_names, _1),
|
||||||
static_cast<int>(numparams), this->children.back())));
|
static_cast<int>(numparams), this->children.back())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,7 +501,7 @@ namespace chaiscript
|
|||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
|
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
|
||||||
const size_t num_children = this->children.size();
|
const size_t num_children = this->children.size();
|
||||||
|
|
||||||
detail::Scope_Push_Pop spp(t_ss);
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
|
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (size_t i = 0; i < num_children; ++i) {
|
||||||
try {
|
try {
|
||||||
@@ -510,7 +512,7 @@ namespace chaiscript
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const chaiscript::detail::Return_Value &) {
|
catch (const chaiscript::eval::detail::Return_Value &) {
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,7 +554,7 @@ namespace chaiscript
|
|||||||
boost::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
|
boost::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
|
||||||
if (guardnode) {
|
if (guardnode) {
|
||||||
guard = boost::shared_ptr<dispatch::Dynamic_Proxy_Function>
|
guard = boost::shared_ptr<dispatch::Dynamic_Proxy_Function>
|
||||||
(new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
|
(new dispatch::Dynamic_Proxy_Function(boost::bind(chaiscript::eval::detail::eval_function,
|
||||||
boost::ref(t_ss), guardnode,
|
boost::ref(t_ss), guardnode,
|
||||||
t_param_names, _1), static_cast<int>(numparams), guardnode));
|
t_param_names, _1), static_cast<int>(numparams), guardnode));
|
||||||
}
|
}
|
||||||
@@ -561,7 +563,7 @@ namespace chaiscript
|
|||||||
const std::string & l_function_name = this->children[0]->text;
|
const std::string & l_function_name = this->children[0]->text;
|
||||||
const std::string & l_annotation = this->annotation?this->annotation->text:"";
|
const std::string & l_annotation = this->annotation?this->annotation->text:"";
|
||||||
t_ss.add(Proxy_Function
|
t_ss.add(Proxy_Function
|
||||||
(new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
|
(new dispatch::Dynamic_Proxy_Function(boost::bind(chaiscript::eval::detail::eval_function,
|
||||||
boost::ref(t_ss), this->children.back(),
|
boost::ref(t_ss), this->children.back(),
|
||||||
t_param_names, _1), static_cast<int>(numparams), this->children.back(),
|
t_param_names, _1), static_cast<int>(numparams), this->children.back(),
|
||||||
l_annotation, guard)), l_function_name);
|
l_annotation, guard)), l_function_name);
|
||||||
@@ -582,7 +584,7 @@ namespace chaiscript
|
|||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) {
|
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) {
|
||||||
bool cond;
|
bool cond;
|
||||||
|
|
||||||
detail::Scope_Push_Pop spp(t_ss);
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
cond = boxed_cast<bool>(this->children[0]->eval(t_ss));
|
||||||
@@ -663,7 +665,7 @@ namespace chaiscript
|
|||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
|
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
|
||||||
bool cond;
|
bool cond;
|
||||||
|
|
||||||
detail::Scope_Push_Pop spp(t_ss);
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this->children.size() == 4) {
|
if (this->children.size() == 4) {
|
||||||
@@ -845,7 +847,7 @@ namespace chaiscript
|
|||||||
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
|
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
|
||||||
Boxed_Value retval;
|
Boxed_Value retval;
|
||||||
|
|
||||||
detail::Scope_Push_Pop spp(t_ss);
|
chaiscript::eval::detail::Scope_Push_Pop spp(t_ss);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
retval = this->children[0]->eval(t_ss);
|
retval = this->children[0]->eval(t_ss);
|
||||||
@@ -1013,7 +1015,7 @@ namespace chaiscript
|
|||||||
boost::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
|
boost::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
|
||||||
if (guardnode) {
|
if (guardnode) {
|
||||||
guard = boost::shared_ptr<dispatch::Dynamic_Proxy_Function>
|
guard = boost::shared_ptr<dispatch::Dynamic_Proxy_Function>
|
||||||
(new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
|
(new dispatch::Dynamic_Proxy_Function(boost::bind(chaiscript::eval::detail::eval_function,
|
||||||
boost::ref(t_ss), guardnode,
|
boost::ref(t_ss), guardnode,
|
||||||
t_param_names, _1), static_cast<int>(numparams), guardnode));
|
t_param_names, _1), static_cast<int>(numparams), guardnode));
|
||||||
}
|
}
|
||||||
@@ -1025,7 +1027,7 @@ namespace chaiscript
|
|||||||
if (function_name == class_name) {
|
if (function_name == class_name) {
|
||||||
t_ss.add(Proxy_Function
|
t_ss.add(Proxy_Function
|
||||||
(new dispatch::detail::Dynamic_Object_Constructor(class_name, Proxy_Function
|
(new dispatch::detail::Dynamic_Object_Constructor(class_name, Proxy_Function
|
||||||
(new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
|
(new dispatch::Dynamic_Proxy_Function(boost::bind(chaiscript::eval::detail::eval_function,
|
||||||
boost::ref(t_ss), this->children.back(),
|
boost::ref(t_ss), this->children.back(),
|
||||||
t_param_names, _1), static_cast<int>(numparams), this->children.back(),
|
t_param_names, _1), static_cast<int>(numparams), this->children.back(),
|
||||||
l_annotation, guard)))), function_name);
|
l_annotation, guard)))), function_name);
|
||||||
@@ -1040,7 +1042,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
t_ss.add(Proxy_Function
|
t_ss.add(Proxy_Function
|
||||||
(new dispatch::detail::Dynamic_Object_Function(class_name, Proxy_Function
|
(new dispatch::detail::Dynamic_Object_Function(class_name, Proxy_Function
|
||||||
(new dispatch::Dynamic_Proxy_Function(boost::bind(&eval_function<chaiscript::detail::Dispatch_Engine>,
|
(new dispatch::Dynamic_Proxy_Function(boost::bind(chaiscript::eval::detail::eval_function,
|
||||||
boost::ref(t_ss), this->children.back(),
|
boost::ref(t_ss), this->children.back(),
|
||||||
t_param_names, _1), static_cast<int>(numparams), this->children.back(),
|
t_param_names, _1), static_cast<int>(numparams), this->children.back(),
|
||||||
l_annotation, guard)), ti)), function_name);
|
l_annotation, guard)), ti)), function_name);
|
||||||
|
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
/// \brief Classes and functions used during the parsing process.
|
||||||
namespace parser
|
namespace parser
|
||||||
{
|
{
|
||||||
|
/// \brief Classes and functions internal to the parsing process. Not supported for the end user.
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
enum Alphabet
|
enum Alphabet
|
||||||
|
@@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
/// \brief Classes and functions which provide general utility to the end user.
|
||||||
namespace utility
|
namespace utility
|
||||||
{
|
{
|
||||||
inline std::string class_name_translator(const std::string &t_name)
|
inline std::string class_name_translator(const std::string &t_name)
|
||||||
|
Reference in New Issue
Block a user