mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 18:12:43 +00:00
This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r17988]
This commit is contained in:
BIN
doc/PyConDC_2003/python_cpp_mix.jpg
Executable file
BIN
doc/PyConDC_2003/python_cpp_mix.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
43
pyste/example/operators.h
Normal file
43
pyste/example/operators.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace operators {
|
||||
|
||||
struct C
|
||||
{
|
||||
static double x;
|
||||
double value;
|
||||
|
||||
const C operator+(const C other) const
|
||||
{
|
||||
C c;
|
||||
c.value = value + other.value;
|
||||
return c;
|
||||
}
|
||||
operator int() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
double operator()()
|
||||
{
|
||||
return C::x;
|
||||
}
|
||||
|
||||
double operator()(double other)
|
||||
{
|
||||
return C::x + other;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
double C::x = 10;
|
||||
|
||||
const C operator*(const C& lhs, const C& rhs)
|
||||
{
|
||||
C c;
|
||||
c.value = lhs.value * rhs.value;
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
1
pyste/example/operators.pyste
Normal file
1
pyste/example/operators.pyste
Normal file
@@ -0,0 +1 @@
|
||||
Class('operators::C', 'operators.h')
|
||||
16
pyste/example/unions.h
Normal file
16
pyste/example/unions.h
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace unions {
|
||||
|
||||
class UnionTest
|
||||
{
|
||||
public:
|
||||
union // unions are not supported for now
|
||||
{
|
||||
int i;
|
||||
short s1;
|
||||
short s2;
|
||||
} mBad;
|
||||
|
||||
int mGood;
|
||||
};
|
||||
|
||||
}
|
||||
2
pyste/example/unions.pyste
Normal file
2
pyste/example/unions.pyste
Normal file
@@ -0,0 +1,2 @@
|
||||
UnionTest = Class('unions::UnionTest', 'unions.h')
|
||||
exclude(UnionTest.mBad)
|
||||
19
pyste/tests/build_pyste_nt.bat
Normal file
19
pyste/tests/build_pyste_nt.bat
Normal file
@@ -0,0 +1,19 @@
|
||||
@echo off
|
||||
setlocal
|
||||
set MODULE_NAME=%1
|
||||
set PYSTE_FILE=%2
|
||||
set BOOST_ROOT=d:/programming/libraries/boost-cvs
|
||||
set PYTHON_ROOT=c:/python
|
||||
set STLPORT_ROOT=d:/programming/libraries/stlport-4.5.3
|
||||
set PYSTE_FILE_DIR=%@PATH[%PYSTE_FILE]
|
||||
|
||||
python ../src/pyste.py -I%PYSTE_FILE_DIR --out=%MODULE_NAME.cpp --module=%MODULE_NAME %PYSTE_FILE
|
||||
|
||||
icl /nologo /LD /GR /GX -I%PYSTE_FILE_DIR -I%STLPORT_ROOT/stlport -I%BOOST_ROOT/boost -I%PYTHON_ROOT/include %MODULE_NAME.cpp /link /libpath:%PYTHON_ROOT/libs /libpath:%BOOST_ROOT/lib /libpath:%STLPORT_ROOT/lib boost_python.lib
|
||||
|
||||
rm %MODULE_NAME.cpp
|
||||
rm %MODULE_NAME.exp
|
||||
rm %MODULE_NAME.lib
|
||||
rm %MODULE_NAME.obj
|
||||
|
||||
endlocal
|
||||
27
pyste/tests/example_basicUT.py
Normal file
27
pyste/tests/example_basicUT.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import unittest
|
||||
import os
|
||||
|
||||
class BasicExampleTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
from basic import C, call_f
|
||||
|
||||
class D(C):
|
||||
def f(self, x=10):
|
||||
return x+1
|
||||
|
||||
d = D()
|
||||
c = C()
|
||||
|
||||
self.assertEqual(c.f(), 20)
|
||||
self.assertEqual(c.f(3), 6)
|
||||
self.assertEqual(d.f(), 11)
|
||||
self.assertEqual(d.f(3), 4)
|
||||
self.assertEqual(call_f(c), 20)
|
||||
self.assertEqual(call_f(c, 4), 8)
|
||||
self.assertEqual(call_f(d), 11)
|
||||
self.assertEqual(call_f(d, 3), 4)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
18
pyste/tests/example_enumsUT.py
Normal file
18
pyste/tests/example_enumsUT.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import unittest
|
||||
from enums import *
|
||||
|
||||
class EnumsTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
self.assertEqual(int(color.Red), 0)
|
||||
self.assertEqual(int(color.Blue), 1)
|
||||
|
||||
self.assertEqual(int(X.Choices.Good), 1)
|
||||
self.assertEqual(int(X.Choices.Bad), 2)
|
||||
x = X()
|
||||
self.assertEqual(x.set(x.Choices.Good), 1)
|
||||
self.assertEqual(x.set(x.Choices.Bad), 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
15
pyste/tests/example_header_testUT.py
Normal file
15
pyste/tests/example_header_testUT.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import unittest
|
||||
from header_test import *
|
||||
|
||||
class HeaderTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
self.assertEqual(choice.red, 0)
|
||||
self.assertEqual(choice.blue, 1)
|
||||
self.assertEqual(choice_str(choice.blue), 'blue')
|
||||
self.assertEqual(choice_str(choice.red), 'red')
|
||||
c = C()
|
||||
c.c = choice.blue
|
||||
self.assertEqual(c.get(), 'blue')
|
||||
c.c = choice.red
|
||||
self.assertEqual(c.get(), 'red')
|
||||
15
pyste/tests/example_nested.py
Normal file
15
pyste/tests/example_nested.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import unittest
|
||||
from nested import *
|
||||
|
||||
class NestedTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
self.assertEqual(Root.staticXValue, 10)
|
||||
self.assertEqual(Root.Y.staticYValue, 20)
|
||||
z = Root.Y.Z()
|
||||
z.valueZ = 3
|
||||
self.assertEqual(z.valueZ, 3)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
25
pyste/tests/example_operatorsUT.py
Normal file
25
pyste/tests/example_operatorsUT.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import unittest
|
||||
from operators import *
|
||||
|
||||
class OperatorTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
c = C()
|
||||
c.value = 3.0
|
||||
d = C()
|
||||
d.value = 2.0
|
||||
self.assertEqual(c.x, 10)
|
||||
self.assertEqual(C.x, 10)
|
||||
self.assertEqual(C.x, 10)
|
||||
self.assertEqual((c * d).value, 6.0)
|
||||
self.assertEqual((c + d).value, 5.0)
|
||||
self.assertEqual(int(c), 3)
|
||||
self.assertEqual(int(d), 2)
|
||||
self.assertEqual(c(), 10)
|
||||
self.assertEqual(d(), 10)
|
||||
self.assertEqual(c(3.0), 13.0)
|
||||
self.assertEqual(d(6.0), 16.0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
26
pyste/tests/example_templatesUT.py
Normal file
26
pyste/tests/example_templatesUT.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import unittest
|
||||
from templates import *
|
||||
|
||||
class TemplatesTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
fp = FPoint()
|
||||
fp.i = 3.0
|
||||
fp.j = 4
|
||||
ip = IPoint()
|
||||
ip.x = 10
|
||||
ip.y = 3.0
|
||||
|
||||
self.assertEqual(fp.i, 3.0)
|
||||
self.assertEqual(fp.j, 4)
|
||||
self.assertEqual(ip.x, 10)
|
||||
self.assertEqual(ip.y, 3.0)
|
||||
self.assertEqual(type(fp.i), float)
|
||||
self.assertEqual(type(fp.j), int)
|
||||
self.assertEqual(type(ip.x), int)
|
||||
self.assertEqual(type(ip.y), float)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
31
pyste/tests/example_virtual.py
Normal file
31
pyste/tests/example_virtual.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import unittest
|
||||
from virtual import *
|
||||
|
||||
class VirtualTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
|
||||
class D(C):
|
||||
def f_abs(self):
|
||||
return 3
|
||||
|
||||
class E(C):
|
||||
def f(self):
|
||||
return 10
|
||||
def name(self):
|
||||
return 'E'
|
||||
|
||||
d = D()
|
||||
e = E()
|
||||
|
||||
self.assertEqual(d.f(), 3)
|
||||
self.assertEqual(call_f(d), 3)
|
||||
self.assertEqual(e.f(), 10)
|
||||
self.assertEqual(call_f(e), 10)
|
||||
self.assertEqual(d.get_name(), 'C')
|
||||
self.assertEqual(e.get_name(), 'E')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
11
pyste/tests/example_wrappertestUT.py
Normal file
11
pyste/tests/example_wrappertestUT.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import unittest
|
||||
from wrappertest import *
|
||||
|
||||
class WrapperTest(unittest.TestCase):
|
||||
|
||||
def testIt(self):
|
||||
self.assertEqual(Range(10), range(10))
|
||||
self.assertEqual(C().Mul(10), [x*10 for x in range(10)])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
20
pyste/tests/test_all.bat
Normal file
20
pyste/tests/test_all.bat
Normal file
@@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
call build_pyste_nt basic ../example/basic.pyste
|
||||
call build_pyste_nt enums ../example/enums.pyste
|
||||
call build_pyste_nt header_test ../example/header_test.pyste
|
||||
call build_pyste_nt nested ../example/nested.pyste
|
||||
call build_pyste_nt operators ../example/operators.pyste
|
||||
call build_pyste_nt templates ../example/templates.pyste
|
||||
call build_pyste_nt virtual ../example/virtual.pyste
|
||||
call build_pyste_nt wrappertest ../example/wrappertest.pyste
|
||||
call build_pyste_nt unions ../example/unions.pyste
|
||||
|
||||
|
||||
runtests.py
|
||||
|
||||
if errorlevel != 0 goto end
|
||||
|
||||
rm *.dll
|
||||
rm *.pyc
|
||||
|
||||
:end
|
||||
Reference in New Issue
Block a user