Urbi SDK Remote for C++  2.7.5
ucallbacks.hh
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006-2011, Gostai S.A.S.
00003  *
00004  * This software is provided "as is" without warranty of any kind,
00005  * either expressed or implied, including but not limited to the
00006  * implied warranties of fitness for a particular purpose.
00007  *
00008  * See the LICENSE file for more information.
00009  */
00010 
00012 
00013 #ifndef URBI_UCALLBACKS_HH
00014 # define URBI_UCALLBACKS_HH
00015 
00016 # include <string>
00017 
00018 # include <libport/compiler.hh>
00019 # include <libport/meta.hh>
00020 # include <libport/preproc.hh>
00021 # include <libport/thread-pool.hh>
00022 # include <urbi/export.hh>
00023 # include <urbi/fwd.hh>
00024 # include <urbi/utable.hh>
00025 # include <urbi/uvalue.hh>
00026 # include <urbi/ucontext.hh>
00027 # include <urbi/uvar.hh>
00028 
00029 # include <boost/function.hpp>
00030 
00031 namespace urbi
00032 {
00033 
00034   namespace impl
00035   {
00036     class URBI_SDK_API UGenericCallbackImpl
00037     {
00038     public:
00039       virtual ~UGenericCallbackImpl() = 0;
00040       virtual void initialize(UGenericCallback* owner, bool owned) = 0;
00041       virtual void initialize(UGenericCallback* owner) = 0;
00042       virtual void registerCallback() = 0;
00043       virtual void clear() = 0;
00044     };
00045 
00046     inline
00047     UGenericCallbackImpl::~UGenericCallbackImpl()
00048     {}
00049   };
00050 
00054 
00055   class URBI_SDK_API UGenericCallback: public UContext
00056   {
00057   public:
00058     UGenericCallback(UObject& owner,
00059                      UVar* target,
00060                      const std::string& type,
00061                      const std::string& name,
00062                      int size,
00063                      impl::UContextImpl* ctx);
00064     UGenericCallback(UObject& owner,
00065                      UVar* target,
00066                      const std::string& type,
00067                      const std::string& name,
00068                      impl::UContextImpl* ctx);
00069     virtual ~UGenericCallback();
00070 
00071     void registerCallback();
00072 
00073     const std::string& getName() const
00074     {
00075       return name;
00076     }
00077 
00079     void setAsync(libport::ThreadPool::rTaskLock lock);
00080 
00081     typedef boost::function2<void, UValue&, const std::exception*> OnDone;
00085     void eval(UList& param, OnDone onDone = 0);
00087     void syncEval(UList& param, OnDone onDone = 0);
00088     virtual UValue __evalcall(UList& param)  = 0;
00089 
00091     ufloat period;
00092 
00094     int nbparam;
00095 
00097     std::string objname;
00098     std::string type;
00100     std::string name;
00102     UVar* target;
00103     impl::UGenericCallbackImpl* impl_;
00104     UObject& owner;
00106     bool isSynchronous() const;
00108     static libport::ThreadPool& threadPool();
00109   protected:
00111     libport::ThreadPool::rTaskLock taskLock;
00113     bool synchronous_;
00114     template<typename T>
00115     static inline impl::UContextImpl* fetchContext(T* ptr, libport::meta::True)
00116     {
00117       return ptr->ctx_;
00118     }
00119 
00120     template<typename T>
00121     static inline impl::UContextImpl* fetchContext(T*, libport::meta::False)
00122     {
00123       return getCurrentContext();
00124     }
00125   };
00126 
00127 
00128 // Support for arbitrary-signature notify callbacks.
00129 
00130 
00131 template<typename T>
00132 inline
00133 typename uvar_ref_traits<typename uvalue_cast_return_type<T>::type>::type
00134 uvar_uvalue_cast(UValue& v)
00135 {
00136   if (v.type == DATA_VOID && v.storage)
00137   {
00138     UVar* var = reinterpret_cast<UVar*>(v.storage);
00139     return uvalue_cast<T>(const_cast<UValue&>(var->val()));
00140   }
00141   else
00142     return uvalue_cast<T>(v);
00143 }
00144 
00145 template<>
00146 inline
00147 UVar&
00148 uvar_uvalue_cast<UVar&>(UValue& v)
00149 {
00150   return uvalue_cast<UVar>(v);
00151 }
00152 
00153 // TODO: compile-time error if argument is UVar without a ref.
00154 
00155   /*------------------------------------------------.
00156   | This section is generated. Not for human eyes.  |
00157   `------------------------------------------------*/
00158 
00159 
00160   // non void return type
00161 
00162   template <class OBJ, class R>
00163   class UCallback0 : public UGenericCallback
00164   {
00165   public:
00166 
00167 # define INSTANTIATE(Const, IsConst)                                    \
00168       UCallback0(UObject& owner,                                      \
00169                    UVar* target,                                        \
00170                    const std::string& type,                             \
00171                    OBJ* obj,                                            \
00172                    R (OBJ::*fun) () Const,                   \
00173                    const std::string& funname)                          \
00174       : UGenericCallback                                                \
00175       (owner, target, type, funname, 0,                               \
00176        fetchContext(obj,                                                \
00177                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00178                     UContext>::res>::res()))                            \
00179       , obj(obj)                                                        \
00180       , fun##Const(fun)                                                 \
00181       , is_const_(IsConst)                                              \
00182     {                                                                   \
00183       nbparam = 0;                                                    \
00184       registerCallback();                                               \
00185     }
00186 
00187     INSTANTIATE(     , false);
00188     INSTANTIATE(const, true);
00189 
00190 # undef INSTANTIATE
00191 
00192     virtual UValue __evalcall(UList& param)
00193     {
00194       impl::UContextImpl::CleanupStack s_(*ctx_);
00195       LIBPORT_USE(param);
00196       UValue res;
00197       res(),
00198         (is_const_)
00199         ? ((*obj).*funconst)()
00200         : ((*obj).*fun)     ();
00201       return res;
00202     }
00203 
00204   private:
00205     OBJ* obj;
00206     R (OBJ::*fun)      ();
00207     R (OBJ::*funconst) () const;
00208     bool is_const_;
00209   };
00210 
00211 
00212   // non void non-member function
00213   template <class R>
00214   class UFCallback0 : public UGenericCallback
00215   {
00216     public:
00217     UFCallback0(UObject& owner, UVar* target,
00218                   const std::string& type,
00219                   R (*fun) (),
00220                   const std::string& funname,
00221                   impl::UContextImpl* ctx)
00222       : UGenericCallback(owner, target, type, funname,0, ctx),
00223       fun(fun)
00224     {
00225       nbparam = 0;
00226       registerCallback();
00227     }
00228 
00229     virtual UValue __evalcall(UList& param)
00230     {
00231       impl::UContextImpl::CleanupStack s_(*ctx_);
00232       LIBPORT_USE(param);
00233       UValue res;
00234       res(), (*fun)();
00235       return res;
00236     }
00237 
00238     private:
00239     R (*fun) ();
00240   };
00241 
00242   // callback creation for non-member non void return type
00243 
00244   template <class R>
00245   UGenericCallback*
00246   createUCallback(UObject& owner, UVar* target,
00247                   const std::string& type,
00248                   R (*fun) (),
00249                   const std::string& funname,
00250                   impl::UContextImpl* ctx)
00251   {
00252     return new UFCallback0<R> (owner, target, type,fun,funname, ctx);
00253   }
00254 
00255   // callback creation for non void return type
00256 
00257   // Use a by-ref dynamic_cast to throw an exception in case of
00258   // failure.
00259 # define INSTANTIATE(Const)                                             \
00260   template <class OBJ, class EOBJ, class R>             \
00261   UGenericCallback*                                                     \
00262   createUCallback(UObject& owner, UVar* target,                         \
00263                   const std::string& type,                              \
00264                   EOBJ* obj,                                            \
00265                   R (OBJ::*fun) () Const,                       \
00266                   const std::string& funname)                           \
00267   {                                                                     \
00268     return new UCallback0<OBJ,R> (owner, target, type,       \
00269        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00270   }
00271 
00272   INSTANTIATE(__);
00273   INSTANTIATE(const);
00274 
00275 # undef INSTANTIATE
00276 
00277 
00278   // non void return type
00279 
00280   template <class OBJ, class R, class P1 >
00281   class UCallback1 : public UGenericCallback
00282   {
00283   public:
00284 
00285 # define INSTANTIATE(Const, IsConst)                                    \
00286       UCallback1(UObject& owner,                                      \
00287                    UVar* target,                                        \
00288                    const std::string& type,                             \
00289                    OBJ* obj,                                            \
00290                    R (OBJ::*fun) ( P1 ) Const,                   \
00291                    const std::string& funname)                          \
00292       : UGenericCallback                                                \
00293       (owner, target, type, funname, 1,                               \
00294        fetchContext(obj,                                                \
00295                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00296                     UContext>::res>::res()))                            \
00297       , obj(obj)                                                        \
00298       , fun##Const(fun)                                                 \
00299       , is_const_(IsConst)                                              \
00300     {                                                                   \
00301       nbparam = 1;                                                    \
00302       registerCallback();                                               \
00303     }
00304 
00305     INSTANTIATE(     , false);
00306     INSTANTIATE(const, true);
00307 
00308 # undef INSTANTIATE
00309 
00310     virtual UValue __evalcall(UList& param)
00311     {
00312       impl::UContextImpl::CleanupStack s_(*ctx_);
00313       LIBPORT_USE(param);
00314       UValue res;
00315       res(),
00316         (is_const_)
00317         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) )
00318         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) );
00319       return res;
00320     }
00321 
00322   private:
00323     OBJ* obj;
00324     R (OBJ::*fun)      ( P1 );
00325     R (OBJ::*funconst) ( P1 ) const;
00326     bool is_const_;
00327   };
00328 
00329 
00330   // non void non-member function
00331   template <class R, class P1 >
00332   class UFCallback1 : public UGenericCallback
00333   {
00334     public:
00335     UFCallback1(UObject& owner, UVar* target,
00336                   const std::string& type,
00337                   R (*fun) ( P1 ),
00338                   const std::string& funname,
00339                   impl::UContextImpl* ctx)
00340       : UGenericCallback(owner, target, type, funname,1, ctx),
00341       fun(fun)
00342     {
00343       nbparam = 1;
00344       registerCallback();
00345     }
00346 
00347     virtual UValue __evalcall(UList& param)
00348     {
00349       impl::UContextImpl::CleanupStack s_(*ctx_);
00350       LIBPORT_USE(param);
00351       UValue res;
00352       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) );
00353       return res;
00354     }
00355 
00356     private:
00357     R (*fun) ( P1 );
00358   };
00359 
00360   // callback creation for non-member non void return type
00361 
00362   template <class R, class P1 >
00363   UGenericCallback*
00364   createUCallback(UObject& owner, UVar* target,
00365                   const std::string& type,
00366                   R (*fun) ( P1 ),
00367                   const std::string& funname,
00368                   impl::UContextImpl* ctx)
00369   {
00370     return new UFCallback1<R, P1 > (owner, target, type,fun,funname, ctx);
00371   }
00372 
00373   // callback creation for non void return type
00374 
00375   // Use a by-ref dynamic_cast to throw an exception in case of
00376   // failure.
00377 # define INSTANTIATE(Const)                                             \
00378   template <class OBJ, class EOBJ, class R, class P1 >          \
00379   UGenericCallback*                                                     \
00380   createUCallback(UObject& owner, UVar* target,                         \
00381                   const std::string& type,                              \
00382                   EOBJ* obj,                                            \
00383                   R (OBJ::*fun) ( P1 ) Const,                   \
00384                   const std::string& funname)                           \
00385   {                                                                     \
00386     return new UCallback1<OBJ,R, P1 > (owner, target, type,       \
00387        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00388   }
00389 
00390   INSTANTIATE(__);
00391   INSTANTIATE(const);
00392 
00393 # undef INSTANTIATE
00394 
00395 
00396   // non void return type
00397 
00398   template <class OBJ, class R, class P1 , class P2 >
00399   class UCallback2 : public UGenericCallback
00400   {
00401   public:
00402 
00403 # define INSTANTIATE(Const, IsConst)                                    \
00404       UCallback2(UObject& owner,                                      \
00405                    UVar* target,                                        \
00406                    const std::string& type,                             \
00407                    OBJ* obj,                                            \
00408                    R (OBJ::*fun) ( P1 , P2 ) Const,                   \
00409                    const std::string& funname)                          \
00410       : UGenericCallback                                                \
00411       (owner, target, type, funname, 2,                               \
00412        fetchContext(obj,                                                \
00413                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00414                     UContext>::res>::res()))                            \
00415       , obj(obj)                                                        \
00416       , fun##Const(fun)                                                 \
00417       , is_const_(IsConst)                                              \
00418     {                                                                   \
00419       nbparam = 2;                                                    \
00420       registerCallback();                                               \
00421     }
00422 
00423     INSTANTIATE(     , false);
00424     INSTANTIATE(const, true);
00425 
00426 # undef INSTANTIATE
00427 
00428     virtual UValue __evalcall(UList& param)
00429     {
00430       impl::UContextImpl::CleanupStack s_(*ctx_);
00431       LIBPORT_USE(param);
00432       UValue res;
00433       res(),
00434         (is_const_)
00435         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) )
00436         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) );
00437       return res;
00438     }
00439 
00440   private:
00441     OBJ* obj;
00442     R (OBJ::*fun)      ( P1 , P2 );
00443     R (OBJ::*funconst) ( P1 , P2 ) const;
00444     bool is_const_;
00445   };
00446 
00447 
00448   // non void non-member function
00449   template <class R, class P1 , class P2 >
00450   class UFCallback2 : public UGenericCallback
00451   {
00452     public:
00453     UFCallback2(UObject& owner, UVar* target,
00454                   const std::string& type,
00455                   R (*fun) ( P1 , P2 ),
00456                   const std::string& funname,
00457                   impl::UContextImpl* ctx)
00458       : UGenericCallback(owner, target, type, funname,2, ctx),
00459       fun(fun)
00460     {
00461       nbparam = 2;
00462       registerCallback();
00463     }
00464 
00465     virtual UValue __evalcall(UList& param)
00466     {
00467       impl::UContextImpl::CleanupStack s_(*ctx_);
00468       LIBPORT_USE(param);
00469       UValue res;
00470       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) );
00471       return res;
00472     }
00473 
00474     private:
00475     R (*fun) ( P1 , P2 );
00476   };
00477 
00478   // callback creation for non-member non void return type
00479 
00480   template <class R, class P1 , class P2 >
00481   UGenericCallback*
00482   createUCallback(UObject& owner, UVar* target,
00483                   const std::string& type,
00484                   R (*fun) ( P1 , P2 ),
00485                   const std::string& funname,
00486                   impl::UContextImpl* ctx)
00487   {
00488     return new UFCallback2<R, P1 , P2 > (owner, target, type,fun,funname, ctx);
00489   }
00490 
00491   // callback creation for non void return type
00492 
00493   // Use a by-ref dynamic_cast to throw an exception in case of
00494   // failure.
00495 # define INSTANTIATE(Const)                                             \
00496   template <class OBJ, class EOBJ, class R, class P1 , class P2 >               \
00497   UGenericCallback*                                                     \
00498   createUCallback(UObject& owner, UVar* target,                         \
00499                   const std::string& type,                              \
00500                   EOBJ* obj,                                            \
00501                   R (OBJ::*fun) ( P1 , P2 ) Const,                      \
00502                   const std::string& funname)                           \
00503   {                                                                     \
00504     return new UCallback2<OBJ,R, P1 , P2 > (owner, target, type,       \
00505        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00506   }
00507 
00508   INSTANTIATE(__);
00509   INSTANTIATE(const);
00510 
00511 # undef INSTANTIATE
00512 
00513 
00514   // non void return type
00515 
00516   template <class OBJ, class R, class P1 , class P2 , class P3 >
00517   class UCallback3 : public UGenericCallback
00518   {
00519   public:
00520 
00521 # define INSTANTIATE(Const, IsConst)                                    \
00522       UCallback3(UObject& owner,                                      \
00523                    UVar* target,                                        \
00524                    const std::string& type,                             \
00525                    OBJ* obj,                                            \
00526                    R (OBJ::*fun) ( P1 , P2 , P3 ) Const,                   \
00527                    const std::string& funname)                          \
00528       : UGenericCallback                                                \
00529       (owner, target, type, funname, 3,                               \
00530        fetchContext(obj,                                                \
00531                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00532                     UContext>::res>::res()))                            \
00533       , obj(obj)                                                        \
00534       , fun##Const(fun)                                                 \
00535       , is_const_(IsConst)                                              \
00536     {                                                                   \
00537       nbparam = 3;                                                    \
00538       registerCallback();                                               \
00539     }
00540 
00541     INSTANTIATE(     , false);
00542     INSTANTIATE(const, true);
00543 
00544 # undef INSTANTIATE
00545 
00546     virtual UValue __evalcall(UList& param)
00547     {
00548       impl::UContextImpl::CleanupStack s_(*ctx_);
00549       LIBPORT_USE(param);
00550       UValue res;
00551       res(),
00552         (is_const_)
00553         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) )
00554         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) );
00555       return res;
00556     }
00557 
00558   private:
00559     OBJ* obj;
00560     R (OBJ::*fun)      ( P1 , P2 , P3 );
00561     R (OBJ::*funconst) ( P1 , P2 , P3 ) const;
00562     bool is_const_;
00563   };
00564 
00565 
00566   // non void non-member function
00567   template <class R, class P1 , class P2 , class P3 >
00568   class UFCallback3 : public UGenericCallback
00569   {
00570     public:
00571     UFCallback3(UObject& owner, UVar* target,
00572                   const std::string& type,
00573                   R (*fun) ( P1 , P2 , P3 ),
00574                   const std::string& funname,
00575                   impl::UContextImpl* ctx)
00576       : UGenericCallback(owner, target, type, funname,3, ctx),
00577       fun(fun)
00578     {
00579       nbparam = 3;
00580       registerCallback();
00581     }
00582 
00583     virtual UValue __evalcall(UList& param)
00584     {
00585       impl::UContextImpl::CleanupStack s_(*ctx_);
00586       LIBPORT_USE(param);
00587       UValue res;
00588       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) );
00589       return res;
00590     }
00591 
00592     private:
00593     R (*fun) ( P1 , P2 , P3 );
00594   };
00595 
00596   // callback creation for non-member non void return type
00597 
00598   template <class R, class P1 , class P2 , class P3 >
00599   UGenericCallback*
00600   createUCallback(UObject& owner, UVar* target,
00601                   const std::string& type,
00602                   R (*fun) ( P1 , P2 , P3 ),
00603                   const std::string& funname,
00604                   impl::UContextImpl* ctx)
00605   {
00606     return new UFCallback3<R, P1 , P2 , P3 > (owner, target, type,fun,funname, ctx);
00607   }
00608 
00609   // callback creation for non void return type
00610 
00611   // Use a by-ref dynamic_cast to throw an exception in case of
00612   // failure.
00613 # define INSTANTIATE(Const)                                             \
00614   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 >            \
00615   UGenericCallback*                                                     \
00616   createUCallback(UObject& owner, UVar* target,                         \
00617                   const std::string& type,                              \
00618                   EOBJ* obj,                                            \
00619                   R (OBJ::*fun) ( P1 , P2 , P3 ) Const,                 \
00620                   const std::string& funname)                           \
00621   {                                                                     \
00622     return new UCallback3<OBJ,R, P1 , P2 , P3 > (owner, target, type,       \
00623        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00624   }
00625 
00626   INSTANTIATE(__);
00627   INSTANTIATE(const);
00628 
00629 # undef INSTANTIATE
00630 
00631 
00632   // non void return type
00633 
00634   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 >
00635   class UCallback4 : public UGenericCallback
00636   {
00637   public:
00638 
00639 # define INSTANTIATE(Const, IsConst)                                    \
00640       UCallback4(UObject& owner,                                      \
00641                    UVar* target,                                        \
00642                    const std::string& type,                             \
00643                    OBJ* obj,                                            \
00644                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 ) Const,                   \
00645                    const std::string& funname)                          \
00646       : UGenericCallback                                                \
00647       (owner, target, type, funname, 4,                               \
00648        fetchContext(obj,                                                \
00649                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00650                     UContext>::res>::res()))                            \
00651       , obj(obj)                                                        \
00652       , fun##Const(fun)                                                 \
00653       , is_const_(IsConst)                                              \
00654     {                                                                   \
00655       nbparam = 4;                                                    \
00656       registerCallback();                                               \
00657     }
00658 
00659     INSTANTIATE(     , false);
00660     INSTANTIATE(const, true);
00661 
00662 # undef INSTANTIATE
00663 
00664     virtual UValue __evalcall(UList& param)
00665     {
00666       impl::UContextImpl::CleanupStack s_(*ctx_);
00667       LIBPORT_USE(param);
00668       UValue res;
00669       res(),
00670         (is_const_)
00671         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) )
00672         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) );
00673       return res;
00674     }
00675 
00676   private:
00677     OBJ* obj;
00678     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 );
00679     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 ) const;
00680     bool is_const_;
00681   };
00682 
00683 
00684   // non void non-member function
00685   template <class R, class P1 , class P2 , class P3 , class P4 >
00686   class UFCallback4 : public UGenericCallback
00687   {
00688     public:
00689     UFCallback4(UObject& owner, UVar* target,
00690                   const std::string& type,
00691                   R (*fun) ( P1 , P2 , P3 , P4 ),
00692                   const std::string& funname,
00693                   impl::UContextImpl* ctx)
00694       : UGenericCallback(owner, target, type, funname,4, ctx),
00695       fun(fun)
00696     {
00697       nbparam = 4;
00698       registerCallback();
00699     }
00700 
00701     virtual UValue __evalcall(UList& param)
00702     {
00703       impl::UContextImpl::CleanupStack s_(*ctx_);
00704       LIBPORT_USE(param);
00705       UValue res;
00706       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) );
00707       return res;
00708     }
00709 
00710     private:
00711     R (*fun) ( P1 , P2 , P3 , P4 );
00712   };
00713 
00714   // callback creation for non-member non void return type
00715 
00716   template <class R, class P1 , class P2 , class P3 , class P4 >
00717   UGenericCallback*
00718   createUCallback(UObject& owner, UVar* target,
00719                   const std::string& type,
00720                   R (*fun) ( P1 , P2 , P3 , P4 ),
00721                   const std::string& funname,
00722                   impl::UContextImpl* ctx)
00723   {
00724     return new UFCallback4<R, P1 , P2 , P3 , P4 > (owner, target, type,fun,funname, ctx);
00725   }
00726 
00727   // callback creation for non void return type
00728 
00729   // Use a by-ref dynamic_cast to throw an exception in case of
00730   // failure.
00731 # define INSTANTIATE(Const)                                             \
00732   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 >         \
00733   UGenericCallback*                                                     \
00734   createUCallback(UObject& owner, UVar* target,                         \
00735                   const std::string& type,                              \
00736                   EOBJ* obj,                                            \
00737                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 ) Const,                    \
00738                   const std::string& funname)                           \
00739   {                                                                     \
00740     return new UCallback4<OBJ,R, P1 , P2 , P3 , P4 > (owner, target, type,       \
00741        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00742   }
00743 
00744   INSTANTIATE(__);
00745   INSTANTIATE(const);
00746 
00747 # undef INSTANTIATE
00748 
00749 
00750   // non void return type
00751 
00752   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 >
00753   class UCallback5 : public UGenericCallback
00754   {
00755   public:
00756 
00757 # define INSTANTIATE(Const, IsConst)                                    \
00758       UCallback5(UObject& owner,                                      \
00759                    UVar* target,                                        \
00760                    const std::string& type,                             \
00761                    OBJ* obj,                                            \
00762                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 ) Const,                   \
00763                    const std::string& funname)                          \
00764       : UGenericCallback                                                \
00765       (owner, target, type, funname, 5,                               \
00766        fetchContext(obj,                                                \
00767                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00768                     UContext>::res>::res()))                            \
00769       , obj(obj)                                                        \
00770       , fun##Const(fun)                                                 \
00771       , is_const_(IsConst)                                              \
00772     {                                                                   \
00773       nbparam = 5;                                                    \
00774       registerCallback();                                               \
00775     }
00776 
00777     INSTANTIATE(     , false);
00778     INSTANTIATE(const, true);
00779 
00780 # undef INSTANTIATE
00781 
00782     virtual UValue __evalcall(UList& param)
00783     {
00784       impl::UContextImpl::CleanupStack s_(*ctx_);
00785       LIBPORT_USE(param);
00786       UValue res;
00787       res(),
00788         (is_const_)
00789         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) )
00790         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) );
00791       return res;
00792     }
00793 
00794   private:
00795     OBJ* obj;
00796     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 );
00797     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 ) const;
00798     bool is_const_;
00799   };
00800 
00801 
00802   // non void non-member function
00803   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 >
00804   class UFCallback5 : public UGenericCallback
00805   {
00806     public:
00807     UFCallback5(UObject& owner, UVar* target,
00808                   const std::string& type,
00809                   R (*fun) ( P1 , P2 , P3 , P4 , P5 ),
00810                   const std::string& funname,
00811                   impl::UContextImpl* ctx)
00812       : UGenericCallback(owner, target, type, funname,5, ctx),
00813       fun(fun)
00814     {
00815       nbparam = 5;
00816       registerCallback();
00817     }
00818 
00819     virtual UValue __evalcall(UList& param)
00820     {
00821       impl::UContextImpl::CleanupStack s_(*ctx_);
00822       LIBPORT_USE(param);
00823       UValue res;
00824       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) );
00825       return res;
00826     }
00827 
00828     private:
00829     R (*fun) ( P1 , P2 , P3 , P4 , P5 );
00830   };
00831 
00832   // callback creation for non-member non void return type
00833 
00834   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 >
00835   UGenericCallback*
00836   createUCallback(UObject& owner, UVar* target,
00837                   const std::string& type,
00838                   R (*fun) ( P1 , P2 , P3 , P4 , P5 ),
00839                   const std::string& funname,
00840                   impl::UContextImpl* ctx)
00841   {
00842     return new UFCallback5<R, P1 , P2 , P3 , P4 , P5 > (owner, target, type,fun,funname, ctx);
00843   }
00844 
00845   // callback creation for non void return type
00846 
00847   // Use a by-ref dynamic_cast to throw an exception in case of
00848   // failure.
00849 # define INSTANTIATE(Const)                                             \
00850   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 >              \
00851   UGenericCallback*                                                     \
00852   createUCallback(UObject& owner, UVar* target,                         \
00853                   const std::string& type,                              \
00854                   EOBJ* obj,                                            \
00855                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 ) Const,                       \
00856                   const std::string& funname)                           \
00857   {                                                                     \
00858     return new UCallback5<OBJ,R, P1 , P2 , P3 , P4 , P5 > (owner, target, type,       \
00859        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00860   }
00861 
00862   INSTANTIATE(__);
00863   INSTANTIATE(const);
00864 
00865 # undef INSTANTIATE
00866 
00867 
00868   // non void return type
00869 
00870   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >
00871   class UCallback6 : public UGenericCallback
00872   {
00873   public:
00874 
00875 # define INSTANTIATE(Const, IsConst)                                    \
00876       UCallback6(UObject& owner,                                      \
00877                    UVar* target,                                        \
00878                    const std::string& type,                             \
00879                    OBJ* obj,                                            \
00880                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 ) Const,                   \
00881                    const std::string& funname)                          \
00882       : UGenericCallback                                                \
00883       (owner, target, type, funname, 6,                               \
00884        fetchContext(obj,                                                \
00885                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
00886                     UContext>::res>::res()))                            \
00887       , obj(obj)                                                        \
00888       , fun##Const(fun)                                                 \
00889       , is_const_(IsConst)                                              \
00890     {                                                                   \
00891       nbparam = 6;                                                    \
00892       registerCallback();                                               \
00893     }
00894 
00895     INSTANTIATE(     , false);
00896     INSTANTIATE(const, true);
00897 
00898 # undef INSTANTIATE
00899 
00900     virtual UValue __evalcall(UList& param)
00901     {
00902       impl::UContextImpl::CleanupStack s_(*ctx_);
00903       LIBPORT_USE(param);
00904       UValue res;
00905       res(),
00906         (is_const_)
00907         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) )
00908         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) );
00909       return res;
00910     }
00911 
00912   private:
00913     OBJ* obj;
00914     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 );
00915     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 ) const;
00916     bool is_const_;
00917   };
00918 
00919 
00920   // non void non-member function
00921   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >
00922   class UFCallback6 : public UGenericCallback
00923   {
00924     public:
00925     UFCallback6(UObject& owner, UVar* target,
00926                   const std::string& type,
00927                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 ),
00928                   const std::string& funname,
00929                   impl::UContextImpl* ctx)
00930       : UGenericCallback(owner, target, type, funname,6, ctx),
00931       fun(fun)
00932     {
00933       nbparam = 6;
00934       registerCallback();
00935     }
00936 
00937     virtual UValue __evalcall(UList& param)
00938     {
00939       impl::UContextImpl::CleanupStack s_(*ctx_);
00940       LIBPORT_USE(param);
00941       UValue res;
00942       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) );
00943       return res;
00944     }
00945 
00946     private:
00947     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 );
00948   };
00949 
00950   // callback creation for non-member non void return type
00951 
00952   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >
00953   UGenericCallback*
00954   createUCallback(UObject& owner, UVar* target,
00955                   const std::string& type,
00956                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 ),
00957                   const std::string& funname,
00958                   impl::UContextImpl* ctx)
00959   {
00960     return new UFCallback6<R, P1 , P2 , P3 , P4 , P5 , P6 > (owner, target, type,fun,funname, ctx);
00961   }
00962 
00963   // callback creation for non void return type
00964 
00965   // Use a by-ref dynamic_cast to throw an exception in case of
00966   // failure.
00967 # define INSTANTIATE(Const)                                             \
00968   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >           \
00969   UGenericCallback*                                                     \
00970   createUCallback(UObject& owner, UVar* target,                         \
00971                   const std::string& type,                              \
00972                   EOBJ* obj,                                            \
00973                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 ) Const,                  \
00974                   const std::string& funname)                           \
00975   {                                                                     \
00976     return new UCallback6<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 > (owner, target, type,       \
00977        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
00978   }
00979 
00980   INSTANTIATE(__);
00981   INSTANTIATE(const);
00982 
00983 # undef INSTANTIATE
00984 
00985 
00986   // non void return type
00987 
00988   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >
00989   class UCallback7 : public UGenericCallback
00990   {
00991   public:
00992 
00993 # define INSTANTIATE(Const, IsConst)                                    \
00994       UCallback7(UObject& owner,                                      \
00995                    UVar* target,                                        \
00996                    const std::string& type,                             \
00997                    OBJ* obj,                                            \
00998                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 ) Const,                   \
00999                    const std::string& funname)                          \
01000       : UGenericCallback                                                \
01001       (owner, target, type, funname, 7,                               \
01002        fetchContext(obj,                                                \
01003                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01004                     UContext>::res>::res()))                            \
01005       , obj(obj)                                                        \
01006       , fun##Const(fun)                                                 \
01007       , is_const_(IsConst)                                              \
01008     {                                                                   \
01009       nbparam = 7;                                                    \
01010       registerCallback();                                               \
01011     }
01012 
01013     INSTANTIATE(     , false);
01014     INSTANTIATE(const, true);
01015 
01016 # undef INSTANTIATE
01017 
01018     virtual UValue __evalcall(UList& param)
01019     {
01020       impl::UContextImpl::CleanupStack s_(*ctx_);
01021       LIBPORT_USE(param);
01022       UValue res;
01023       res(),
01024         (is_const_)
01025         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) )
01026         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) );
01027       return res;
01028     }
01029 
01030   private:
01031     OBJ* obj;
01032     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 );
01033     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 ) const;
01034     bool is_const_;
01035   };
01036 
01037 
01038   // non void non-member function
01039   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >
01040   class UFCallback7 : public UGenericCallback
01041   {
01042     public:
01043     UFCallback7(UObject& owner, UVar* target,
01044                   const std::string& type,
01045                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 ),
01046                   const std::string& funname,
01047                   impl::UContextImpl* ctx)
01048       : UGenericCallback(owner, target, type, funname,7, ctx),
01049       fun(fun)
01050     {
01051       nbparam = 7;
01052       registerCallback();
01053     }
01054 
01055     virtual UValue __evalcall(UList& param)
01056     {
01057       impl::UContextImpl::CleanupStack s_(*ctx_);
01058       LIBPORT_USE(param);
01059       UValue res;
01060       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) );
01061       return res;
01062     }
01063 
01064     private:
01065     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 );
01066   };
01067 
01068   // callback creation for non-member non void return type
01069 
01070   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >
01071   UGenericCallback*
01072   createUCallback(UObject& owner, UVar* target,
01073                   const std::string& type,
01074                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 ),
01075                   const std::string& funname,
01076                   impl::UContextImpl* ctx)
01077   {
01078     return new UFCallback7<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 > (owner, target, type,fun,funname, ctx);
01079   }
01080 
01081   // callback creation for non void return type
01082 
01083   // Use a by-ref dynamic_cast to throw an exception in case of
01084   // failure.
01085 # define INSTANTIATE(Const)                                             \
01086   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >                \
01087   UGenericCallback*                                                     \
01088   createUCallback(UObject& owner, UVar* target,                         \
01089                   const std::string& type,                              \
01090                   EOBJ* obj,                                            \
01091                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 ) Const,                     \
01092                   const std::string& funname)                           \
01093   {                                                                     \
01094     return new UCallback7<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 > (owner, target, type,       \
01095        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01096   }
01097 
01098   INSTANTIATE(__);
01099   INSTANTIATE(const);
01100 
01101 # undef INSTANTIATE
01102 
01103 
01104   // non void return type
01105 
01106   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >
01107   class UCallback8 : public UGenericCallback
01108   {
01109   public:
01110 
01111 # define INSTANTIATE(Const, IsConst)                                    \
01112       UCallback8(UObject& owner,                                      \
01113                    UVar* target,                                        \
01114                    const std::string& type,                             \
01115                    OBJ* obj,                                            \
01116                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 ) Const,                   \
01117                    const std::string& funname)                          \
01118       : UGenericCallback                                                \
01119       (owner, target, type, funname, 8,                               \
01120        fetchContext(obj,                                                \
01121                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01122                     UContext>::res>::res()))                            \
01123       , obj(obj)                                                        \
01124       , fun##Const(fun)                                                 \
01125       , is_const_(IsConst)                                              \
01126     {                                                                   \
01127       nbparam = 8;                                                    \
01128       registerCallback();                                               \
01129     }
01130 
01131     INSTANTIATE(     , false);
01132     INSTANTIATE(const, true);
01133 
01134 # undef INSTANTIATE
01135 
01136     virtual UValue __evalcall(UList& param)
01137     {
01138       impl::UContextImpl::CleanupStack s_(*ctx_);
01139       LIBPORT_USE(param);
01140       UValue res;
01141       res(),
01142         (is_const_)
01143         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) )
01144         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) );
01145       return res;
01146     }
01147 
01148   private:
01149     OBJ* obj;
01150     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 );
01151     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 ) const;
01152     bool is_const_;
01153   };
01154 
01155 
01156   // non void non-member function
01157   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >
01158   class UFCallback8 : public UGenericCallback
01159   {
01160     public:
01161     UFCallback8(UObject& owner, UVar* target,
01162                   const std::string& type,
01163                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 ),
01164                   const std::string& funname,
01165                   impl::UContextImpl* ctx)
01166       : UGenericCallback(owner, target, type, funname,8, ctx),
01167       fun(fun)
01168     {
01169       nbparam = 8;
01170       registerCallback();
01171     }
01172 
01173     virtual UValue __evalcall(UList& param)
01174     {
01175       impl::UContextImpl::CleanupStack s_(*ctx_);
01176       LIBPORT_USE(param);
01177       UValue res;
01178       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) );
01179       return res;
01180     }
01181 
01182     private:
01183     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 );
01184   };
01185 
01186   // callback creation for non-member non void return type
01187 
01188   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >
01189   UGenericCallback*
01190   createUCallback(UObject& owner, UVar* target,
01191                   const std::string& type,
01192                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 ),
01193                   const std::string& funname,
01194                   impl::UContextImpl* ctx)
01195   {
01196     return new UFCallback8<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 > (owner, target, type,fun,funname, ctx);
01197   }
01198 
01199   // callback creation for non void return type
01200 
01201   // Use a by-ref dynamic_cast to throw an exception in case of
01202   // failure.
01203 # define INSTANTIATE(Const)                                             \
01204   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >             \
01205   UGenericCallback*                                                     \
01206   createUCallback(UObject& owner, UVar* target,                         \
01207                   const std::string& type,                              \
01208                   EOBJ* obj,                                            \
01209                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 ) Const,                        \
01210                   const std::string& funname)                           \
01211   {                                                                     \
01212     return new UCallback8<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 > (owner, target, type,       \
01213        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01214   }
01215 
01216   INSTANTIATE(__);
01217   INSTANTIATE(const);
01218 
01219 # undef INSTANTIATE
01220 
01221 
01222   // non void return type
01223 
01224   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >
01225   class UCallback9 : public UGenericCallback
01226   {
01227   public:
01228 
01229 # define INSTANTIATE(Const, IsConst)                                    \
01230       UCallback9(UObject& owner,                                      \
01231                    UVar* target,                                        \
01232                    const std::string& type,                             \
01233                    OBJ* obj,                                            \
01234                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 ) Const,                   \
01235                    const std::string& funname)                          \
01236       : UGenericCallback                                                \
01237       (owner, target, type, funname, 9,                               \
01238        fetchContext(obj,                                                \
01239                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01240                     UContext>::res>::res()))                            \
01241       , obj(obj)                                                        \
01242       , fun##Const(fun)                                                 \
01243       , is_const_(IsConst)                                              \
01244     {                                                                   \
01245       nbparam = 9;                                                    \
01246       registerCallback();                                               \
01247     }
01248 
01249     INSTANTIATE(     , false);
01250     INSTANTIATE(const, true);
01251 
01252 # undef INSTANTIATE
01253 
01254     virtual UValue __evalcall(UList& param)
01255     {
01256       impl::UContextImpl::CleanupStack s_(*ctx_);
01257       LIBPORT_USE(param);
01258       UValue res;
01259       res(),
01260         (is_const_)
01261         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) )
01262         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) );
01263       return res;
01264     }
01265 
01266   private:
01267     OBJ* obj;
01268     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 );
01269     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 ) const;
01270     bool is_const_;
01271   };
01272 
01273 
01274   // non void non-member function
01275   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >
01276   class UFCallback9 : public UGenericCallback
01277   {
01278     public:
01279     UFCallback9(UObject& owner, UVar* target,
01280                   const std::string& type,
01281                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 ),
01282                   const std::string& funname,
01283                   impl::UContextImpl* ctx)
01284       : UGenericCallback(owner, target, type, funname,9, ctx),
01285       fun(fun)
01286     {
01287       nbparam = 9;
01288       registerCallback();
01289     }
01290 
01291     virtual UValue __evalcall(UList& param)
01292     {
01293       impl::UContextImpl::CleanupStack s_(*ctx_);
01294       LIBPORT_USE(param);
01295       UValue res;
01296       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) );
01297       return res;
01298     }
01299 
01300     private:
01301     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 );
01302   };
01303 
01304   // callback creation for non-member non void return type
01305 
01306   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >
01307   UGenericCallback*
01308   createUCallback(UObject& owner, UVar* target,
01309                   const std::string& type,
01310                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 ),
01311                   const std::string& funname,
01312                   impl::UContextImpl* ctx)
01313   {
01314     return new UFCallback9<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 > (owner, target, type,fun,funname, ctx);
01315   }
01316 
01317   // callback creation for non void return type
01318 
01319   // Use a by-ref dynamic_cast to throw an exception in case of
01320   // failure.
01321 # define INSTANTIATE(Const)                                             \
01322   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >          \
01323   UGenericCallback*                                                     \
01324   createUCallback(UObject& owner, UVar* target,                         \
01325                   const std::string& type,                              \
01326                   EOBJ* obj,                                            \
01327                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 ) Const,                   \
01328                   const std::string& funname)                           \
01329   {                                                                     \
01330     return new UCallback9<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 > (owner, target, type,       \
01331        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01332   }
01333 
01334   INSTANTIATE(__);
01335   INSTANTIATE(const);
01336 
01337 # undef INSTANTIATE
01338 
01339 
01340   // non void return type
01341 
01342   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >
01343   class UCallback10 : public UGenericCallback
01344   {
01345   public:
01346 
01347 # define INSTANTIATE(Const, IsConst)                                    \
01348       UCallback10(UObject& owner,                                      \
01349                    UVar* target,                                        \
01350                    const std::string& type,                             \
01351                    OBJ* obj,                                            \
01352                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 ) Const,                   \
01353                    const std::string& funname)                          \
01354       : UGenericCallback                                                \
01355       (owner, target, type, funname, 10,                               \
01356        fetchContext(obj,                                                \
01357                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01358                     UContext>::res>::res()))                            \
01359       , obj(obj)                                                        \
01360       , fun##Const(fun)                                                 \
01361       , is_const_(IsConst)                                              \
01362     {                                                                   \
01363       nbparam = 10;                                                    \
01364       registerCallback();                                               \
01365     }
01366 
01367     INSTANTIATE(     , false);
01368     INSTANTIATE(const, true);
01369 
01370 # undef INSTANTIATE
01371 
01372     virtual UValue __evalcall(UList& param)
01373     {
01374       impl::UContextImpl::CleanupStack s_(*ctx_);
01375       LIBPORT_USE(param);
01376       UValue res;
01377       res(),
01378         (is_const_)
01379         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) )
01380         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) );
01381       return res;
01382     }
01383 
01384   private:
01385     OBJ* obj;
01386     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 );
01387     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 ) const;
01388     bool is_const_;
01389   };
01390 
01391 
01392   // non void non-member function
01393   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >
01394   class UFCallback10 : public UGenericCallback
01395   {
01396     public:
01397     UFCallback10(UObject& owner, UVar* target,
01398                   const std::string& type,
01399                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 ),
01400                   const std::string& funname,
01401                   impl::UContextImpl* ctx)
01402       : UGenericCallback(owner, target, type, funname,10, ctx),
01403       fun(fun)
01404     {
01405       nbparam = 10;
01406       registerCallback();
01407     }
01408 
01409     virtual UValue __evalcall(UList& param)
01410     {
01411       impl::UContextImpl::CleanupStack s_(*ctx_);
01412       LIBPORT_USE(param);
01413       UValue res;
01414       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) );
01415       return res;
01416     }
01417 
01418     private:
01419     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 );
01420   };
01421 
01422   // callback creation for non-member non void return type
01423 
01424   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >
01425   UGenericCallback*
01426   createUCallback(UObject& owner, UVar* target,
01427                   const std::string& type,
01428                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 ),
01429                   const std::string& funname,
01430                   impl::UContextImpl* ctx)
01431   {
01432     return new UFCallback10<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 > (owner, target, type,fun,funname, ctx);
01433   }
01434 
01435   // callback creation for non void return type
01436 
01437   // Use a by-ref dynamic_cast to throw an exception in case of
01438   // failure.
01439 # define INSTANTIATE(Const)                                             \
01440   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >              \
01441   UGenericCallback*                                                     \
01442   createUCallback(UObject& owner, UVar* target,                         \
01443                   const std::string& type,                              \
01444                   EOBJ* obj,                                            \
01445                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 ) Const,                     \
01446                   const std::string& funname)                           \
01447   {                                                                     \
01448     return new UCallback10<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 > (owner, target, type,       \
01449        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01450   }
01451 
01452   INSTANTIATE(__);
01453   INSTANTIATE(const);
01454 
01455 # undef INSTANTIATE
01456 
01457 
01458   // non void return type
01459 
01460   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 >
01461   class UCallback11 : public UGenericCallback
01462   {
01463   public:
01464 
01465 # define INSTANTIATE(Const, IsConst)                                    \
01466       UCallback11(UObject& owner,                                      \
01467                    UVar* target,                                        \
01468                    const std::string& type,                             \
01469                    OBJ* obj,                                            \
01470                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 ) Const,                   \
01471                    const std::string& funname)                          \
01472       : UGenericCallback                                                \
01473       (owner, target, type, funname, 11,                               \
01474        fetchContext(obj,                                                \
01475                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01476                     UContext>::res>::res()))                            \
01477       , obj(obj)                                                        \
01478       , fun##Const(fun)                                                 \
01479       , is_const_(IsConst)                                              \
01480     {                                                                   \
01481       nbparam = 11;                                                    \
01482       registerCallback();                                               \
01483     }
01484 
01485     INSTANTIATE(     , false);
01486     INSTANTIATE(const, true);
01487 
01488 # undef INSTANTIATE
01489 
01490     virtual UValue __evalcall(UList& param)
01491     {
01492       impl::UContextImpl::CleanupStack s_(*ctx_);
01493       LIBPORT_USE(param);
01494       UValue res;
01495       res(),
01496         (is_const_)
01497         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) )
01498         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) );
01499       return res;
01500     }
01501 
01502   private:
01503     OBJ* obj;
01504     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 );
01505     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 ) const;
01506     bool is_const_;
01507   };
01508 
01509 
01510   // non void non-member function
01511   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 >
01512   class UFCallback11 : public UGenericCallback
01513   {
01514     public:
01515     UFCallback11(UObject& owner, UVar* target,
01516                   const std::string& type,
01517                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 ),
01518                   const std::string& funname,
01519                   impl::UContextImpl* ctx)
01520       : UGenericCallback(owner, target, type, funname,11, ctx),
01521       fun(fun)
01522     {
01523       nbparam = 11;
01524       registerCallback();
01525     }
01526 
01527     virtual UValue __evalcall(UList& param)
01528     {
01529       impl::UContextImpl::CleanupStack s_(*ctx_);
01530       LIBPORT_USE(param);
01531       UValue res;
01532       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) );
01533       return res;
01534     }
01535 
01536     private:
01537     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 );
01538   };
01539 
01540   // callback creation for non-member non void return type
01541 
01542   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 >
01543   UGenericCallback*
01544   createUCallback(UObject& owner, UVar* target,
01545                   const std::string& type,
01546                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 ),
01547                   const std::string& funname,
01548                   impl::UContextImpl* ctx)
01549   {
01550     return new UFCallback11<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 > (owner, target, type,fun,funname, ctx);
01551   }
01552 
01553   // callback creation for non void return type
01554 
01555   // Use a by-ref dynamic_cast to throw an exception in case of
01556   // failure.
01557 # define INSTANTIATE(Const)                                             \
01558   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 >          \
01559   UGenericCallback*                                                     \
01560   createUCallback(UObject& owner, UVar* target,                         \
01561                   const std::string& type,                              \
01562                   EOBJ* obj,                                            \
01563                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 ) Const,                       \
01564                   const std::string& funname)                           \
01565   {                                                                     \
01566     return new UCallback11<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 > (owner, target, type,       \
01567        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01568   }
01569 
01570   INSTANTIATE(__);
01571   INSTANTIATE(const);
01572 
01573 # undef INSTANTIATE
01574 
01575 
01576   // non void return type
01577 
01578   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 >
01579   class UCallback12 : public UGenericCallback
01580   {
01581   public:
01582 
01583 # define INSTANTIATE(Const, IsConst)                                    \
01584       UCallback12(UObject& owner,                                      \
01585                    UVar* target,                                        \
01586                    const std::string& type,                             \
01587                    OBJ* obj,                                            \
01588                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 ) Const,                   \
01589                    const std::string& funname)                          \
01590       : UGenericCallback                                                \
01591       (owner, target, type, funname, 12,                               \
01592        fetchContext(obj,                                                \
01593                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01594                     UContext>::res>::res()))                            \
01595       , obj(obj)                                                        \
01596       , fun##Const(fun)                                                 \
01597       , is_const_(IsConst)                                              \
01598     {                                                                   \
01599       nbparam = 12;                                                    \
01600       registerCallback();                                               \
01601     }
01602 
01603     INSTANTIATE(     , false);
01604     INSTANTIATE(const, true);
01605 
01606 # undef INSTANTIATE
01607 
01608     virtual UValue __evalcall(UList& param)
01609     {
01610       impl::UContextImpl::CleanupStack s_(*ctx_);
01611       LIBPORT_USE(param);
01612       UValue res;
01613       res(),
01614         (is_const_)
01615         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) )
01616         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) );
01617       return res;
01618     }
01619 
01620   private:
01621     OBJ* obj;
01622     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 );
01623     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 ) const;
01624     bool is_const_;
01625   };
01626 
01627 
01628   // non void non-member function
01629   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 >
01630   class UFCallback12 : public UGenericCallback
01631   {
01632     public:
01633     UFCallback12(UObject& owner, UVar* target,
01634                   const std::string& type,
01635                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 ),
01636                   const std::string& funname,
01637                   impl::UContextImpl* ctx)
01638       : UGenericCallback(owner, target, type, funname,12, ctx),
01639       fun(fun)
01640     {
01641       nbparam = 12;
01642       registerCallback();
01643     }
01644 
01645     virtual UValue __evalcall(UList& param)
01646     {
01647       impl::UContextImpl::CleanupStack s_(*ctx_);
01648       LIBPORT_USE(param);
01649       UValue res;
01650       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) );
01651       return res;
01652     }
01653 
01654     private:
01655     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 );
01656   };
01657 
01658   // callback creation for non-member non void return type
01659 
01660   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 >
01661   UGenericCallback*
01662   createUCallback(UObject& owner, UVar* target,
01663                   const std::string& type,
01664                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 ),
01665                   const std::string& funname,
01666                   impl::UContextImpl* ctx)
01667   {
01668     return new UFCallback12<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 > (owner, target, type,fun,funname, ctx);
01669   }
01670 
01671   // callback creation for non void return type
01672 
01673   // Use a by-ref dynamic_cast to throw an exception in case of
01674   // failure.
01675 # define INSTANTIATE(Const)                                             \
01676   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 >              \
01677   UGenericCallback*                                                     \
01678   createUCallback(UObject& owner, UVar* target,                         \
01679                   const std::string& type,                              \
01680                   EOBJ* obj,                                            \
01681                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 ) Const,                 \
01682                   const std::string& funname)                           \
01683   {                                                                     \
01684     return new UCallback12<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 > (owner, target, type,       \
01685        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01686   }
01687 
01688   INSTANTIATE(__);
01689   INSTANTIATE(const);
01690 
01691 # undef INSTANTIATE
01692 
01693 
01694   // non void return type
01695 
01696   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 >
01697   class UCallback13 : public UGenericCallback
01698   {
01699   public:
01700 
01701 # define INSTANTIATE(Const, IsConst)                                    \
01702       UCallback13(UObject& owner,                                      \
01703                    UVar* target,                                        \
01704                    const std::string& type,                             \
01705                    OBJ* obj,                                            \
01706                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 ) Const,                   \
01707                    const std::string& funname)                          \
01708       : UGenericCallback                                                \
01709       (owner, target, type, funname, 13,                               \
01710        fetchContext(obj,                                                \
01711                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01712                     UContext>::res>::res()))                            \
01713       , obj(obj)                                                        \
01714       , fun##Const(fun)                                                 \
01715       , is_const_(IsConst)                                              \
01716     {                                                                   \
01717       nbparam = 13;                                                    \
01718       registerCallback();                                               \
01719     }
01720 
01721     INSTANTIATE(     , false);
01722     INSTANTIATE(const, true);
01723 
01724 # undef INSTANTIATE
01725 
01726     virtual UValue __evalcall(UList& param)
01727     {
01728       impl::UContextImpl::CleanupStack s_(*ctx_);
01729       LIBPORT_USE(param);
01730       UValue res;
01731       res(),
01732         (is_const_)
01733         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) )
01734         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) );
01735       return res;
01736     }
01737 
01738   private:
01739     OBJ* obj;
01740     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 );
01741     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 ) const;
01742     bool is_const_;
01743   };
01744 
01745 
01746   // non void non-member function
01747   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 >
01748   class UFCallback13 : public UGenericCallback
01749   {
01750     public:
01751     UFCallback13(UObject& owner, UVar* target,
01752                   const std::string& type,
01753                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 ),
01754                   const std::string& funname,
01755                   impl::UContextImpl* ctx)
01756       : UGenericCallback(owner, target, type, funname,13, ctx),
01757       fun(fun)
01758     {
01759       nbparam = 13;
01760       registerCallback();
01761     }
01762 
01763     virtual UValue __evalcall(UList& param)
01764     {
01765       impl::UContextImpl::CleanupStack s_(*ctx_);
01766       LIBPORT_USE(param);
01767       UValue res;
01768       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) );
01769       return res;
01770     }
01771 
01772     private:
01773     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 );
01774   };
01775 
01776   // callback creation for non-member non void return type
01777 
01778   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 >
01779   UGenericCallback*
01780   createUCallback(UObject& owner, UVar* target,
01781                   const std::string& type,
01782                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 ),
01783                   const std::string& funname,
01784                   impl::UContextImpl* ctx)
01785   {
01786     return new UFCallback13<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 > (owner, target, type,fun,funname, ctx);
01787   }
01788 
01789   // callback creation for non void return type
01790 
01791   // Use a by-ref dynamic_cast to throw an exception in case of
01792   // failure.
01793 # define INSTANTIATE(Const)                                             \
01794   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 >          \
01795   UGenericCallback*                                                     \
01796   createUCallback(UObject& owner, UVar* target,                         \
01797                   const std::string& type,                              \
01798                   EOBJ* obj,                                            \
01799                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 ) Const,                   \
01800                   const std::string& funname)                           \
01801   {                                                                     \
01802     return new UCallback13<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 > (owner, target, type,       \
01803        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01804   }
01805 
01806   INSTANTIATE(__);
01807   INSTANTIATE(const);
01808 
01809 # undef INSTANTIATE
01810 
01811 
01812   // non void return type
01813 
01814   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 >
01815   class UCallback14 : public UGenericCallback
01816   {
01817   public:
01818 
01819 # define INSTANTIATE(Const, IsConst)                                    \
01820       UCallback14(UObject& owner,                                      \
01821                    UVar* target,                                        \
01822                    const std::string& type,                             \
01823                    OBJ* obj,                                            \
01824                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 ) Const,                   \
01825                    const std::string& funname)                          \
01826       : UGenericCallback                                                \
01827       (owner, target, type, funname, 14,                               \
01828        fetchContext(obj,                                                \
01829                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01830                     UContext>::res>::res()))                            \
01831       , obj(obj)                                                        \
01832       , fun##Const(fun)                                                 \
01833       , is_const_(IsConst)                                              \
01834     {                                                                   \
01835       nbparam = 14;                                                    \
01836       registerCallback();                                               \
01837     }
01838 
01839     INSTANTIATE(     , false);
01840     INSTANTIATE(const, true);
01841 
01842 # undef INSTANTIATE
01843 
01844     virtual UValue __evalcall(UList& param)
01845     {
01846       impl::UContextImpl::CleanupStack s_(*ctx_);
01847       LIBPORT_USE(param);
01848       UValue res;
01849       res(),
01850         (is_const_)
01851         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) )
01852         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) );
01853       return res;
01854     }
01855 
01856   private:
01857     OBJ* obj;
01858     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 );
01859     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 ) const;
01860     bool is_const_;
01861   };
01862 
01863 
01864   // non void non-member function
01865   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 >
01866   class UFCallback14 : public UGenericCallback
01867   {
01868     public:
01869     UFCallback14(UObject& owner, UVar* target,
01870                   const std::string& type,
01871                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 ),
01872                   const std::string& funname,
01873                   impl::UContextImpl* ctx)
01874       : UGenericCallback(owner, target, type, funname,14, ctx),
01875       fun(fun)
01876     {
01877       nbparam = 14;
01878       registerCallback();
01879     }
01880 
01881     virtual UValue __evalcall(UList& param)
01882     {
01883       impl::UContextImpl::CleanupStack s_(*ctx_);
01884       LIBPORT_USE(param);
01885       UValue res;
01886       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) );
01887       return res;
01888     }
01889 
01890     private:
01891     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 );
01892   };
01893 
01894   // callback creation for non-member non void return type
01895 
01896   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 >
01897   UGenericCallback*
01898   createUCallback(UObject& owner, UVar* target,
01899                   const std::string& type,
01900                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 ),
01901                   const std::string& funname,
01902                   impl::UContextImpl* ctx)
01903   {
01904     return new UFCallback14<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 > (owner, target, type,fun,funname, ctx);
01905   }
01906 
01907   // callback creation for non void return type
01908 
01909   // Use a by-ref dynamic_cast to throw an exception in case of
01910   // failure.
01911 # define INSTANTIATE(Const)                                             \
01912   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 >              \
01913   UGenericCallback*                                                     \
01914   createUCallback(UObject& owner, UVar* target,                         \
01915                   const std::string& type,                              \
01916                   EOBJ* obj,                                            \
01917                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 ) Const,                     \
01918                   const std::string& funname)                           \
01919   {                                                                     \
01920     return new UCallback14<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 > (owner, target, type,       \
01921        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
01922   }
01923 
01924   INSTANTIATE(__);
01925   INSTANTIATE(const);
01926 
01927 # undef INSTANTIATE
01928 
01929 
01930   // non void return type
01931 
01932   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 >
01933   class UCallback15 : public UGenericCallback
01934   {
01935   public:
01936 
01937 # define INSTANTIATE(Const, IsConst)                                    \
01938       UCallback15(UObject& owner,                                      \
01939                    UVar* target,                                        \
01940                    const std::string& type,                             \
01941                    OBJ* obj,                                            \
01942                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 ) Const,                   \
01943                    const std::string& funname)                          \
01944       : UGenericCallback                                                \
01945       (owner, target, type, funname, 15,                               \
01946        fetchContext(obj,                                                \
01947                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
01948                     UContext>::res>::res()))                            \
01949       , obj(obj)                                                        \
01950       , fun##Const(fun)                                                 \
01951       , is_const_(IsConst)                                              \
01952     {                                                                   \
01953       nbparam = 15;                                                    \
01954       registerCallback();                                               \
01955     }
01956 
01957     INSTANTIATE(     , false);
01958     INSTANTIATE(const, true);
01959 
01960 # undef INSTANTIATE
01961 
01962     virtual UValue __evalcall(UList& param)
01963     {
01964       impl::UContextImpl::CleanupStack s_(*ctx_);
01965       LIBPORT_USE(param);
01966       UValue res;
01967       res(),
01968         (is_const_)
01969         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) , uvar_uvalue_cast<P15>(param[15 - 1]) )
01970         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) , uvar_uvalue_cast<P15>(param[15 - 1]) );
01971       return res;
01972     }
01973 
01974   private:
01975     OBJ* obj;
01976     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 );
01977     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 ) const;
01978     bool is_const_;
01979   };
01980 
01981 
01982   // non void non-member function
01983   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 >
01984   class UFCallback15 : public UGenericCallback
01985   {
01986     public:
01987     UFCallback15(UObject& owner, UVar* target,
01988                   const std::string& type,
01989                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 ),
01990                   const std::string& funname,
01991                   impl::UContextImpl* ctx)
01992       : UGenericCallback(owner, target, type, funname,15, ctx),
01993       fun(fun)
01994     {
01995       nbparam = 15;
01996       registerCallback();
01997     }
01998 
01999     virtual UValue __evalcall(UList& param)
02000     {
02001       impl::UContextImpl::CleanupStack s_(*ctx_);
02002       LIBPORT_USE(param);
02003       UValue res;
02004       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) , uvar_uvalue_cast<P15>(param[15 - 1]) );
02005       return res;
02006     }
02007 
02008     private:
02009     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 );
02010   };
02011 
02012   // callback creation for non-member non void return type
02013 
02014   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 >
02015   UGenericCallback*
02016   createUCallback(UObject& owner, UVar* target,
02017                   const std::string& type,
02018                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 ),
02019                   const std::string& funname,
02020                   impl::UContextImpl* ctx)
02021   {
02022     return new UFCallback15<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 > (owner, target, type,fun,funname, ctx);
02023   }
02024 
02025   // callback creation for non void return type
02026 
02027   // Use a by-ref dynamic_cast to throw an exception in case of
02028   // failure.
02029 # define INSTANTIATE(Const)                                             \
02030   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 >          \
02031   UGenericCallback*                                                     \
02032   createUCallback(UObject& owner, UVar* target,                         \
02033                   const std::string& type,                              \
02034                   EOBJ* obj,                                            \
02035                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 ) Const,                       \
02036                   const std::string& funname)                           \
02037   {                                                                     \
02038     return new UCallback15<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 > (owner, target, type,       \
02039        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
02040   }
02041 
02042   INSTANTIATE(__);
02043   INSTANTIATE(const);
02044 
02045 # undef INSTANTIATE
02046 
02047 
02048   // non void return type
02049 
02050   template <class OBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 >
02051   class UCallback16 : public UGenericCallback
02052   {
02053   public:
02054 
02055 # define INSTANTIATE(Const, IsConst)                                    \
02056       UCallback16(UObject& owner,                                      \
02057                    UVar* target,                                        \
02058                    const std::string& type,                             \
02059                    OBJ* obj,                                            \
02060                    R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 ) Const,                   \
02061                    const std::string& funname)                          \
02062       : UGenericCallback                                                \
02063       (owner, target, type, funname, 16,                               \
02064        fetchContext(obj,                                                \
02065                     typename libport::meta::If<libport::meta::Inherits<OBJ, \
02066                     UContext>::res>::res()))                            \
02067       , obj(obj)                                                        \
02068       , fun##Const(fun)                                                 \
02069       , is_const_(IsConst)                                              \
02070     {                                                                   \
02071       nbparam = 16;                                                    \
02072       registerCallback();                                               \
02073     }
02074 
02075     INSTANTIATE(     , false);
02076     INSTANTIATE(const, true);
02077 
02078 # undef INSTANTIATE
02079 
02080     virtual UValue __evalcall(UList& param)
02081     {
02082       impl::UContextImpl::CleanupStack s_(*ctx_);
02083       LIBPORT_USE(param);
02084       UValue res;
02085       res(),
02086         (is_const_)
02087         ? ((*obj).*funconst)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) , uvar_uvalue_cast<P15>(param[15 - 1]) , uvar_uvalue_cast<P16>(param[16 - 1]) )
02088         : ((*obj).*fun)     ( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) , uvar_uvalue_cast<P15>(param[15 - 1]) , uvar_uvalue_cast<P16>(param[16 - 1]) );
02089       return res;
02090     }
02091 
02092   private:
02093     OBJ* obj;
02094     R (OBJ::*fun)      ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 );
02095     R (OBJ::*funconst) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 ) const;
02096     bool is_const_;
02097   };
02098 
02099 
02100   // non void non-member function
02101   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 >
02102   class UFCallback16 : public UGenericCallback
02103   {
02104     public:
02105     UFCallback16(UObject& owner, UVar* target,
02106                   const std::string& type,
02107                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 ),
02108                   const std::string& funname,
02109                   impl::UContextImpl* ctx)
02110       : UGenericCallback(owner, target, type, funname,16, ctx),
02111       fun(fun)
02112     {
02113       nbparam = 16;
02114       registerCallback();
02115     }
02116 
02117     virtual UValue __evalcall(UList& param)
02118     {
02119       impl::UContextImpl::CleanupStack s_(*ctx_);
02120       LIBPORT_USE(param);
02121       UValue res;
02122       res(), (*fun)( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) , uvar_uvalue_cast<P11>(param[11 - 1]) , uvar_uvalue_cast<P12>(param[12 - 1]) , uvar_uvalue_cast<P13>(param[13 - 1]) , uvar_uvalue_cast<P14>(param[14 - 1]) , uvar_uvalue_cast<P15>(param[15 - 1]) , uvar_uvalue_cast<P16>(param[16 - 1]) );
02123       return res;
02124     }
02125 
02126     private:
02127     R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 );
02128   };
02129 
02130   // callback creation for non-member non void return type
02131 
02132   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 >
02133   UGenericCallback*
02134   createUCallback(UObject& owner, UVar* target,
02135                   const std::string& type,
02136                   R (*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 ),
02137                   const std::string& funname,
02138                   impl::UContextImpl* ctx)
02139   {
02140     return new UFCallback16<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 > (owner, target, type,fun,funname, ctx);
02141   }
02142 
02143   // callback creation for non void return type
02144 
02145   // Use a by-ref dynamic_cast to throw an exception in case of
02146   // failure.
02147 # define INSTANTIATE(Const)                                             \
02148   template <class OBJ, class EOBJ, class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 >              \
02149   UGenericCallback*                                                     \
02150   createUCallback(UObject& owner, UVar* target,                         \
02151                   const std::string& type,                              \
02152                   EOBJ* obj,                                            \
02153                   R (OBJ::*fun) ( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 ) Const,                 \
02154                   const std::string& funname)                           \
02155   {                                                                     \
02156     return new UCallback16<OBJ,R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 , P11 , P12 , P13 , P14 , P15 , P16 > (owner, target, type,       \
02157        &dynamic_cast<OBJ&>(*obj), fun, funname);                        \
02158   }
02159 
02160   INSTANTIATE(__);
02161   INSTANTIATE(const);
02162 
02163 # undef INSTANTIATE
02164 
02165 
02166 
02167   template <class R>
02168   class UBoostFunctionCallback0 : public UGenericCallback
02169   {
02170     public:
02171     UBoostFunctionCallback0(UObject& owner, UVar* target,
02172                   const std::string& type,
02173                   boost::function0<R > fun,
02174                   const std::string& funname,
02175                   impl::UContextImpl* ctx)
02176       : UGenericCallback(owner, target, type, funname,0, ctx),
02177       fun(fun)
02178     {
02179       nbparam = 0;
02180       registerCallback();
02181     }
02182 
02183     virtual UValue __evalcall(UList& param)
02184     {
02185       impl::UContextImpl::CleanupStack s_(*ctx_);
02186       LIBPORT_USE(param);
02187       UValue res;
02188       res(), fun();
02189       return res;
02190     }
02191 
02192     private:
02193     boost::function0<R > fun;
02194   };
02195 
02196   template <class R>
02197   UGenericCallback*
02198   createUCallback(UObject& owner, UVar* target,
02199                   const std::string& type,
02200                   boost::function0<R > fun,
02201                   const std::string& funname,
02202                   impl::UContextImpl* ctx)
02203   {
02204     return new UBoostFunctionCallback0<R>
02205       (owner, target, type,fun,funname, ctx);
02206   }
02207 
02208 # ifdef ATTRIBUTE_STDCALL
02209   template <class R>
02210   UGenericCallback*
02211   createUCallbackStd(UObject& owner, UVar* target,
02212                      const std::string& type,
02213                      // MSVC wants it here.
02214                      R (ATTRIBUTE_STDCALL *fun)(),
02215                      const std::string& funname,
02216                      impl::UContextImpl* ctx)
02217   {
02218     return new UBoostFunctionCallback0<R >
02219       (owner, target, type,boost::function0<R >(fun),funname, ctx);
02220   }
02221 # endif
02222 
02223   template <class R, class P1 >
02224   class UBoostFunctionCallback1 : public UGenericCallback
02225   {
02226     public:
02227     UBoostFunctionCallback1(UObject& owner, UVar* target,
02228                   const std::string& type,
02229                   boost::function1<R , P1 > fun,
02230                   const std::string& funname,
02231                   impl::UContextImpl* ctx)
02232       : UGenericCallback(owner, target, type, funname,1, ctx),
02233       fun(fun)
02234     {
02235       nbparam = 1;
02236       registerCallback();
02237     }
02238 
02239     virtual UValue __evalcall(UList& param)
02240     {
02241       impl::UContextImpl::CleanupStack s_(*ctx_);
02242       LIBPORT_USE(param);
02243       UValue res;
02244       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) );
02245       return res;
02246     }
02247 
02248     private:
02249     boost::function1<R , P1 > fun;
02250   };
02251 
02252   template <class R, class P1 >
02253   UGenericCallback*
02254   createUCallback(UObject& owner, UVar* target,
02255                   const std::string& type,
02256                   boost::function1<R , P1 > fun,
02257                   const std::string& funname,
02258                   impl::UContextImpl* ctx)
02259   {
02260     return new UBoostFunctionCallback1<R, P1 >
02261       (owner, target, type,fun,funname, ctx);
02262   }
02263 
02264 # ifdef ATTRIBUTE_STDCALL
02265   template <class R, class P1 >
02266   UGenericCallback*
02267   createUCallbackStd(UObject& owner, UVar* target,
02268                      const std::string& type,
02269                      // MSVC wants it here.
02270                      R (ATTRIBUTE_STDCALL *fun)( P1 ),
02271                      const std::string& funname,
02272                      impl::UContextImpl* ctx)
02273   {
02274     return new UBoostFunctionCallback1<R , P1 >
02275       (owner, target, type,boost::function1<R , P1 >(fun),funname, ctx);
02276   }
02277 # endif
02278 
02279   template <class R, class P1 , class P2 >
02280   class UBoostFunctionCallback2 : public UGenericCallback
02281   {
02282     public:
02283     UBoostFunctionCallback2(UObject& owner, UVar* target,
02284                   const std::string& type,
02285                   boost::function2<R , P1 , P2 > fun,
02286                   const std::string& funname,
02287                   impl::UContextImpl* ctx)
02288       : UGenericCallback(owner, target, type, funname,2, ctx),
02289       fun(fun)
02290     {
02291       nbparam = 2;
02292       registerCallback();
02293     }
02294 
02295     virtual UValue __evalcall(UList& param)
02296     {
02297       impl::UContextImpl::CleanupStack s_(*ctx_);
02298       LIBPORT_USE(param);
02299       UValue res;
02300       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) );
02301       return res;
02302     }
02303 
02304     private:
02305     boost::function2<R , P1 , P2 > fun;
02306   };
02307 
02308   template <class R, class P1 , class P2 >
02309   UGenericCallback*
02310   createUCallback(UObject& owner, UVar* target,
02311                   const std::string& type,
02312                   boost::function2<R , P1 , P2 > fun,
02313                   const std::string& funname,
02314                   impl::UContextImpl* ctx)
02315   {
02316     return new UBoostFunctionCallback2<R, P1 , P2 >
02317       (owner, target, type,fun,funname, ctx);
02318   }
02319 
02320 # ifdef ATTRIBUTE_STDCALL
02321   template <class R, class P1 , class P2 >
02322   UGenericCallback*
02323   createUCallbackStd(UObject& owner, UVar* target,
02324                      const std::string& type,
02325                      // MSVC wants it here.
02326                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 ),
02327                      const std::string& funname,
02328                      impl::UContextImpl* ctx)
02329   {
02330     return new UBoostFunctionCallback2<R , P1 , P2 >
02331       (owner, target, type,boost::function2<R , P1 , P2 >(fun),funname, ctx);
02332   }
02333 # endif
02334 
02335   template <class R, class P1 , class P2 , class P3 >
02336   class UBoostFunctionCallback3 : public UGenericCallback
02337   {
02338     public:
02339     UBoostFunctionCallback3(UObject& owner, UVar* target,
02340                   const std::string& type,
02341                   boost::function3<R , P1 , P2 , P3 > fun,
02342                   const std::string& funname,
02343                   impl::UContextImpl* ctx)
02344       : UGenericCallback(owner, target, type, funname,3, ctx),
02345       fun(fun)
02346     {
02347       nbparam = 3;
02348       registerCallback();
02349     }
02350 
02351     virtual UValue __evalcall(UList& param)
02352     {
02353       impl::UContextImpl::CleanupStack s_(*ctx_);
02354       LIBPORT_USE(param);
02355       UValue res;
02356       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) );
02357       return res;
02358     }
02359 
02360     private:
02361     boost::function3<R , P1 , P2 , P3 > fun;
02362   };
02363 
02364   template <class R, class P1 , class P2 , class P3 >
02365   UGenericCallback*
02366   createUCallback(UObject& owner, UVar* target,
02367                   const std::string& type,
02368                   boost::function3<R , P1 , P2 , P3 > fun,
02369                   const std::string& funname,
02370                   impl::UContextImpl* ctx)
02371   {
02372     return new UBoostFunctionCallback3<R, P1 , P2 , P3 >
02373       (owner, target, type,fun,funname, ctx);
02374   }
02375 
02376 # ifdef ATTRIBUTE_STDCALL
02377   template <class R, class P1 , class P2 , class P3 >
02378   UGenericCallback*
02379   createUCallbackStd(UObject& owner, UVar* target,
02380                      const std::string& type,
02381                      // MSVC wants it here.
02382                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 ),
02383                      const std::string& funname,
02384                      impl::UContextImpl* ctx)
02385   {
02386     return new UBoostFunctionCallback3<R , P1 , P2 , P3 >
02387       (owner, target, type,boost::function3<R , P1 , P2 , P3 >(fun),funname, ctx);
02388   }
02389 # endif
02390 
02391   template <class R, class P1 , class P2 , class P3 , class P4 >
02392   class UBoostFunctionCallback4 : public UGenericCallback
02393   {
02394     public:
02395     UBoostFunctionCallback4(UObject& owner, UVar* target,
02396                   const std::string& type,
02397                   boost::function4<R , P1 , P2 , P3 , P4 > fun,
02398                   const std::string& funname,
02399                   impl::UContextImpl* ctx)
02400       : UGenericCallback(owner, target, type, funname,4, ctx),
02401       fun(fun)
02402     {
02403       nbparam = 4;
02404       registerCallback();
02405     }
02406 
02407     virtual UValue __evalcall(UList& param)
02408     {
02409       impl::UContextImpl::CleanupStack s_(*ctx_);
02410       LIBPORT_USE(param);
02411       UValue res;
02412       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) );
02413       return res;
02414     }
02415 
02416     private:
02417     boost::function4<R , P1 , P2 , P3 , P4 > fun;
02418   };
02419 
02420   template <class R, class P1 , class P2 , class P3 , class P4 >
02421   UGenericCallback*
02422   createUCallback(UObject& owner, UVar* target,
02423                   const std::string& type,
02424                   boost::function4<R , P1 , P2 , P3 , P4 > fun,
02425                   const std::string& funname,
02426                   impl::UContextImpl* ctx)
02427   {
02428     return new UBoostFunctionCallback4<R, P1 , P2 , P3 , P4 >
02429       (owner, target, type,fun,funname, ctx);
02430   }
02431 
02432 # ifdef ATTRIBUTE_STDCALL
02433   template <class R, class P1 , class P2 , class P3 , class P4 >
02434   UGenericCallback*
02435   createUCallbackStd(UObject& owner, UVar* target,
02436                      const std::string& type,
02437                      // MSVC wants it here.
02438                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 ),
02439                      const std::string& funname,
02440                      impl::UContextImpl* ctx)
02441   {
02442     return new UBoostFunctionCallback4<R , P1 , P2 , P3 , P4 >
02443       (owner, target, type,boost::function4<R , P1 , P2 , P3 , P4 >(fun),funname, ctx);
02444   }
02445 # endif
02446 
02447   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 >
02448   class UBoostFunctionCallback5 : public UGenericCallback
02449   {
02450     public:
02451     UBoostFunctionCallback5(UObject& owner, UVar* target,
02452                   const std::string& type,
02453                   boost::function5<R , P1 , P2 , P3 , P4 , P5 > fun,
02454                   const std::string& funname,
02455                   impl::UContextImpl* ctx)
02456       : UGenericCallback(owner, target, type, funname,5, ctx),
02457       fun(fun)
02458     {
02459       nbparam = 5;
02460       registerCallback();
02461     }
02462 
02463     virtual UValue __evalcall(UList& param)
02464     {
02465       impl::UContextImpl::CleanupStack s_(*ctx_);
02466       LIBPORT_USE(param);
02467       UValue res;
02468       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) );
02469       return res;
02470     }
02471 
02472     private:
02473     boost::function5<R , P1 , P2 , P3 , P4 , P5 > fun;
02474   };
02475 
02476   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 >
02477   UGenericCallback*
02478   createUCallback(UObject& owner, UVar* target,
02479                   const std::string& type,
02480                   boost::function5<R , P1 , P2 , P3 , P4 , P5 > fun,
02481                   const std::string& funname,
02482                   impl::UContextImpl* ctx)
02483   {
02484     return new UBoostFunctionCallback5<R, P1 , P2 , P3 , P4 , P5 >
02485       (owner, target, type,fun,funname, ctx);
02486   }
02487 
02488 # ifdef ATTRIBUTE_STDCALL
02489   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 >
02490   UGenericCallback*
02491   createUCallbackStd(UObject& owner, UVar* target,
02492                      const std::string& type,
02493                      // MSVC wants it here.
02494                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 , P5 ),
02495                      const std::string& funname,
02496                      impl::UContextImpl* ctx)
02497   {
02498     return new UBoostFunctionCallback5<R , P1 , P2 , P3 , P4 , P5 >
02499       (owner, target, type,boost::function5<R , P1 , P2 , P3 , P4 , P5 >(fun),funname, ctx);
02500   }
02501 # endif
02502 
02503   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >
02504   class UBoostFunctionCallback6 : public UGenericCallback
02505   {
02506     public:
02507     UBoostFunctionCallback6(UObject& owner, UVar* target,
02508                   const std::string& type,
02509                   boost::function6<R , P1 , P2 , P3 , P4 , P5 , P6 > fun,
02510                   const std::string& funname,
02511                   impl::UContextImpl* ctx)
02512       : UGenericCallback(owner, target, type, funname,6, ctx),
02513       fun(fun)
02514     {
02515       nbparam = 6;
02516       registerCallback();
02517     }
02518 
02519     virtual UValue __evalcall(UList& param)
02520     {
02521       impl::UContextImpl::CleanupStack s_(*ctx_);
02522       LIBPORT_USE(param);
02523       UValue res;
02524       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) );
02525       return res;
02526     }
02527 
02528     private:
02529     boost::function6<R , P1 , P2 , P3 , P4 , P5 , P6 > fun;
02530   };
02531 
02532   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >
02533   UGenericCallback*
02534   createUCallback(UObject& owner, UVar* target,
02535                   const std::string& type,
02536                   boost::function6<R , P1 , P2 , P3 , P4 , P5 , P6 > fun,
02537                   const std::string& funname,
02538                   impl::UContextImpl* ctx)
02539   {
02540     return new UBoostFunctionCallback6<R, P1 , P2 , P3 , P4 , P5 , P6 >
02541       (owner, target, type,fun,funname, ctx);
02542   }
02543 
02544 # ifdef ATTRIBUTE_STDCALL
02545   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 >
02546   UGenericCallback*
02547   createUCallbackStd(UObject& owner, UVar* target,
02548                      const std::string& type,
02549                      // MSVC wants it here.
02550                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 , P5 , P6 ),
02551                      const std::string& funname,
02552                      impl::UContextImpl* ctx)
02553   {
02554     return new UBoostFunctionCallback6<R , P1 , P2 , P3 , P4 , P5 , P6 >
02555       (owner, target, type,boost::function6<R , P1 , P2 , P3 , P4 , P5 , P6 >(fun),funname, ctx);
02556   }
02557 # endif
02558 
02559   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >
02560   class UBoostFunctionCallback7 : public UGenericCallback
02561   {
02562     public:
02563     UBoostFunctionCallback7(UObject& owner, UVar* target,
02564                   const std::string& type,
02565                   boost::function7<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 > fun,
02566                   const std::string& funname,
02567                   impl::UContextImpl* ctx)
02568       : UGenericCallback(owner, target, type, funname,7, ctx),
02569       fun(fun)
02570     {
02571       nbparam = 7;
02572       registerCallback();
02573     }
02574 
02575     virtual UValue __evalcall(UList& param)
02576     {
02577       impl::UContextImpl::CleanupStack s_(*ctx_);
02578       LIBPORT_USE(param);
02579       UValue res;
02580       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) );
02581       return res;
02582     }
02583 
02584     private:
02585     boost::function7<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 > fun;
02586   };
02587 
02588   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >
02589   UGenericCallback*
02590   createUCallback(UObject& owner, UVar* target,
02591                   const std::string& type,
02592                   boost::function7<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 > fun,
02593                   const std::string& funname,
02594                   impl::UContextImpl* ctx)
02595   {
02596     return new UBoostFunctionCallback7<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 >
02597       (owner, target, type,fun,funname, ctx);
02598   }
02599 
02600 # ifdef ATTRIBUTE_STDCALL
02601   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 >
02602   UGenericCallback*
02603   createUCallbackStd(UObject& owner, UVar* target,
02604                      const std::string& type,
02605                      // MSVC wants it here.
02606                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 , P5 , P6 , P7 ),
02607                      const std::string& funname,
02608                      impl::UContextImpl* ctx)
02609   {
02610     return new UBoostFunctionCallback7<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 >
02611       (owner, target, type,boost::function7<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 >(fun),funname, ctx);
02612   }
02613 # endif
02614 
02615   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >
02616   class UBoostFunctionCallback8 : public UGenericCallback
02617   {
02618     public:
02619     UBoostFunctionCallback8(UObject& owner, UVar* target,
02620                   const std::string& type,
02621                   boost::function8<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 > fun,
02622                   const std::string& funname,
02623                   impl::UContextImpl* ctx)
02624       : UGenericCallback(owner, target, type, funname,8, ctx),
02625       fun(fun)
02626     {
02627       nbparam = 8;
02628       registerCallback();
02629     }
02630 
02631     virtual UValue __evalcall(UList& param)
02632     {
02633       impl::UContextImpl::CleanupStack s_(*ctx_);
02634       LIBPORT_USE(param);
02635       UValue res;
02636       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) );
02637       return res;
02638     }
02639 
02640     private:
02641     boost::function8<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 > fun;
02642   };
02643 
02644   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >
02645   UGenericCallback*
02646   createUCallback(UObject& owner, UVar* target,
02647                   const std::string& type,
02648                   boost::function8<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 > fun,
02649                   const std::string& funname,
02650                   impl::UContextImpl* ctx)
02651   {
02652     return new UBoostFunctionCallback8<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 >
02653       (owner, target, type,fun,funname, ctx);
02654   }
02655 
02656 # ifdef ATTRIBUTE_STDCALL
02657   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 >
02658   UGenericCallback*
02659   createUCallbackStd(UObject& owner, UVar* target,
02660                      const std::string& type,
02661                      // MSVC wants it here.
02662                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 ),
02663                      const std::string& funname,
02664                      impl::UContextImpl* ctx)
02665   {
02666     return new UBoostFunctionCallback8<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 >
02667       (owner, target, type,boost::function8<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 >(fun),funname, ctx);
02668   }
02669 # endif
02670 
02671   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >
02672   class UBoostFunctionCallback9 : public UGenericCallback
02673   {
02674     public:
02675     UBoostFunctionCallback9(UObject& owner, UVar* target,
02676                   const std::string& type,
02677                   boost::function9<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 > fun,
02678                   const std::string& funname,
02679                   impl::UContextImpl* ctx)
02680       : UGenericCallback(owner, target, type, funname,9, ctx),
02681       fun(fun)
02682     {
02683       nbparam = 9;
02684       registerCallback();
02685     }
02686 
02687     virtual UValue __evalcall(UList& param)
02688     {
02689       impl::UContextImpl::CleanupStack s_(*ctx_);
02690       LIBPORT_USE(param);
02691       UValue res;
02692       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) );
02693       return res;
02694     }
02695 
02696     private:
02697     boost::function9<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 > fun;
02698   };
02699 
02700   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >
02701   UGenericCallback*
02702   createUCallback(UObject& owner, UVar* target,
02703                   const std::string& type,
02704                   boost::function9<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 > fun,
02705                   const std::string& funname,
02706                   impl::UContextImpl* ctx)
02707   {
02708     return new UBoostFunctionCallback9<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 >
02709       (owner, target, type,fun,funname, ctx);
02710   }
02711 
02712 # ifdef ATTRIBUTE_STDCALL
02713   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 >
02714   UGenericCallback*
02715   createUCallbackStd(UObject& owner, UVar* target,
02716                      const std::string& type,
02717                      // MSVC wants it here.
02718                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 ),
02719                      const std::string& funname,
02720                      impl::UContextImpl* ctx)
02721   {
02722     return new UBoostFunctionCallback9<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 >
02723       (owner, target, type,boost::function9<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 >(fun),funname, ctx);
02724   }
02725 # endif
02726 
02727   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >
02728   class UBoostFunctionCallback10 : public UGenericCallback
02729   {
02730     public:
02731     UBoostFunctionCallback10(UObject& owner, UVar* target,
02732                   const std::string& type,
02733                   boost::function10<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 > fun,
02734                   const std::string& funname,
02735                   impl::UContextImpl* ctx)
02736       : UGenericCallback(owner, target, type, funname,10, ctx),
02737       fun(fun)
02738     {
02739       nbparam = 10;
02740       registerCallback();
02741     }
02742 
02743     virtual UValue __evalcall(UList& param)
02744     {
02745       impl::UContextImpl::CleanupStack s_(*ctx_);
02746       LIBPORT_USE(param);
02747       UValue res;
02748       res(), fun( uvar_uvalue_cast<P1>(param[1 - 1]) , uvar_uvalue_cast<P2>(param[2 - 1]) , uvar_uvalue_cast<P3>(param[3 - 1]) , uvar_uvalue_cast<P4>(param[4 - 1]) , uvar_uvalue_cast<P5>(param[5 - 1]) , uvar_uvalue_cast<P6>(param[6 - 1]) , uvar_uvalue_cast<P7>(param[7 - 1]) , uvar_uvalue_cast<P8>(param[8 - 1]) , uvar_uvalue_cast<P9>(param[9 - 1]) , uvar_uvalue_cast<P10>(param[10 - 1]) );
02749       return res;
02750     }
02751 
02752     private:
02753     boost::function10<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 > fun;
02754   };
02755 
02756   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >
02757   UGenericCallback*
02758   createUCallback(UObject& owner, UVar* target,
02759                   const std::string& type,
02760                   boost::function10<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 > fun,
02761                   const std::string& funname,
02762                   impl::UContextImpl* ctx)
02763   {
02764     return new UBoostFunctionCallback10<R, P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 >
02765       (owner, target, type,fun,funname, ctx);
02766   }
02767 
02768 # ifdef ATTRIBUTE_STDCALL
02769   template <class R, class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 >
02770   UGenericCallback*
02771   createUCallbackStd(UObject& owner, UVar* target,
02772                      const std::string& type,
02773                      // MSVC wants it here.
02774                      R (ATTRIBUTE_STDCALL *fun)( P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 ),
02775                      const std::string& funname,
02776                      impl::UContextImpl* ctx)
02777   {
02778     return new UBoostFunctionCallback10<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 >
02779       (owner, target, type,boost::function10<R , P1 , P2 , P3 , P4 , P5 , P6 , P7 , P8 , P9 , P10 >(fun),funname, ctx);
02780   }
02781 # endif
02782 } // end namespace urbi
02783 
02784 #endif // ! URBI_UCALLBACKS_HH
02785