???C/C++???Python
???????????? ???????[ 2015/8/10 10:26:52 ] ??????????????? ???????????
????3????????鰱????
???????????:
????python setup.py build
????????build??????boostCallTest1.so????????????????????????
????>>> import boostCallTest1
????>>> boostCallTest1.Max(1??3)
????3
???????swig???python
????SWIG??????????C????C++??д?????????????????????????????????????????????
????SWIG???????????????????????????y??????????????Perl?? PHP?? Python?? Tcl?? Ruby and PHP??
????swig?????? http://www.swig.org/download.html
???????????yum???????
????yum install swig
????1????д???????
???????????swigCall.cpp
???????????£?
????int Max(int i1??int i2)
????{
????return (i1>i2)?i1:i2;
????}
????2????д??????
???????????swigCall.i
???????????£?
????%module swigCall
????%{
????extern int Max(int i1??int i2);
????%}
????extern int Max(int i1??int i2);
????3????дMakefile???
???????????£?
????all:
????make swigCall
????swigCall:
????swig -python -c++ swigCall.i
????g++ -c swigCall.cpp swigCall_wrap.cxx -I/usr/include/python2.6/ -fPIC
????g++ -shared swigCall.o swigCall_wrap.o -o _swigCall.so
????clean:
????rm -f swigCall_wrap.c*
????rm -f *.py*
????rm -f *.so
????rm -f *.o
???????swig??????????-c++????????c++????
???????SIP???python
????SIP???SWIG???????????Python????C/C++???????? ????????SIP??voip?е?sip???????????????????sip?????python????voip?е?sip????????Э?飬?????????
???????
??????????python sip??
????1????дc++???
????1.1 ??д????
??????????? sipCall.h ????????
????class TestMode
????{
????public:
????int Max(int i1??int i2);
????};
????1.2 ??д???????
???????????sipCall.cpp ????????
????#include "sipCall.h"
????int TestMode::Max(int i1??int i2)
????{
????return (i1>i2)?i1:i2;
????}
????2????д??????
???????????sipCall.sip ????????
????%Module TestMode
????class TestMode {
????%TypeHeaderCode
????#include "sipCall.h"
????%End
????public:
????int Max(int i1??int i2);
????};
????3?????澲???
?????????y??????????????genlib.sh
????????????
????#! /bin/bash
????g++ -c -fPIC sipCall.cpp
????ar -crs libsipCall.a sipCall.o
????4????дconfigure???
?????y??????????Makefile?????????£?
????#! /usr/bin/env python
????import os
????import sipconfig
????build_file = "sipCall.sbf"
????config = sipconfig.Configuration()
????cmd = " ".join([config.sip_bin?? "-c"?? "."?? "-b"?? build_file?? "sipCall.sip"])
????os.system(cmd)
????makefile = sipconfig.SIPModuleMakefile(config?? build_file)
????makefile.extra_libs = ["sipCall"]
????makefile.LIBDIR.append(".")
????makefile.generate()
????5??????genlib.sh???????lib?????
????6??????configure.py???????Makefile??
????7??????make????????????so???????
????8??python???????£?
????>>> import TestMode
????>>> dir(TestMode)
????['TestMode'?? '__doc__'?? '__file__'?? '__name__'?? '__package__']
????>>> s = TestMode.TestMode()
????>>> s.Max(1??3)
????3
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????