Add the 'a' example from Mathieu

This commit is contained in:
Gustavo J. A. M. Carneiro committed 2008-04-28 12:49:30 +01:00
1 parent 81b4f530b8
commit 6c5f4f3c0b
6 files changed
+88 -1

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#include "a.h"
#include <iostream>
void ADoA (void)
{
std::cout << "ADoA" << std::endl;
}
void ADoB (uint32_t b)
{
std::cout << "ADoB=" << b << std::endl;
}
uint32_t ADoC (void)
{
std::cout << "ADoC" << std::endl;
return 1;
}
+7
View File
@@ -0,0 +1,7 @@
#include <stdint.h>
void ADoA (void);
void ADoB (uint32_t b);
uint32_t ADoC (void);
+9
View File
@@ -0,0 +1,9 @@
import sys
sys.path.insert(0, "../../build/default/examples/a")
from a import *
ADoA ()
ADoB (1)
a = ADoC ()
print a
+23
View File
@@ -0,0 +1,23 @@
#! /usr/bin/env python
import sys
import pybindgen
from pybindgen import (ReturnValue, Parameter, Module, Function, FileCodeSink)
from pybindgen import (CppMethod, CppConstructor, CppClass, Enum)
def my_module_gen(out_file):
pybindgen.write_preamble(FileCodeSink(out_file))
print >> out_file, "#include \"a.h\""
mod = Module('a')
mod.add_function(Function(ReturnValue.new('void'), 'ADoA', []))
mod.add_function(Function(ReturnValue.new('void'), 'ADoB', [Parameter.new('uint32_t', 'b')]))
mod.add_function(Function(ReturnValue.new('uint32_t'), 'ADoC', []))
mod.generate(FileCodeSink(out_file) )
if __name__ == '__main__':
my_module_gen(sys.stdout)
+30
View File
@@ -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 = 'amodule.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 = [
'a.cc',
'amodule.cc'
]
obj.target = 'a'
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
View File
@@ -1,5 +1,5 @@
## -*- python -*-
def build(bld):
pass # TODO
bld.add_subdirs('a')