当前位置: 首页>>代码示例>>C++>>正文


C++ ModulePtr::add方法代码示例

本文整理汇总了C++中ModulePtr::add方法的典型用法代码示例。如果您正苦于以下问题:C++ ModulePtr::add方法的具体用法?C++ ModulePtr::add怎么用?C++ ModulePtr::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModulePtr的用法示例。


在下文中一共展示了ModulePtr::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: container_type

 ModulePtr container_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
 {
   m->add(fun<size_t (const ContainerType *)>([](const ContainerType *a) { return a->size(); } ), "size");
   m->add(fun<bool (const ContainerType *)>([](const ContainerType *a) { return a->empty(); } ), "empty");
   m->add(fun<void (ContainerType *)>([](ContainerType *a) { a->clear(); } ), "clear");
   return m;
 }
开发者ID:Arpit007,项目名称:ChaiScript,代码行数:7,代码来源:bootstrap_stl.hpp

示例2: container_type

 ModulePtr container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
 {
   m->add(fun( std::function<size_t (const ContainerType *)>( [](const ContainerType *a) { return a->size(); } ) ), "size");
   m->add(fun( std::function<bool (const ContainerType *)>( [](const ContainerType *a) { return a->empty(); } ) ), "empty");
   m->add(fun( std::function<void (ContainerType *)>( [](ContainerType *a) { a->clear(); } ) ), "clear");
   return m;
 }
开发者ID:AdrianArroyoCalle,项目名称:test-embed-language,代码行数:7,代码来源:bootstrap_stl.hpp

示例3: back_insertion_sequence_type

        ModulePtr back_insertion_sequence_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
        {
          typedef typename ContainerType::reference (ContainerType::*backptr)();

          m->add(fun(static_cast<backptr>(&ContainerType::back)), "back");


          typedef void (ContainerType::*push_back)(const typename ContainerType::value_type &);
          m->add(fun(static_cast<push_back>(&ContainerType::push_back)),
              [&]()->std::string{
              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"
                    "  if (x.is_var_return_value()) {\n"
                    "    x.reset_var_return_value() \n"
                    "    container.push_back_ref(x) \n"
                    "  } else { \n"
                    "    container.push_back_ref(clone(x)); \n"
                    "  }\n"
                    "} \n"
                    );

                  return "push_back_ref";
                } else {
                  return "push_back";
                }
              }());

          m->add(fun(&ContainerType::pop_back), "pop_back");
          return m;
        }
开发者ID:Coldreader88,项目名称:ChaiScript,代码行数:33,代码来源:bootstrap_stl.hpp

示例4: front_insertion_sequence_type

        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::const_reference (ContainerType::*const_front_ptr)() const;
          typedef void (ContainerType::*push_ptr)(typename ContainerType::const_reference);
          typedef void (ContainerType::*pop_ptr)();

          m->add(fun(static_cast<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)),
              [&]()->std::string{
                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"
                      "  if (x.is_var_return_value()) {\n"
                      "    x.reset_var_return_value() \n"
                      "    container.push_front_ref(x) \n"
                      "  } else { \n"
                      "    container.push_front_ref(clone(x)); \n"
                      "  }\n"
                      "} \n"
                      );
                  return "push_front_ref";
                } else {
                  return "push_front";
                }
              }());

          m->add(fun(static_cast<pop_ptr>(&ContainerType::pop_front)), "pop_front");
          return m;
        }
开发者ID:Coldreader88,项目名称:ChaiScript,代码行数:34,代码来源:bootstrap_stl.hpp

示例5: container_type

 ModulePtr container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
 {
   boost::function<int (const ContainerType *)> f = detail::return_int(&ContainerType::size);
   m->add(fun(f), "size");
   m->add(fun<bool (ContainerType::*)() const>(&ContainerType::empty), "empty");
   m->add(fun<void (ContainerType::*)()>(&ContainerType::clear), "clear");
   return m;
 }
开发者ID:BraginaT,项目名称:Open-Transactions,代码行数:8,代码来源:bootstrap_stl.hpp

示例6: sequence_type

        ModulePtr sequence_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
        {
          std::string insert_name;
          if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value))
          {
            insert_name = "insert_ref_at";
          } else {
            insert_name = "insert_at";
          }

          m->add(fun(&detail::insert_at<ContainerType>), insert_name);
          m->add(fun(&detail::erase_at<ContainerType>), "erase_at");

          return m;
        }
开发者ID:BraginaT,项目名称:Open-Transactions,代码行数:15,代码来源:bootstrap_stl.hpp

示例7: sequence_type

        ModulePtr sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
        {
          m->add(fun(&detail::insert_at<ContainerType>), 
              []()->std::string{
                if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
                  return "insert_ref_at";
                } else {
                  return "insert_at";
                }
              }());

          m->add(fun(&detail::erase_at<ContainerType>), "erase_at");

          return m;
        }
开发者ID:Arpit007,项目名称:ChaiScript,代码行数:15,代码来源:bootstrap_stl.hpp

示例8: pair_type

        ModulePtr pair_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
        {
          m->add(user_type<PairType>(), type);


          typename PairType::first_type PairType::* f = &PairType::first;
          typename PairType::second_type PairType::* s = &PairType::second;

          m->add(fun(f), "first");
          m->add(fun(s), "second");

          basic_constructors<PairType>(type, m);
          m->add(constructor<PairType (const typename PairType::first_type &, const typename PairType::second_type &)>(), type);

          return m;
        }
