$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: oryol_at_[hidden]
Date: 2007-09-14 23:17:31
Author: jeremypack
Date: 2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
New Revision: 39294
URL: http://svn.boost.org/trac/boost/changeset/39294
Log:
Add two reflection tests: reflect from shared library, and multi-param tests.
Text files modified: 
   sandbox/boost/reflection/instance.hpp                    |     2 +                                       
   sandbox/libs/reflection/examples/Jamfile.v2              |     8 ++--                                    
   sandbox/libs/reflection/examples/extension/car_lib.cpp   |    29 +++++++++++------                       
   sandbox/libs/reflection/examples/extension/extension.cpp |    65 +++++++++++++-------------------------- 
   sandbox/libs/reflection/test/Jamfile.v2                  |     2 +                                       
   sandbox/libs/reflection/test/single_param_test.cpp       |     6 +-                                      
   6 files changed, 52 insertions(+), 60 deletions(-)
Modified: sandbox/boost/reflection/instance.hpp
==============================================================================
--- sandbox/boost/reflection/instance.hpp	(original)
+++ sandbox/boost/reflection/instance.hpp	2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
@@ -9,6 +9,8 @@
 
 #ifndef BOOST_EXTENSION_INSTANCE_HPP
 #define BOOST_EXTENSION_INSTANCE_HPP
