[C++-sig] templated classes in pyplusplus

Roman Yakovenko roman.yakovenko at gmail.com
Fri May 12 12:56:43 CEST 2006


On 5/11/06, Naceur.Meskini at sophia.inria.fr
<Naceur.Meskini at sophia.inria.fr> wrote:
> I'm trying to analyse the date_time example in order to do the same, but
> in vain, I also read all messages concerning templates in pyplusplus and I
> find out that you have said that there is many way to expose templated
> classes and one them is to use sizeof
> Can you please complete the explication of that, because I don't know how
> to use file_configuration_t

file_configuration_t is rather cool feature. When you create module_builder_t
class instance you should pass list of files. This list can contain
string( == file paths ) and/or instances of file_configuration_t
class.

file_configuration_t is class with fat interface.
It has 4 states:
   1. it could contain reference to source file.
        Use "create_source_fc" function to create an instance of
file_configuration_t

   2. it could contain reference to source file and xml file. In this
case if xml file
       exist, source file will not be parsed by gccxml. If xml file
does not exists, source
       file will be parsed and xml file will be saved for future use.
       See create_cached_source_fc function

   3. it could contain reference to xml file only
       See create_gccxml_fc

   4. it could contain some text. In this case, parser will create
temporal file on
       disk and will pass it as an argument to gccxml.
       See create_text_fc

In most cases you don't all those features. If I were you, I would
create regular
source file and put all template instantiation there.

Any way the code:

tmpl_inst = """
=====================
  #include "TempClass.h"

  namespace details{
     inline void export_templates(){
         sizeof( TempClass<int> );
     }
 }
"""
import module_builder
mb = module_builder.module_builder_t(
    [ module_builder.create_text_fc( tmpl_inst ) ]
    , .... )

> thanks

Do you understand it know?

> Naceur MESKINI.


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list