Commits

bi...@4525493e-7705-40b1-a816-d608a930855b  committed c69bb84

support for (a few) builtins in storegate

  • Participants
  • Parent commits cb3812c

Comments (0)

Files changed (2)

+2011-05-19  Sebastien Binet  <sebastien.binet@cern.ch>
+
+	* tagging StoreGateBindings-00-05-03
+	* support for (a few) builtins in storegate
+	* M src/StoreGatePyExt.cxx
+
 2010-03-30  Sebastien Binet  <binet@farnsworth>
 
 	* tagging StoreGateBindings-00-05-02

File src/StoreGatePyExt.cxx

 #include "SGTools/unordered_map.h" // move to STL once available
 #include "SGTools/DataBucketBase.h"
 #include "SGTools/BaseInfo.h"
+#include "SGTools/ClassID_traits.h"
+#include "SGTools/BuiltinsClids.h"
 
 // Reflex includes
 #include "Reflex/Type.h"
 #include <vector>
 #include <algorithm> // for stable_partition
 
+namespace {
+  static CLID int_clid = ClassID_traits<int>::ID();
+  static CLID uint_clid = ClassID_traits<unsigned int>::ID();
+  static CLID long_clid = ClassID_traits<long>::ID();
+  static CLID ulong_clid= ClassID_traits<unsigned long>::ID();
+  static CLID float_clid= ClassID_traits<float>::ID();
+  static CLID double_clid=ClassID_traits<double>::ID();
+}
+
 PyObject* 
 AthenaInternal::retrieveObjectFromStore( PyObject* self, 
-					 PyObject* tp, PyObject* pykey )
+                                         PyObject* tp, PyObject* pykey )
 {
   void* res = 0;
   PyObject* objProxy = NULL;
   if ( PyCLID == realID ) {
     objProxy = (PyObject*)dbb->object();
 
+  } else if (realID == int_clid) {
+    res = dbb->cast( uint_clid );
+    int *v = reinterpret_cast<int*>(res);
+    objProxy = PyInt_FromLong(*v);
+    return objProxy;
+
+  } else if (realID == uint_clid) {
+    res = dbb->cast( uint_clid );
+    unsigned int *v = reinterpret_cast<unsigned int*>(res);
+    objProxy = PyInt_FromLong(*v);
+    return objProxy;
+
+  } else if (realID == long_clid) {
+    res = dbb->cast( long_clid );
+    long *v =reinterpret_cast<long*>(res);
+    objProxy = PyLong_FromLong(*v);
+    return objProxy;
+
+  } else if (realID == ulong_clid) {
+    res = dbb->cast( ulong_clid );
+    unsigned long *v =reinterpret_cast<unsigned long*>(res);
+    objProxy = PyLong_FromUnsignedLong(*v);
+    return objProxy;
+    
+  } else if (realID == float_clid) {
+    res = dbb->cast( float_clid );
+    float *v =reinterpret_cast<float*>(res);
+    objProxy = PyFloat_FromDouble(*v);
+    return objProxy;
+  
+  } else if (realID == double_clid) {
+    res = dbb->cast( double_clid );
+    double *v =reinterpret_cast<double*>(res);
+    objProxy = PyFloat_FromDouble(*v);
+    return objProxy;
+  
   } else if ( id == realID ) {
     res = dbb->object();