add php swig for esl

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12090 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-02-17 15:54:36 +00:00
parent aef9199bec
commit b6a5ef868f
5 changed files with 2785 additions and 1 deletions

View File

@ -40,14 +40,19 @@ fs_cli: $(MYLIB) fs_cli.c
clean:
rm -f *.o src/*.o testclient testserver fs_cli libesl.a *~ src/*~ src/include/*~
make -C perl clean
make -C php clean
reswig: swigclean
make -C perl reswig
make -C php reswig
swigclean: clean
make -C perl swigclean
make -C php swigclean
perlmod: $(MYLIB)
make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C perl
phpmod: $(MYLIB)
make MYLIB="../$(MYLIB)" SOLINK="$(SOLINK)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CXX_CFLAGS="$(CXX_CFLAGS)" -C php

169
libs/esl/php/ESL.php Normal file
View File

@ -0,0 +1,169 @@
<?php
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
// Try to load our extension if it's not already loaded.
if (!extension_loaded("ESL")) {
if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
if (!dl('php_ESL.dll')) return;
} else {
// PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.
// It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.
if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') {
if (!dl('ESL.so')) return;
} else {
if (!dl('ESL.'.PHP_SHLIB_SUFFIX)) return;
}
}
}
/* PHP Proxy Classes */
class eslEvent {
public $_cPtr=null;
function __set($var,$value) {
$func = 'eslEvent_'.$var.'_set';
if (function_exists($func)) call_user_func($func,$this->_cPtr,$value);
}
function __isset($var) {
return function_exists('eslEvent_'.$var.'_set');
}
function __get($var) {
$func = 'eslEvent_'.$var.'_get';
if (function_exists($func)) return call_user_func($func,$this->_cPtr);
return null;
}
function __construct($type_or_wrap_me,$subclass_name_or_free_me=null) {
switch (func_num_args()) {
case 1: $r=new_eslEvent($type_or_wrap_me); break;
default: $r=new_eslEvent($type_or_wrap_me,$subclass_name_or_free_me);
}
$this->_cPtr=$r;
}
function serialize($format=null) {
switch (func_num_args()) {
case 0: $r=eslEvent_serialize($this->_cPtr); break;
default: $r=eslEvent_serialize($this->_cPtr,$format);
}
return $r;
}
function setPriority($priority=null) {
switch (func_num_args()) {
case 0: $r=eslEvent_setPriority($this->_cPtr); break;
default: $r=eslEvent_setPriority($this->_cPtr,$priority);
}
return $r;
}
function getHeader($header_name) {
return eslEvent_getHeader($this->_cPtr,$header_name);
}
function getBody() {
return eslEvent_getBody($this->_cPtr);
}
function getType() {
return eslEvent_getType($this->_cPtr);
}
function addBody($value) {
return eslEvent_addBody($this->_cPtr,$value);
}
function addHeader($header_name,$value) {
return eslEvent_addHeader($this->_cPtr,$header_name,$value);
}
function delHeader($header_name) {
return eslEvent_delHeader($this->_cPtr,$header_name);
}
}
class eslConnection {
public $_cPtr=null;
function __construct($host_or_socket,$port=null,$password=null) {
switch (func_num_args()) {
case 1: $r=new_eslConnection($host_or_socket); break;
case 2: $r=new_eslConnection($host_or_socket,$port); break;
default: $r=new_eslConnection($host_or_socket,$port,$password);
}
$this->_cPtr=$r;
}
function connected() {
return eslConnection_connected($this->_cPtr);
}
function getInfo() {
$r=eslConnection_getInfo($this->_cPtr);
return is_resource($r) ? new eslEvent($r) : $r;
}
function send($cmd) {
return eslConnection_send($this->_cPtr,$cmd);
}
function sendRecv($cmd) {
$r=eslConnection_sendRecv($this->_cPtr,$cmd);
return is_resource($r) ? new eslEvent($r) : $r;
}
function sendEvent($send_me) {
return eslConnection_sendEvent($this->_cPtr,$send_me);
}
function recvEvent() {
$r=eslConnection_recvEvent($this->_cPtr);
return is_resource($r) ? new eslEvent($r) : $r;
}
function recvEventTimed($ms) {
$r=eslConnection_recvEventTimed($this->_cPtr,$ms);
return is_resource($r) ? new eslEvent($r) : $r;
}
function filter($header,$value) {
return eslConnection_filter($this->_cPtr,$header,$value);
}
function events($etype,$value) {
return eslConnection_events($this->_cPtr,$etype,$value);
}
function execute($app,$arg=null,$uuid=null) {
switch (func_num_args()) {
case 1: $r=eslConnection_execute($this->_cPtr,$app); break;
case 2: $r=eslConnection_execute($this->_cPtr,$app,$arg); break;
default: $r=eslConnection_execute($this->_cPtr,$app,$arg,$uuid);
}
return $r;
}
function setBlockingExecute($val) {
return eslConnection_setBlockingExecute($this->_cPtr,$val);
}
function setEventLock($val) {
return eslConnection_setEventLock($this->_cPtr,$val);
}
}
?>

22
libs/esl/php/Makefile Normal file
View File

@ -0,0 +1,22 @@
LOCAL_CFLAGS=$(shell php-config --includes)
LOCAL_LDFLAGS=$(shell php-config --ldflags --libs)
all: ESL.so
esl_wrap.cpp:
swig -module ESL -php5 -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
esl_wrap.o: esl_wrap.cpp
$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o
ESL.so: esl_wrap.o
$(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o ESL.so -L. $(LIBS)
clean:
rm -f *.o *.so *~
swigclean:
rm -f esl_wrap.* ESL.so php_ESL.*
reswig: swigclean esl_wrap.cpp

2525
libs/esl/php/esl_wrap.cpp Normal file

File diff suppressed because it is too large Load Diff

63
libs/esl/php/php_ESL.h Normal file
View File

@ -0,0 +1,63 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
#ifndef PHP_ESL_H
#define PHP_ESL_H
extern zend_module_entry ESL_module_entry;
#define phpext_ESL_ptr &ESL_module_entry
#ifdef PHP_WIN32
# define PHP_ESL_API __declspec(dllexport)
#else
# define PHP_ESL_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(ESL);
PHP_MSHUTDOWN_FUNCTION(ESL);
PHP_RINIT_FUNCTION(ESL);
PHP_RSHUTDOWN_FUNCTION(ESL);
PHP_MINFO_FUNCTION(ESL);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_event_set);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_event_get);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_serialized_string_set);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_serialized_string_get);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_mine_set);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_mine_get);
ZEND_NAMED_FUNCTION(_wrap_new_eslEvent);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_serialize);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_setPriority);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_getHeader);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_getBody);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_getType);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_addBody);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_addHeader);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_delHeader);
ZEND_NAMED_FUNCTION(_wrap_new_eslConnection);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_connected);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_getInfo);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_send);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_sendRecv);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_sendEvent);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_recvEvent);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_recvEventTimed);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_filter);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_events);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_execute);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_setBlockingExecute);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_setEventLock);
#endif /* PHP_ESL_H */