parent
563999f3b8
commit
2fbc377119
@ -319,7 +319,7 @@ namespace chaiscript
|
|||||||
/// Add back insertion sequence concept to the given ContainerType
|
/// Add back insertion sequence concept to the given ContainerType
|
||||||
/// http://www.sgi.com/tech/stl/BackInsertionSequence.html
|
/// http://www.sgi.com/tech/stl/BackInsertionSequence.html
|
||||||
template<typename ContainerType>
|
template<typename ContainerType>
|
||||||
ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
|
ModulePtr back_insertion_sequence_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
|
||||||
{
|
{
|
||||||
typedef typename ContainerType::reference (ContainerType::*backptr)();
|
typedef typename ContainerType::reference (ContainerType::*backptr)();
|
||||||
|
|
||||||
@ -328,8 +328,16 @@ namespace chaiscript
|
|||||||
|
|
||||||
typedef void (ContainerType::*push_back)(const typename ContainerType::value_type &);
|
typedef void (ContainerType::*push_back)(const typename ContainerType::value_type &);
|
||||||
m->add(fun(static_cast<push_back>(&ContainerType::push_back)),
|
m->add(fun(static_cast<push_back>(&ContainerType::push_back)),
|
||||||
[]()->std::string{
|
[&]()->std::string{
|
||||||
if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
|
if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
|
||||||
|
m->eval(
|
||||||
|
"# Pushes the second value onto the container while making a clone of the value\n"
|
||||||
|
"def push_back(" + type + " container, x)\n"
|
||||||
|
"{ \n"
|
||||||
|
" container.push_back_ref(clone(x)) \n"
|
||||||
|
"} \n"
|
||||||
|
);
|
||||||
|
|
||||||
return "push_back_ref";
|
return "push_back_ref";
|
||||||
} else {
|
} else {
|
||||||
return "push_back";
|
return "push_back";
|
||||||
@ -345,7 +353,7 @@ namespace chaiscript
|
|||||||
/// Front insertion sequence
|
/// Front insertion sequence
|
||||||
/// http://www.sgi.com/tech/stl/FrontInsertionSequence.html
|
/// http://www.sgi.com/tech/stl/FrontInsertionSequence.html
|
||||||
template<typename ContainerType>
|
template<typename ContainerType>
|
||||||
ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = std::make_shared<Module>())
|
ModulePtr front_insertion_sequence_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
|
||||||
{
|
{
|
||||||
typedef typename ContainerType::reference (ContainerType::*front_ptr)();
|
typedef typename ContainerType::reference (ContainerType::*front_ptr)();
|
||||||
typedef typename ContainerType::const_reference (ContainerType::*const_front_ptr)() const;
|
typedef typename ContainerType::const_reference (ContainerType::*const_front_ptr)() const;
|
||||||
@ -356,8 +364,15 @@ namespace chaiscript
|
|||||||
m->add(fun(static_cast<const_front_ptr>(&ContainerType::front)), "front");
|
m->add(fun(static_cast<const_front_ptr>(&ContainerType::front)), "front");
|
||||||
|
|
||||||
m->add(fun(static_cast<push_ptr>(&ContainerType::push_front)),
|
m->add(fun(static_cast<push_ptr>(&ContainerType::push_front)),
|
||||||
[]()->std::string{
|
[&]()->std::string{
|
||||||
if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
|
if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
|
||||||
|
m->eval(
|
||||||
|
"# Pushes the second value onto the front of container while making a clone of the value\n"
|
||||||
|
"def push_front(" + type + " container, x)\n"
|
||||||
|
"{ \n"
|
||||||
|
" container.push_front_ref(clone(x)) \n"
|
||||||
|
"} \n"
|
||||||
|
);
|
||||||
return "push_front_ref";
|
return "push_front_ref";
|
||||||
} else {
|
} else {
|
||||||
return "push_front";
|
return "push_front";
|
||||||
|
@ -127,18 +127,6 @@ def even(x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Pushes the second value onto the container first value while making a clone of the value
|
|
||||||
def push_back(container, x) : call_exists(push_back_ref, container, x)
|
|
||||||
{
|
|
||||||
container.push_back_ref(clone(x))
|
|
||||||
}
|
|
||||||
|
|
||||||
# Pushes the second value onto the front of the container first value while making a clone of the value
|
|
||||||
def push_front(container, x) : call_exists(push_front_ref, container, x)
|
|
||||||
{
|
|
||||||
container.push_front_ref(clone(x))
|
|
||||||
}
|
|
||||||
|
|
||||||
# Inserts the third value at the position of the second value into the container of the first
|
# Inserts the third value at the position of the second value into the container of the first
|
||||||
# while making a clone.
|
# while making a clone.
|
||||||
def insert_at(container, pos, x)
|
def insert_at(container, pos, x)
|
||||||
|
@ -26,6 +26,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extr
|
|||||||
|
|
||||||
auto module = chaiscript::bootstrap::standard_library::list_type<std::list<chaiscript::Boxed_Value> >("List");
|
auto module = chaiscript::bootstrap::standard_library::list_type<std::list<chaiscript::Boxed_Value> >("List");
|
||||||
module->add(chaiscript::bootstrap::standard_library::vector_type<std::vector<uint16_t> >("u16vector"));
|
module->add(chaiscript::bootstrap::standard_library::vector_type<std::vector<uint16_t> >("u16vector"));
|
||||||
|
module->add(chaiscript::vector_conversion<std::vector<uint16_t>>());
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user