merge
This commit is contained in:
commit
3b9f2c560a
11 files changed
+209
-1
No files matched your search
@@ -0,0 +1,19 @@
|
||||
#include "g.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void GDoA (void)
|
||||
{
|
||||
std::cout << "GDoA" << std::endl;
|
||||
}
|
||||
|
||||
void G::GDoB (void)
|
||||
{
|
||||
std::cout << "G::GDoB" << std::endl;
|
||||
}
|
||||
|
||||
void G::GInner::GDoC (void)
|
||||
{
|
||||
std::cout << "G::Inner::GDoC" << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
void GDoA (void);
|
||||
|
||||
namespace G
|
||||
{
|
||||
|
||||
void GDoB (void);
|
||||
|
||||
namespace GInner {
|
||||
|
||||
void GDoC (void);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import sys
|
||||
sys.path.insert(0, "../../build/default/examples/g")
|
||||
from g import *
|
||||
from g.G import GDoB
|
||||
from g.G.GInner import GDoC
|
||||
|
||||
GDoA()
|
||||
G.GDoB()
|
||||
GDoB()
|
||||
G.GInner.GDoC()
|
||||
GDoC()
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
import pybindgen
|
||||
from pybindgen import (ReturnValue, Parameter, Module, Function, FileCodeSink)
|
||||
|
||||
def my_module_gen(out_file):
|
||||
pybindgen.write_preamble(FileCodeSink(out_file))
|
||||
|
||||
mod = Module('g')
|
||||
mod.add_include('"g.h"')
|
||||
|
||||
mod.add_function(Function(ReturnValue.new('void'), 'GDoA', []))
|
||||
G = mod.add_cpp_namespace("G")
|
||||
G.add_function(Function(ReturnValue.new('void'), 'GDoB', []))
|
||||
GInner = G.add_cpp_namespace("GInner")
|
||||
GInner.add_function(Function(ReturnValue.new('void'), 'GDoC', []))
|
||||
|
||||
mod.generate(FileCodeSink(out_file))
|
||||
|
||||
if __name__ == '__main__':
|
||||
my_module_gen(sys.stdout)
|
||||
@@ -0,0 +1,30 @@
|
||||
## -*- python -*-
|
||||
import Params
|
||||
|
||||
def create_pyext_obj(bld, c_or_cpp_type):
|
||||
waf_version = [int (s) for s in Params.g_version.split('.')]
|
||||
if waf_version >= [1,4]:
|
||||
return bld.create_obj(c_or_cpp_type, 'shlib', 'pyext')
|
||||
else:
|
||||
return bld.create_obj(c_or_cpp_type, 'plugin', 'pyext')
|
||||
|
||||
|
||||
def build(bld):
|
||||
## manual code generation using simple pybindgen API calls
|
||||
bindgen = bld.create_obj('command-output')
|
||||
bindgen.stdout = 'gmodule.cc'
|
||||
bindgen.argv = [bindgen.input_file('modulegen.py')]
|
||||
bindgen.command = bindgen.env['PYTHON']
|
||||
bindgen.command_is_external = True
|
||||
bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen
|
||||
|
||||
obj = create_pyext_obj(bld, 'cpp')
|
||||
obj.source = [
|
||||
'g.cc',
|
||||
'gmodule.cc'
|
||||
]
|
||||
obj.target = 'g'
|
||||
obj.inst_var = 0 # do not install
|
||||
|
||||
## Workaround a WAF bug (http://code.google.com/p/waf/issues/detail?id=37)
|
||||
obj.env.append_value("CPPPATH", bld.m_curdirnode.srcpath(obj.env))
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "h.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void H::Do (void)
|
||||
{
|
||||
std::cout << "H::Do" << std::endl;
|
||||
}
|
||||
|
||||
void H::Inner::Do (void)
|
||||
{
|
||||
std::cout << "H::Inner::Do" << std::endl;
|
||||
}
|
||||
|
||||
void H::Inner::MostInner::Do (void)
|
||||
{
|
||||
std::cout << "H::Inner::MostInner::Do" << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
class H
|
||||
{
|
||||
public:
|
||||
void Do (void);
|
||||
class Inner
|
||||
{
|
||||
public:
|
||||
void Do (void);
|
||||
|
||||
class MostInner
|
||||
{
|
||||
public:
|
||||
void Do (void);
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import sys
|
||||
sys.path.insert(0, "../../build/default/examples/h")
|
||||
from h import *
|
||||
|
||||
h = H()
|
||||
h.Do()
|
||||
inner = H.Inner()
|
||||
inner.Do()
|
||||
most_inner = H.Inner.MostInner()
|
||||
most_inner.Do()
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
import pybindgen
|
||||
from pybindgen import (ReturnValue, Parameter, Module, CppClass, CppMethod, CppConstructor, FileCodeSink)
|
||||
|
||||
def my_module_gen(out_file):
|
||||
pybindgen.write_preamble(FileCodeSink(out_file))
|
||||
|
||||
mod = Module('h')
|
||||
mod.add_include('"h.h"')
|
||||
|
||||
H = CppClass('H')
|
||||
mod.add_class(H)
|
||||
H.add_constructor(CppConstructor([]))
|
||||
H.add_method(CppMethod(ReturnValue.new('void'), 'Do', []))
|
||||
|
||||
Inner = CppClass('Inner', outer_class=H)
|
||||
mod.add_class(Inner)
|
||||
Inner.add_constructor(CppConstructor([]))
|
||||
Inner.add_method(CppMethod (ReturnValue.new('void'), 'Do', []))
|
||||
|
||||
MostInner = CppClass('MostInner', outer_class=Inner)
|
||||
mod.add_class (MostInner)
|
||||
MostInner.add_constructor (CppConstructor([]))
|
||||
MostInner.add_method (CppMethod (ReturnValue.new('void'), 'Do', []))
|
||||
|
||||
mod.generate(FileCodeSink(out_file))
|
||||
|
||||
if __name__ == '__main__':
|
||||
my_module_gen(sys.stdout)
|
||||
@@ -0,0 +1,30 @@
|
||||
## -*- python -*-
|
||||
import Params
|
||||
|
||||
def create_pyext_obj(bld, c_or_cpp_type):
|
||||
waf_version = [int (s) for s in Params.g_version.split('.')]
|
||||
if waf_version >= [1,4]:
|
||||
return bld.create_obj(c_or_cpp_type, 'shlib', 'pyext')
|
||||
else:
|
||||
return bld.create_obj(c_or_cpp_type, 'plugin', 'pyext')
|
||||
|
||||
|
||||
def build(bld):
|
||||
## manual code generation using simple pybindgen API calls
|
||||
bindgen = bld.create_obj('command-output')
|
||||
bindgen.stdout = 'hmodule.cc'
|
||||
bindgen.argv = [bindgen.input_file('modulegen.py')]
|
||||
bindgen.command = bindgen.env['PYTHON']
|
||||
bindgen.command_is_external = True
|
||||
bindgen.prio = 55 # must run after the 'py' objects in ../pybindgen
|
||||
|
||||
obj = create_pyext_obj(bld, 'cpp')
|
||||
obj.source = [
|
||||
'h.cc',
|
||||
'hmodule.cc'
|
||||
]
|
||||
obj.target = 'h'
|
||||
obj.inst_var = 0 # do not install
|
||||
|
||||
## Workaround a WAF bug (http://code.google.com/p/waf/issues/detail?id=37)
|
||||
obj.env.append_value("CPPPATH", bld.m_curdirnode.srcpath(obj.env))
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
## -*- python -*-
|
||||
|
||||
def build(bld):
|
||||
bld.add_subdirs('a b c d e f')
|
||||
bld.add_subdirs('a b c d e f g h')
|
||||
|
||||
Reference in new issue
Block a user