Update of /cvsroot/pygccxml/source/pyplusplus/docs/tutorials In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20656/pyplusplus/docs/tutorials Modified Files: module_builder.rest tutorials.rest Added Files: module_builder_generate_code.html module_builder_hello_world.html module_builder_hello_world_result.html Log Message: Documentation improvments --- NEW FILE: module_builder_hello_world.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>hello_world.hpp</title> <meta name="GENERATOR" content="SciTE - www.Scintilla.org" /> <style type="text/css"> .S0 { color: #808080; background: #FFFFFF; } .S2 { font-family: 'Courier New'; color: #007F00; background: #FFFFFF; font-size: 9pt; } .S3 { font-family: 'Courier New'; color: #3F703F; background: #FFFFFF; font-size: 9pt; } .S4 { color: #007F7F; background: #FFFFFF; } .S5 { font-weight: bold; color: #00007F; background: #FFFFFF; } .S6 { color: #7F007F; background: #FFFFFF; } .S9 { color: #7F7F00; background: #FFFFFF; } .S10 { font-weight: bold; color: #000000; background: #FFFFFF; } span { font-family: 'Courier New'; color: #000000; background: #FFFFFF; font-size: 10pt; } </style> </head> <body bgcolor="#FFFFFF"> <span><span class="S2">// Copyright 2004 Roman Yakovenko.</span><br /> <span class="S2">// Distributed under the Boost Software License, Version 1.0. (See</span><br /> <span class="S2">// accompanying file LICENSE_1_0.txt or copy at</span><br /> <span class="S2">// http://www.boost.org/LICENSE_1_0.txt)</span><br /> <br /> <span class="S9">#ifndef __hello_world_hpp__</span><br /> <span class="S9">#define __hello_world_hpp__</span><br /> <br /> <span class="S9">#include <string></span><br /> <br /> <span class="S2">//I want to rename color to Color</span><br /> <span class="S5">enum</span><span class="S0"> </span>color<span class="S10">{</span><span class="S0"> </span>red<span class="S10">,</span><span class="S0"> </span>green<span class="S10">,</span><span class="S0"> </span>blue<span class="S0"> </span><span class="S10">};</span><br /> <br /> <span class="S5">struct</span><span class="S0"> </span>animal<span class="S10">{</span><br /> <span class="S0"> </span><br /> <span class="S0"> </span>animal<span class="S10">(</span><span class="S0"> </span><span class="S5">const</span><span class="S0"> </span>std<span class="S10">::</span>string<span class="S10">&</span><span class="S0"> </span>name<span class="S10">=</span><span class="S6">""</span><span class="S0"> </span><span class="S10">)</span><br /> <span class="S0"> </span><span class="S10">:</span><span class="S0"> </span>m_name<span class="S10">(</span><span class="S0"> </span>name<span class="S0"> </span><span class="S10">)</span><br /> <span class="S0"> </span><span class="S10">{}</span><br /> <span class="S0"> </span><br /> <span class="S0"> </span><span class="S2">//I need to set call policies to the function</span><br /> <span class="S0"> </span><span class="S5">const</span><span class="S0"> </span>std<span class="S10">::</span>string<span class="S10">*</span><span class="S0"> </span>get_name_ptr<span class="S10">()</span><span class="S0"> </span><span class="S5">const</span><br /> <span class="S0"> </span><span class="S10">{</span><span class="S0"> </span><span class="S5">return</span><span class="S0"> </span><span class="S10">&</span>m_name<span class="S10">;</span><span class="S0"> </span><span class="S10">}</span><br /> <br /> <span class="S0"> </span><span class="S5">const</span><span class="S0"> </span>std<span class="S10">::</span>string<span class="S10">&</span><span class="S0"> </span>name<span class="S10">()</span><span class="S0"> </span><span class="S5">const</span><br /> <span class="S0"> </span><span class="S10">{</span><span class="S0"> </span><span class="S5">return</span><span class="S0"> </span>m_name<span class="S10">;</span><span class="S0"> </span><span class="S10">}</span><br /> <span class="S0"> </span><br /> <span class="S5">private</span><span class="S10">:</span><span class="S0"> </span><br /> <span class="S0"> </span>std<span class="S10">::</span>string<span class="S0"> </span>m_name<span class="S10">;</span><br /> <br /> <span class="S10">};</span><br /> <br /> <span class="S2">//I want to exclude next declarations:</span><br /> <span class="S5">struct</span><span class="S0"> </span>impl1<span class="S10">{};</span><br /> <span class="S5">struct</span><span class="S0"> </span>impl2<span class="S10">{};</span><br /> <br /> <span class="S5">inline</span><span class="S0"> </span><span class="S5">int</span><span class="S10">*</span><span class="S0"> </span>get_int_ptr<span class="S10">(){</span><span class="S0"> </span><span class="S5">return</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;}</span><span class="S0"> </span><br /> <span class="S5">inline</span><span class="S0"> </span><span class="S5">int</span><span class="S10">*</span><span class="S0"> </span>get_int_ptr<span class="S10">(</span><span class="S5">int</span><span class="S10">){</span><span class="S0"> </span><span class="S5">return</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;}</span><br /> <span class="S5">inline</span><span class="S0"> </span><span class="S5">int</span><span class="S10">*</span><span class="S0"> </span>get_int_ptr<span class="S10">(</span><span class="S5">double</span><span class="S10">){</span><span class="S0"> </span><span class="S5">return</span><span class="S0"> </span><span class="S4">0</span><span class="S10">;}</span><br /> <span class="S0"> </span><br /> <span class="S9">#endif</span><span class="S2">//__hello_world_hpp__</span><br /> <br /> <span class="S0"></span></span> </body> </html> Index: module_builder.rest =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/docs/tutorials/module_builder.rest,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** module_builder.rest 9 Apr 2006 05:17:15 -0000 1.2 --- module_builder.rest 12 Apr 2006 07:40:34 -0000 1.3 *************** *** 16,24 **** I guess you decided to try to use `pyplusplus`_ API. Good! So lets start. ! First of all take a look on two files: * `hello_world.hpp`_ - C++ source code, that we want to export to Python * `generate_code.py`_ - Python code, that uses `pyplusplus`_ to export declarations from the source file ! .. _`hello_world.hpp` : ./module_builder_hello_world.html .. _`generate_code.py` : ./module_builder_generate_code.html --- 16,26 ---- I guess you decided to try to use `pyplusplus`_ API. Good! So lets start. ! First of all please take a look on two files: ! * `hello_world.hpp`_ - C++ source code, that we want to export to Python + * `generate_code.py`_ - Python code, that uses `pyplusplus`_ to export declarations from the source file ! .. _`hello_world.hpp` : ./module_builder_hello_world.html .. _`generate_code.py` : ./module_builder_generate_code.html *************** *** 29,178 **** `pyplusplus`_ is built from a few packages, but there is only one package you ! should realy to be familiar with - ``module_builder``. The main purpose of this ! package is to provide simple and user friendly interface to `pyplusplus`_ ! internals. The main class within this package is ``module_builder_t``. The ! instance of this class will guide you through the whole process. Next few ! paragraphs will tell you more about this class. ------------------------- module_builder_t.__init__ ------------------------- - ``module_builder_t.__init__`` methods takes few arguments: - - 1. files - list of all C++ source files, that declarations from them you want - to export. - - - - - - - ! ----------------------------- ! Step 1: Read C++ declarations ! ----------------------------- ! During this step C++ source files are parsed and all declarations are read. ! `pyplusplus`_ is not involved in this step at all. You should use `pygccxml`_. ! Fortunately it is very easy to setup\\use `pygccxml`_: ! :: ! import os ! from pygccxml import parser ! from pygccxml import declarations ! from pyplusplus import code_creators ! from pyplusplus import module_creator ! from pyplusplus import file_writers ! class settings: ! gccxml_path = '/home/roman/gccxml/bin' ! working_dir = '/tmp' ! ! #configurating parser ! parser_config = parser.config_t( gccxml_path=settings.gccxml_path, working_directory=settings.working_dir ) ! ! #reading all declarations ! decls_all = parser.parse( ['hello_world.hpp'], parser_config ) ! ! #filtering declarations ! decls = declarations.filtering.by_location( decls_all, [settings.working_dir] ) ! `pygccxml`_ does not parse C++ files, but use `GCC-XML`_ to do the job. So, the ! first thing that you should do is to setup `GCC-XML`_ binary location. The only ! way to do it is to create ``parser.config_t`` class instance. ! ``parser.config_t.__init__`` method takes few arguments: ! * `GCC-XML`_ binary location ! * working directory, this will help `GCC-XML`_ to locate included files ! * list of additional include directories ! * list of defined\\undefined symbols ! * ..., please see documentation of `pygccxml`_ for more information ! Now, when we created configuration for parser, we can actually read all ! declarations from source files. Function ``parse`` of module ``parser`` will do ! it. It will read all declarations that are found in your file and files included ! from the file. This means, that variable ``decls_all`` contains some declarations, ! that we do not want to export. So there is a need to apply some filter. In my ! example I remove all declarations that have been defined in files, outside of ! our working directory. We finished this step. The result of this step is that ! we have a set of declarations that we want to export. ! --------------------------------- ! Step 2: Create code creators tree ! --------------------------------- ! During this step `pyplusplus`_ will create one or more code creator for every ! C++ declaration, that should be exported. At the end of this step ``module_t`` ! class instances is created. Lets see some code: :: ! #creating code creators tree ! extmodule = module_creator.create( decls=decls, module_name="hello_world",recursive=False ) ! ! What is going on? First of all this is a first time we actualy use `pyplusplus`_. ! `pyplusplus`_ contains a package, named ``module_creator`` that contains ! functionality that create code creator(s) for every declaration. In this case ! I want to export all declarations from ``decls`` list. I also set exported ! module name to "hello_world". The 3rd parameter needs more explanation. ! ``decls`` argument could be interpreted as ! ! * list of all declaration to be exported ! * list of top level declarations. all declarations should be exported ! recursively. ! In order to clarify the use of ``decls`` argument, argument ``recursive`` is used. ! In my case ``decls`` variable holds a list of all declarations that should be ! exported, so I set ``recursive`` to be ``False``. ! Actually, we finished this step. ! ------------------------------- ! Step 3: Customize code creators ! ------------------------------- ! This step is optional. Inspite of being "optional" this step allows you to change ! code before it has been generated. You can create and add custom code creatpors. ! Or you can modify an exising one. Or even more you can delete code creators. ! There are few function that will help you to locate desired code creator by ! different criterias. In my case I only want to set user defined directories. ! Thus allowing `pyplusplus`_ to generate nice( shorter ) include directives: ! :: ! extmodule.user_defined_directories.append( parser_config.working_directory ) ! That's all for this step. ! --------------------------- ! Step 4: Write code to files ! --------------------------- ! :: ! file_writers.write_file( extmodule, 'bindings.cpp' ) ! ! I think that code above is self explained. I write ``extmodule`` into ! ``bindings.cpp`` file. It is also possible to write ``extmodule`` into multiple ! files: ! :: ! file_writers.write_multiple_files( extmodule, '.' ) ! The code above split extension module source to few files. This is very useful ! option. It saves compilation time. - -------------- - Congratulation - -------------- - Congratulation! You've done. You can find the whole listing of the program within - CVS/pyplusplus/examples/tutorials. ! Enjoy. ! .. _`pyplusplus` : ./pyplusplus.html ! .. _`pygccxml` : ./../pygccxml/pygccxml.html .. _`boost.python`: http://www.boost.org/libs/python/doc/index.html .. _`SourceForge`: http://sourceforge.net/index.php --- 31,157 ---- `pyplusplus`_ is built from a few packages, but there is only one package you ! should realy to be familiar with - ``module_builder``. This module is some kind ! of facade to low level API. It provides simple and intuitive API. The main ! class within this package is ``module_builder_t``. The instance of this class will ! guide you through the whole process. Next few paragraphs will tell you more about ! this class. ------------------------- module_builder_t.__init__ ------------------------- + First of all, what is needed in order to creates an instance of the class? + ``module_builder_t.__init__`` methods takes few arguments: + 1. ``files`` - list of all C++ source files, that declarations from them you want + to export. This is the only required parameter. + + 2. ``gccxml_path`` - path to `GCC-XML`_ binary. If you don't supply this argument + `pygccxml`_ will look for it using your environment variable ``PATH``. + + There some other arguments: + * additional include directories + * [un]defined symbols ( macros ) + * declarations cache + * ... + Parsing of source files is done within this method. Post condition of this + method is - all declarations has been successfully extracted from the sources + files using the settings you provided. + -------------------------- + Declarations customization + -------------------------- + Not all declarations should be exported! Not every declaration could be exported + without human invocation! As you already saw from example, `pyplusplus`_ provides + simple and powerful declarations query interface. By default only declarations, + that belongs to files you have asked to parse and to files, that lies in the same + directories as parsed files, will be exported: + :: + project_root/ + details/ + impl_a.h + impl_b.h + include/ + a.h //includes impl_a.h + b.h //includes impl_b.h + all.h //includes a.h and b.h + mb = module_builder( [ 'all.h' ] ) + + All declarations that belongs to ``include`` directory will be signed as included + to exposing. All other declarations will be ignored. ! You can change this final set of exported declarations by calling ``exclude`` or ! ``include`` methods on declarations. ! Basically this is a second step of code generation process. During this step ! you could/should/may change `pyplusplus`_ defaults: ! * to rename exposed declarations ! * to include/exclude declarations ! * to set call policies ! * ... ! I think it is critical for beginers to see what is going on, right? ! ``module_builder_t`` class has ``print_declarations``_ method. You can print whole ! declarations tree or some specific declaration. Very convinient, very useful. ! ----------------------------------- ! module_builder_t build_code_creator ! ----------------------------------- ! Now it is a time to create module code creator. Do you remember, in inroduction ! to `pyplusplus`_, I told you that before writing code to disc, `pyplusplus`_ will ! create some kind of `AST`_. Well this is done by calling ! ``module_builder_t.build_code_creator`` function. Right now, the only important ! argument to the function is ``module_name``. Self explained, is it? ! What is the main value of code creators? Code creators allow you to modify ! code before it has been written to disk. For example one common requirement for ! open source projects it to have license text within every source file. You can ! do it with one line of code only: :: ! mb.code_creator.license = your license text ! After you call this function, I recommend you not to change declarations ! configuration. In most cases the change will take effect, in some cases it will ! not! ! This tutorials is not cover code creators and how you should work with them. ! I will write an other tutorial. ! .. _`AST`: http://en.wikipedia.org/wiki/Abstract_syntax_tree ! ----------------------------- ! module_builder_t.write_module ! ----------------------------- ! You have almost created your module. The last things left is to write module ! code to file(s). You can do it with ! * ``module_builder_t.write_module`` - you should provide file name, the code ! will be written in. ! * ``module_builder_t.split_module`` - you should provide directory name. ! For big projects it is a must to minimize compilation time. So `pyplusplus`_ ! splits your module source code to different files within the directory. ! ! ------ ! Result ! ------ ! `View generated file`_ ! .. _`View generated file` : ./module_builder_hello_world_result.html ! That's all. I hope you enjoyed. ! .. _`pyplusplus` : ./../pyplusplus.html ! .. _`pygccxml` : ./../../pygccxml/pygccxml.html .. _`boost.python`: http://www.boost.org/libs/python/doc/index.html .. _`SourceForge`: http://sourceforge.net/index.php Index: tutorials.rest =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/docs/tutorials/tutorials.rest,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tutorials.rest 9 Apr 2006 05:17:15 -0000 1.1 --- tutorials.rest 12 Apr 2006 07:40:34 -0000 1.2 *************** *** 49,54 **** methods as a property. ! .. _`pyplusplus` : ./pyplusplus.html ! .. _`pygccxml` : ./../pygccxml/pygccxml.html .. _`boost.python`: http://www.boost.org/libs/python/doc/index.html .. _`SourceForge`: http://sourceforge.net/index.php --- 49,54 ---- methods as a property. ! .. _`pyplusplus` : ./../pyplusplus.html ! .. _`pygccxml` : ./../../pygccxml/pygccxml.html .. _`boost.python`: http://www.boost.org/libs/python/doc/index.html .. _`SourceForge`: http://sourceforge.net/index.php --- NEW FILE: module_builder_generate_code.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>generate_code.py</title> <meta name="GENERATOR" content="SciTE - www.Scintilla.org" /> <style type="text/css"> .S0 { color: #808080; background: #FFFFFF; } .S1 { font-family: 'Courier New'; color: #007F00; background: #FFFFFF; font-size: 9pt; } .S4 { font-family: 'Courier New'; color: #7F007F; background: #FFFFFF; font-size: 10pt; } .S5 { font-weight: bold; color: #00007F; background: #FFFFFF; } .S10 { font-weight: bold; color: #000000; background: #FFFFFF; } .S12 { color: #7F7F7F; background: #FFFFFF; } span { font-family: 'Courier New'; color: #000000; background: #FFFFFF; font-size: 10pt; } </style> </head> <body bgcolor="#FFFFFF"> <span><span class="S1">#! /usr/bin/python</span><br /> <span class="S1"># Copyright 2004 Roman Yakovenko.</span><br /> <span class="S1"># Distributed under the Boost Software License, Version 1.0. (See</span><br /> <span class="S1"># accompanying file LICENSE_1_0.txt or copy at</span><br /> <span class="S1"># http://www.boost.org/LICENSE_1_0.txt)</span><br /> <br /> <span class="S5">import</span><span class="S0"> </span>os<br /> <span class="S5">from</span><span class="S0"> </span>environment<span class="S0"> </span><span class="S5">import</span><span class="S0"> </span>settings<br /> <span class="S5">from</span><span class="S0"> </span>pyplusplus<span class="S0"> </span><span class="S5">import</span><span class="S0"> </span>module_builder<br /> <br /> mb<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>module_builder<span class="S10">.</span>module_builder_t<span class="S10">(</span><br /> <span class="S0"> </span>files<span class="S10">=[</span><span class="S4">'hello_world.hpp'</span><span class="S10">]</span><br /> <span class="S0"> </span><span class="S10">,</span><span class="S0"> </span>gccxml_path<span class="S10">=</span>settings<span class="S10">.</span>gccxml_path<span class="S0"> </span><span class="S1">#path to gccxml executable</span><br /> <span class="S0"> </span><span class="S10">,</span><span class="S0"> </span>working_directory<span class="S10">=</span>settings<span class="S10">.</span>working_dir<span class="S0"> </span><span class="S10">)</span><span class="S0"> </span><span class="S1">#setting working directory for gccxml</span><br /> <br /> <span class="S1">#rename enum Color to color</span><br /> Color<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>mb<span class="S10">.</span>enum<span class="S10">(</span><span class="S0"> </span><span class="S4">'color'</span><span class="S0"> </span><span class="S10">)</span><br /> Color<span class="S10">.</span>rename<span class="S10">(</span><span class="S4">'Color'</span><span class="S10">)</span><br /> <br /> <span class="S1">#Set call policies to animal::get_name_ptr</span><br /> animal<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>mb<span class="S10">.</span>class_<span class="S10">(</span><span class="S0"> </span><span class="S4">'animal'</span><span class="S0"> </span><span class="S10">)</span><br /> get_name_ptr<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>animal<span class="S10">.</span>member_function<span class="S10">(</span><span class="S0"> </span><span class="S4">'get_name_ptr'</span><span class="S10">,</span><span class="S0"> </span>recursive<span class="S10">=</span>False<span class="S0"> </span><span class="S10">)</span><br /> get_name_ptr<span class="S10">.</span>call_policies<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>module_builder<span class="S10">.</span>call_policies<span class="S10">.</span>return_internal_reference<span class="S10">()</span><br /> <br /> <span class="S1">#next code has same effect</span><br /> get_name_ptr<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>mb<span class="S10">.</span>member_function<span class="S10">(</span><span class="S0"> </span><span class="S4">'get_name_ptr'</span><span class="S0"> </span><span class="S10">)</span><br /> get_name_ptr<span class="S10">.</span>call_policies<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>module_builder<span class="S10">.</span>call_policies<span class="S10">.</span>return_internal_reference<span class="S10">()</span><br /> <br /> <span class="S1">#I want to exclude all classes with name starts with impl</span><br /> impl_classes<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>mb<span class="S10">.</span>classes<span class="S10">(</span><span class="S0"> </span><span class="S5">lambda</span><span class="S0"> </span>decl<span class="S10">:</span><span class="S0"> </span>decl<span class="S10">.</span>name<span class="S10">.</span>startswith<span class="S10">(</span><span class="S0"> </span><span class="S4">'impl'</span><span class="S0"> </span><span class="S10">)</span><span class="S0"> </span><span class="S10">)</span><br /> impl_classes<span class="S10">.</span>exclude<span class="S10">()</span><br /> <br /> <span class="S1">#I want to exclude all functions that returns pointer to int</span><br /> ptr_to_int<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>mb<span class="S10">.</span>free_functions<span class="S10">(</span><span class="S0"> </span>return_type<span class="S10">=</span><span class="S4">'int *'</span><span class="S0"> </span><span class="S10">)</span><br /> ptr_to_int<span class="S10">.</span>exclude<span class="S10">()</span><br /> <br /> <span class="S1">#I can print declarations to see what is going on</span><br /> mb<span class="S10">.</span>print_declarations<span class="S10">()</span><br /> <br /> <span class="S1">#I can print single declaration</span><br /> mb<span class="S10">.</span>print_declarations<span class="S10">(</span><span class="S0"> </span>animal<span class="S0"> </span><span class="S10">)</span><br /> <br /> <span class="S1">#Now it is the time to give a name to our module</span><br /> mb<span class="S10">.</span>build_code_creator<span class="S10">(</span><span class="S0"> </span>module_name<span class="S10">=</span><span class="S4">'hw'</span><span class="S0"> </span><span class="S10">)</span><br /> <br /> <span class="S1">#It is common requirement in software world - each file should have license</span><br /> mb<span class="S10">.</span>code_creator<span class="S10">.</span>license<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span><span class="S4">'//Boost Software License( http://boost.org/more/license_info.html )'</span><br /> <br /> <span class="S1">#I don't want absolute includes within code</span><br /> mb<span class="S10">.</span>code_creator<span class="S10">.</span>user_defined_directories<span class="S10">.</span>append<span class="S10">(</span><span class="S0"> </span>settings<span class="S10">.</span>working_dir<span class="S0"> </span><span class="S10">)</span><br /> <br /> <span class="S1">#And finally we can write code to the disk</span><br /> mb<span class="S10">.</span>write_module<span class="S10">(</span><span class="S0"> </span>os<span class="S10">.</span>path<span class="S10">.</span>join<span class="S10">(</span><span class="S0"> </span>settings<span class="S10">.</span>working_dir<span class="S10">,</span><span class="S0"> </span><span class="S4">'hello_world.py.cpp'</span><span class="S0"> </span><span class="S10">)</span><span class="S0"> </span><span class="S10">)</span></span> </body> </html> --- NEW FILE: module_builder_hello_world_result.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>hello_world.py.cpp</title> <meta name="GENERATOR" content="SciTE - www.Scintilla.org" /> <style type="text/css"> .S0 { color: #808080; background: #FFFFFF; } .S2 { font-family: 'Courier New'; color: #007F00; background: #FFFFFF; font-size: 9pt; } .S4 { color: #007F7F; background: #FFFFFF; } .S5 { font-weight: bold; color: #00007F; background: #FFFFFF; } .S6 { color: #7F007F; background: #FFFFFF; } .S9 { color: #7F7F00; background: #FFFFFF; } .S10 { font-weight: bold; color: #000000; background: #FFFFFF; } span { font-family: 'Courier New'; color: #000000; background: #FFFFFF; font-size: 10pt; } </style> </head> <body bgcolor="#FFFFFF"> <span><span class="S2">// This file has been generated by pyplusplus.</span><br /> <br /> <span class="S2">//Boost Software License( http://boost.org/more/license_info.html )</span><br /> <br /> <span class="S2">// std directories: []</span><br /> <span class="S2">// user defined directories: ['d:\\pygccxml_sources\\source\\pyplusplus\\examples\\tutorials']</span><br /> <br /> <span class="S9">#include "boost/python.hpp"</span><br /> <br /> <span class="S9">#include "hello_world.hpp"</span><br /> <br /> <span class="S5">namespace</span><span class="S0"> </span>bp<span class="S0"> </span><span class="S10">=</span><span class="S0"> </span>boost<span class="S10">::</span>python<span class="S10">;</span><br /> <br /> BOOST_PYTHON_MODULE<span class="S10">(</span>hw<span class="S10">){</span><br /> <span class="S0"> </span>bp<span class="S10">::</span>enum_<span class="S10"><</span>color<span class="S10">>(</span><span class="S6">"Color"</span><span class="S10">)</span><br /> <span class="S0"> </span><span class="S10">.</span>value<span class="S10">(</span><span class="S6">"blue"</span><span class="S10">,</span><span class="S0"> </span>blue<span class="S10">)</span><br /> <span class="S0"> </span><span class="S10">.</span>value<span class="S10">(</span><span class="S6">"green"</span><span class="S10">,</span><span class="S0"> </span>green<span class="S10">)</span><br /> <span class="S0"> </span><span class="S10">.</span>value<span class="S10">(</span><span class="S6">"red"</span><span class="S10">,</span><span class="S0"> </span>red<span class="S10">)</span><br /> <span class="S0"> </span><span class="S10">.</span>export_values<span class="S10">()</span><br /> <span class="S0"> </span><span class="S10">;</span><br /> <br /> <span class="S0"> </span>bp<span class="S10">::</span>class_<span class="S10"><</span><span class="S0"> </span>animal<span class="S0"> </span><span class="S10">>(</span><span class="S0"> </span><span class="S6">"animal"</span><span class="S10">,</span><span class="S0"> </span>bp<span class="S10">::</span>init<span class="S10"><</span><span class="S0"> </span>bp<span class="S10">::</span>optional<span class="S10"><</span><span class="S0"> </span>std<span class="S10">::</span>string<span class="S0"> </span><span class="S5">const</span><span class="S0"> </span><span class="S10">&</span><span class="S0"> </span><span class="S10">></span><span class="S0"> </span><span class="S10">>((</span><span class="S0"> </span>bp<span class="S10">::</span>arg<span class="S10">(</span><span class="S6">"name"</span><span class="S10">)=</span><span class="S6">""</span><span class="S0"> </span><span class="S10">))</span><span class="S0"> </span><span class="S10">)</span><span class="S0"> </span><br /> <span class="S0"> </span><span class="S10">.</span>def<span class="S10">(</span><span class="S0"> </span><span class="S6">"get_name_ptr"</span><br /> <span class="S0"> </span><span class="S10">,</span><span class="S0"> </span><span class="S10">&</span>animal<span class="S10">::</span>get_name_ptr<br /> <span class="S0"> </span><span class="S10">,</span><span class="S0"> </span>bp<span class="S10">::</span>return_internal_reference<span class="S10"><</span><span class="S0"> </span><span class="S4">1</span><span class="S10">,</span><span class="S0"> </span>bp<span class="S10">::</span>default_call_policies<span class="S0"> </span><span class="S10">>()</span><span class="S0"> </span><span class="S10">)</span><span class="S0"> </span><br /> <span class="S0"> </span><span class="S10">.</span>def<span class="S10">(</span><span class="S0"> </span><span class="S6">"name"</span><br /> <span class="S0"> </span><span class="S10">,</span><span class="S0"> </span><span class="S10">&</span>animal<span class="S10">::</span>name<br /> <span class="S0"> </span><span class="S10">,</span><span class="S0"> </span>bp<span class="S10">::</span>return_value_policy<span class="S10"><</span><span class="S0"> </span>bp<span class="S10">::</span>copy_const_reference<span class="S10">,</span><span class="S0"> </span>bp<span class="S10">::</span>default_call_policies<span class="S0"> </span><span class="S10">>()</span><span class="S0"> </span><span class="S10">);</span><br /> <br /> <span class="S0"> </span>bp<span class="S10">::</span>implicitly_convertible<span class="S10"><</span><span class="S0"> </span>std<span class="S10">::</span>string<span class="S0"> </span><span class="S5">const</span><span class="S0"> </span><span class="S10">&,</span><span class="S0"> </span>animal<span class="S0"> </span><span class="S10">>();</span><br /> <span class="S10">}</span><br /> <span class="S0"></span></span> </body> </html> |