开发者ID:Arpit007,项目名称:ChaiScript,代码行数:16,代码来源:bootstrap_stl.hpp

示例9: random_access_container_type

        ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
        {
          typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t);
          typedef typename ContainerType::const_reference(ContainerType::*constindexoper)(size_t) const;

          //In the interest of runtime safety for the m, we prefer the at() method for [] access,
          //to throw an exception in an out of bounds condition.
          m->add(
              fun(boost::function<typename ContainerType::reference (ContainerType *, int)>
                (boost::mem_fn(static_cast<indexoper>(&ContainerType::at)))), "[]");
          m->add(
              fun(boost::function<typename ContainerType::const_reference (const ContainerType *, int)>
                (boost::mem_fn(static_cast<constindexoper>(&ContainerType::at)))), "[]");

          return m;
        }
开发者ID:BraginaT,项目名称:Open-Transactions,代码行数:16,代码来源:bootstrap_stl.hpp

示例10: map_type

        ModulePtr map_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
        {
          m->add(user_type<MapType>(), type);

          typedef typename MapType::mapped_type &(MapType::*elemaccess)(const typename MapType::key_type &);

          m->add(fun(static_cast<elemaccess>(&MapType::operator[])), "[]");

          container_type<MapType>(type, m);
          assignable_type<MapType>(type, m);
          unique_associative_container_type<MapType>(type, m);
          pair_associative_container_type<MapType>(type, m);
          input_range_type<MapType>(type, m);

          return m;
        }
开发者ID:BraginaT,项目名称:Open-Transactions,代码行数:16,代码来源:bootstrap_stl.hpp

示例11: random_access_container_type

        ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
        {
          //In the interest of runtime safety for the m, we prefer the at() method for [] access,
          //to throw an exception in an out of bounds condition.
          m->add(
              fun(
                [](ContainerType &c, int index) -> typename ContainerType::reference {
                  return c.at(index);
                }), "[]");

          m->add(
              fun(
                [](const ContainerType &c, int index) -> typename ContainerType::const_reference {
                  return c.at(index);
                }), "[]");

          return m;
        }
开发者ID:Coldreader88,项目名称:ChaiScript,代码行数:18,代码来源:bootstrap_stl.hpp

示例12: random_access_container_type

        ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
        {
          // cppcheck-suppress syntaxError
          typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t);

          //In the interest of runtime safety for the m, we prefer the at() method for [] access,
          //to throw an exception in an out of bounds condition.
          m->add(
              fun(std::function<typename ContainerType::reference (ContainerType *, int)>
                (std::mem_fn(static_cast<indexoper>(&ContainerType::at)))), "[]");
          m->add(
              fun<typename ContainerType::const_reference (const ContainerType *, int)>(
                [](const ContainerType *c, int index) -> typename ContainerType::const_reference {
                  return c->at(index);
                }), "[]");

          return m;
        }
开发者ID:Arpit007,项目名称:ChaiScript,代码行数:18,代码来源:bootstrap_stl.hpp

示例13: back_insertion_sequence_type

        ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
        {
          typedef typename ContainerType::reference (ContainerType::*backptr)();

          m->add(fun(static_cast<backptr>(&ContainerType::back)), "back");

          std::string push_back_name;
          if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value))
          {
            push_back_name = "push_back_ref";
          } else {
            push_back_name = "push_back";
          }

          typedef void (ContainerType::*pushback)(const typename ContainerType::value_type &);
          m->add(fun(static_cast<pushback>(&ContainerType::push_back)), push_back_name);
          m->add(fun(&ContainerType::pop_back), "pop_back");
          return m;
        }
开发者ID:BraginaT,项目名称:Open-Transactions,代码行数:19,代码来源:bootstrap_stl.hpp

示例14: back_insertion_sequence_type

        ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
        {
          typedef typename ContainerType::reference (ContainerType::*backptr)();

          m->add(fun(static_cast<backptr>(&ContainerType::back)), "back");


          typedef void (ContainerType::*push_back)(const typename ContainerType::value_type &);
          m->add(fun(static_cast<push_back>(&ContainerType::push_back)),
              []()->std::string{
                if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
                  return "push_back_ref";
                } else {
                  return "push_back";
                }
              }());

          m->add(fun(&ContainerType::pop_back), "pop_back");
          return m;
        }
开发者ID:Arpit007,项目名称:ChaiScript,代码行数:20,代码来源:bootstrap_stl.hpp

示例15: front_insertion_sequence_type

        ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = ModulePtr(new Module()))
        {
          typedef typename ContainerType::reference (ContainerType::*frontptr)();
          typedef void (ContainerType::*pushptr)(typename ContainerType::const_reference);
          typedef void (ContainerType::*popptr)();

          m->add(fun(static_cast<frontptr>(&ContainerType::front)), "front");

          std::string push_front_name;
          if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value))
          {
            push_front_name = "push_front_ref";
          } else {
            push_front_name = "push_front";
          }

          m->add(fun(static_cast<pushptr>(&ContainerType::push_front)), push_front_name);
          m->add(fun(static_cast<popptr>(&ContainerType::pop_front)), "pop_front");
          return m;
        }
开发者ID:BraginaT,项目名称:Open-Transactions,代码行数:20,代码来源:bootstrap_stl.hpp


注:本文中的ModulePtr::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。