~ubuntu-branches/ubuntu/trusty/pysvn/trusty

« back to all changes in this revision

Viewing changes to Import/pycxx-6.2.2/Demo/Python2/pycxx_iter.cxx

  • Committer: Package Import Robot
  • Author(s): Hideki Yamane
  • Date: 2012-07-19 04:23:27 UTC
  • mfrom: (0.1.8)
  • Revision ID: package-import@ubuntu.com-20120719042327-y2kza1fve3tqrvzb
Tags: 1.7.6-0.1
* Non-maintainer upload
* Upload to experimental, we're now freeze time and it may break other 
  package, so checking reverse dependency packages is needed to put it
  to unstable.
* New upstream release
  - works with subversion1.7 (Closes: #678559)
* debian/control
  - add "Build-Depends: libaprutil1-dev" to provide apu.h file.
* debian/rules
  - specify "--apu-inc-dir" option to find apu.h.
  - enable --norpath option to avoid "binary-or-shlib-defines-rpath" lintain
    error
* debian/patches
  - refresh it, meet to new upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "pycxx_iter.hxx"
2
 
#include "CXX/Objects.hxx"
3
 
 
4
 
void IterT::init_type()
5
 
{
6
 
    behaviors().name("IterT");
7
 
    behaviors().doc("IterT(ini_count)");
8
 
    // you must have overwritten the virtual functions
9
 
    // Py::Object iter() and Py::Object iternext()
10
 
    behaviors().supportIter();    // set entries in the Type Table
11
 
    behaviors().supportRepr();
12
 
    add_varargs_method("reversed",&IterT::reversed,"reversed()");
13
 
}
14
 
 
15
 
class MyIterModule : public Py::ExtensionModule<MyIterModule>
16
 
{
17
 
 
18
 
public:
19
 
    MyIterModule() : Py::ExtensionModule<MyIterModule>("pycxx_iter")
20
 
    {
21
 
        IterT::init_type();
22
 
        add_varargs_method("IterT",&MyIterModule::new_IterT,"IterT(from,last)");
23
 
        initialize("MyIterModule documentation"); // register with Python
24
 
    }
25
 
    
26
 
    virtual ~MyIterModule() {}
27
 
 
28
 
private:
29
 
    Py::Object new_IterT(const Py::Tuple& args)
30
 
    {
31
 
        if (args.length() != 2)
32
 
        {
33
 
            throw Py::RuntimeError("Incorrect # of args to IterT(from,to).");
34
 
        }
35
 
        return Py::asObject(new IterT(Py::Int(args[0]),Py::Int(args[1])));
36
 
    }
37
 
};
38
 
 
39
 
#if defined( _WIN32 )
40
 
#define EXPORT_SYMBOL __declspec( dllexport )
41
 
#else
42
 
#define EXPORT_SYMBOL
43
 
#endif
44
 
 
45
 
extern "C" EXPORT_SYMBOL void initpycxx_iter()
46
 
{
47
 
    // the following constructor call registers our extension module
48
 
    // with the Python runtime system
49
 
    static MyIterModule* IterTest = new MyIterModule;
50
 
}