The reason for Pyste is the built-in code generator of Boost. Python.

Source: Internet
Author: User

Do you have any knowledge about the practical use of Pyste in functions? In fact, Pyste is very similar to SWIG, and relevant source files can be written in C ++-related forms. The following article mainly introduces how Pyste is in Boost. python built-in code generator.

You only need to write the corresponding interface file to generate the corresponding code. Pyste must be installed before it can be used. Go to the Boost installation directory, run the "/libs/python/pyste/install" directory, and run python setup. py install to complete Pyste installation.

Because Pyste requires GCC-XML support, you need to go to the GCC-XML's official website to download the Windows version of GCC-XML. After installing the GCC-XML, you need to add its installation PATH to the system PATH variable. In addition, Pyste also requires support for ElementTree, so you need to download and install it on the relevant official network.

Compile the header file "Num. h" as shown below ".

 
 
  1. class Num  
  2. {  
  3. int value;  
  4. void set( int n )  
  5. {  
  6. value = n;  
  7. }  
  8. int get()  
  9. {  
  10. return value;  
  11. }   
  12. };   

Write the following interface file "world. pyste ".

 
 
  1. Class("Num", "Num.h") 

Due to the file path problem in Windows, it is best to put Pyste in the directory where "Num. h" and "world. pyste" are located. In the Windows command line, enter its directory and run the following command.

 
 
  1. python pyste.py --module=num world.pyste 

The "num. cpp" file is generated after running commands for Boost. Python-related code. The content of the file is as follows.

 
 
  1. // Boost Includes ===================================
    ===========================  
  2. #include <boost/python.hpp> 
  3. #include <boost/cstdint.hpp> 
  4. // Includes =====================================
    ===============================  
  5. #include <Num.h> 
  6. // Using ======================================
    =================================  
  7. using namespace boost::python;  
  8. // Module =================================
    =====================================  
  9. BOOST_PYTHON_MODULE(num)  
  10. {  
  11. class_< Num >("Num", init< >())  
  12. .def(init< const Num& >())  
  13. ;  
  14. }   

The above is an introduction to the reasons why Pyste is a Boost. Python built-in code generator. I hope you will gain some benefits.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.