FS-6796 #comment avoid use c++ string since it causing troubles

This commit is contained in:
Seven Du 2014-09-06 07:17:44 +08:00
parent 794f09bba0
commit 1a4e6e3093
6 changed files with 22 additions and 22 deletions

View File

@ -3,7 +3,6 @@
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
#ifdef DOH
@ -150,9 +149,9 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod
SWITCH_DECLARE_CONSTRUCTOR Stream(void);
SWITCH_DECLARE_CONSTRUCTOR Stream(switch_stream_handle_t *);
virtual SWITCH_DECLARE_CONSTRUCTOR ~ Stream();
SWITCH_DECLARE(std::string) read();
SWITCH_DECLARE(const char *) read(int *len);
SWITCH_DECLARE(void) write(const char *data);
SWITCH_DECLARE(void) raw_write(std::string data);
SWITCH_DECLARE(void) raw_write(const char *data, int len);
SWITCH_DECLARE(const char *) get_data(void);
};

View File

@ -33,5 +33,4 @@ lua_wrap: mod_lua_extra.c
swig -lua -c++ -I../../../../src/include -oh mod_lua_wrap.h -o mod_lua_wrap.cpp freeswitch.i
echo "#include \"mod_lua_extra.c\"" >> mod_lua_wrap.cpp
patch -s -p0 -i hack.diff
sed -i -e 's/lua_strlen/lua_rawlen/' mod_lua_wrap.cpp

View File

@ -43,7 +43,8 @@
%newobject API::execute;
%newobject API::executeString;
%include "std_string.i"
%include "typemaps.i"
%apply int *OUTPUT { int *len };
/**
* tell swig to grok everything defined in these header files and

View File

@ -2946,18 +2946,18 @@ fail:
static int _wrap_Stream_raw_write(lua_State* L) {
int SWIG_arg = -1;
Stream *arg1 = (Stream *) 0 ;
std::string arg2 ;
char *arg2 = (char *) 0 ;
SWIG_check_num_args("raw_write",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("raw_write",1,"Stream *");
if(!lua_isstring(L,2)) SWIG_fail_arg("raw_write",2,"std::string");
if(!lua_isstring(L,2)) SWIG_fail_arg("raw_write",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
SWIG_fail_ptr("Stream_raw_write",1,SWIGTYPE_p_Stream);
}
(&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2));
(arg1)->raw_write(arg2);
arg2 = (char *)lua_tostring(L, 2);
(arg1)->raw_write((char const *)arg2,lua_rawlen(L, 2));
SWIG_arg=0;
return SWIG_arg;

View File

@ -22,7 +22,10 @@ class Stream {
Stream(void);
Stream(switch_stream_handle_t *);
virtual ~ Stream();
string read();
%inline %{
char *read(int *len);
%}
void write(const char *data);
void raw_write(void *data, int len);
const char *get_data(void);

View File

@ -532,22 +532,20 @@ SWITCH_DECLARE_CONSTRUCTOR Stream::~Stream()
}
/* WARNING!! you are not encouraged to use this unless you understand the risk!!! */
SWITCH_DECLARE(std::string) Stream::read()
SWITCH_DECLARE(const char *) Stream::read(int *len)
{
uint8_t *buff;
this_check(std::string(""));
int len = 0;
this_check(std::string());
this_check(NULL);
if (!stream_p->read_function) return std::string();
if (!stream_p->read_function) return NULL;
buff = stream_p->read_function(stream_p, &len);
buff = stream_p->read_function(stream_p, len);
if (!buff) return std::string();
if (len < 0) return std::string();
if (!buff) return NULL;
if (len < 0) return NULL;
return std::string((const char *)buff, len);
return (const char *)buff;
}
SWITCH_DECLARE(void) Stream::write(const char *data)
@ -556,10 +554,10 @@ SWITCH_DECLARE(void) Stream::write(const char *data)
stream_p->write_function(stream_p, "%s", data);
}
SWITCH_DECLARE(void) Stream::raw_write(std::string data)
SWITCH_DECLARE(void) Stream::raw_write(const char *data, int len)
{
this_check_void();
stream_p->raw_write_function(stream_p, (uint8_t *)data.c_str(), data.length());
stream_p->raw_write_function(stream_p, (uint8_t *)data, len);
}
SWITCH_DECLARE(const char *)Stream::get_data()