+
+#include <boost/extension/common.hpp>
 namespace boost {namespace reflections {
 class instance {
 public:
Modified: sandbox/libs/reflection/examples/Jamfile.v2
==============================================================================
--- sandbox/libs/reflection/examples/Jamfile.v2	(original)
+++ sandbox/libs/reflection/examples/Jamfile.v2	2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
@@ -21,19 +21,19 @@
       <include>$(BOOST_ROOT)
       <include>../../../../src/sandbox/
       <toolset>gcc:<find-static-library>dl
-      <toolset>gcc:<find-static-library>readline
-      <toolset>gcc:<find-static-library>boost_regex-gcc-mt
       <toolset>gcc:<linkflags>"-Wl,-rpath,'$ORIGIN'"
       <toolset>darwin:<define>DYLD_LIBRARY_PATH=./
     :
     ;
 
 # basic example
-exe reflection : main.cpp ;
+# exe reflection : main.cpp ;
 
 # interpreter prototype
-exe interpreter : interpreter/interpreter.cpp ;
+# exe interpreter : interpreter/interpreter.cpp ;
 
 # extension integration example
 exe extension-reflection : extension/extension.cpp ;
 lib car_lib : extension/car_lib.cpp : <link>shared ;
+
+install ../bin/ : car_lib extension-reflection ;
Modified: sandbox/libs/reflection/examples/extension/car_lib.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/car_lib.cpp	(original)
+++ sandbox/libs/reflection/examples/extension/car_lib.cpp	2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
@@ -10,29 +10,38 @@
  */
 
 #include "../car.hpp"
-#include <boost/extension/factory_map.hpp>
-
+#include <boost/extension/impl/decl.hpp>
+#include <boost/reflection/reflection.hpp>
+#include <boost/reflection/reflector.hpp>
+using namespace boost::reflections;
 class suv : public car
 {
 public:
-        suv(const std::string name) : car(name) {}
-        virtual std::string get_type(void) { return "It's a SUV."; }
+        suv(const char * name) : car(name) {}
+        virtual const char * get_type(void) { return "It's an SUV."; }
         virtual ~suv(void) {}
 };
 
 class compact : public car
 {
 public:
-        compact(const std::string name) : car(name) {}
-        virtual std::string get_type(void) { return "It's a compact."; }
+        compact(const char * name) : car(name) {}
+        virtual const char * get_type(void) { return "It's a compact."; }
         virtual ~compact(void) {}
 };
 
 
 extern "C" 
 void BOOST_EXTENSION_EXPORT_DECL 
-extension_export_car(boost::extensions::factory_map & fm)
-{
-  fm.add<suv, car, std::string, std::string>("SUV");
-  fm.add<compact, car, std::string, std::string>("Compact");
+extension_export_car(std::map<std::string, reflection> reflection_map) {
+  reflection & first = reflection_map["suv"];
+  reflection & second = reflection_map["compact"];
+  reflector<suv> suv_reflector(&first);
+  reflector<compact> compact_reflector(&second);
+  
+  suv_reflector.reflect_constructor<const char *>();
+  compact_reflector.reflect_constructor<const char *>();
+  
+  suv_reflector.reflect<const char *>(&suv::get_type, "get_type");
+  compact_reflector.reflect<const char *>(&compact::get_type, "get_type");
 }
Modified: sandbox/libs/reflection/examples/extension/extension.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/extension.cpp	(original)
+++ sandbox/libs/reflection/examples/extension/extension.cpp	2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
@@ -15,52 +15,31 @@
 #include <boost/extension/factory_map.hpp>
 #include <boost/extension/shared_library.hpp>
 #include <boost/extension/convenience.hpp>
-
-#include <iostream>
-
-#define BOOST_EXTENSION_USE_PP 1
-
-#include "../car.hpp"
 #include <boost/reflection/reflection.hpp>
-
+#include <iostream>
 
 int main(void)
 {
+  
+  std::map<std::string, boost::reflections::reflection> reflection_map;
+  boost::extensions::shared_library lib("libCarLib.extension");
+  lib.open();
+  lib.get<void, std::map<std::string, 
+    boost::reflections::reflection> &>
+    ("extension_export_car")(reflection_map);
   // Let's create the reflection and add the methods
-  boost::extension::reflection<car, std::string> car_reflection("A Car!");
-  car_reflection.add<int, bool>(&car::start, 3);
-  car_reflection.add<std::string, bool, float, 
-    std::string>(&car::turn, "turn", "turn_angle");
-
-  // extension tests
-  using namespace boost::extensions;
-  factory_map fm;
-
-  // load the car library
-  load_single_library(fm, "libcar_lib.extension", 
-                      "extension_export_car");
-  std::list<factory<car, std::string, std::string> > & factory_list = 
-          fm.get<car, std::string, std::string>();  
-
-  // check if the factories loaded fine
-  if(factory_list.size() < 2) {
-    std::cout << "Error - the classes were not found (" 
-              << factory_list.size() << ").\n";
-    return -1;
-  }
-
-  // create some instances and call the method "3" (start)
-  for (std::list<factory<car, std::string, std::string> >
-         ::iterator current_car = factory_list.begin(); 
-       current_car != factory_list.end(); 
-       ++current_car)
-  {
-    if(current_car->get_info() == "Compact") {
-       car *beetle(current_car->create("VW New Beetle"));
-       car_reflection.call<int, bool>(beetle, 3);
-       delete beetle;
-    }
-  }
-
-  return 0;
+  boost::reflections::reflection & first_reflection =
+    reflection_map["suv"];
+  boost::reflections::reflection & second_reflection =
+    reflection_map["compact"];
+  boost::reflections::instance first_instance =
+    first_reflection.get_constructor<const char *>()("First Instance");
+  boost::reflections::instance second_instance =
+    second_reflection.get_constructor<const char *>()("Second Instance");
+  std::cout <<
+    first_reflection.get_function<const char *>("get_type")(first_instance)
+    << std::endl;
+  std::cout <<
+    second_reflection.get_function<const char *>("get_type")(second_instance)
+    << std::endl;
 }
Modified: sandbox/libs/reflection/test/Jamfile.v2
==============================================================================
--- sandbox/libs/reflection/test/Jamfile.v2	(original)
+++ sandbox/libs/reflection/test/Jamfile.v2	2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
@@ -27,5 +27,7 @@
 test-suite reflection_tests_all
 : [ run basic_test.cpp ] 
   [ run single_param_test.cpp ]
+  [ run shared_library_test.cpp ]
+  [ run multi_param_test.cpp ]
 : 
 ;
Modified: sandbox/libs/reflection/test/single_param_test.cpp
==============================================================================
--- sandbox/libs/reflection/test/single_param_test.cpp	(original)
+++ sandbox/libs/reflection/test/single_param_test.cpp	2007-09-14 23:17:30 EDT (Fri, 14 Sep 2007)
@@ -35,7 +35,7 @@
 };
 using namespace boost::reflections;
 BOOST_AUTO_TEST_CASE(argless)
-{/*
+{
   reflection car_reflection;
   reflector<car> car_reflector(&car_reflection);
   car_reflector.reflect_constructor<float>();
@@ -54,7 +54,7 @@
   BOOST_CHECK_EQUAL
     (car_reflection.get_function<float>("get_cost")
      .call(car_instance), 10.0f);
-  function<int> f2 =
+  function<float> f2 =
     car_reflection.get_function<float>("get_cost");
-  BOOST_CHECK_EQUAL(f2(car_instance), 10.0f);*/
+  BOOST_CHECK_EQUAL(f2(car_instance), 10.0f);
 }