merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11821 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2010-01-11 00:59:12 +00:00
commit d8a371808a
190 changed files with 5425 additions and 2040 deletions

View file

@ -79,5 +79,6 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements);
%cdata(void);
/* Memory move function */
/* Memory move function. Due to multi-argument typemaps this appears to be wrapped as
void memmove(void *data, const char *s); */
void memmove(void *data, const void *indata, int inlen);

View file

@ -79,7 +79,7 @@ typedef struct {
/* this is the struct for wrapping arbitary packed binary data
(currently it is only used for member function pointers)
the data ordering is similar to swig_lua_userdata, but it is currently not possible
to tell the two structures apart within Swig, other than by looking at the type
to tell the two structures apart within SWIG, other than by looking at the type
*/
typedef struct {
swig_type_info *type;

View file

@ -1,24 +1,16 @@
#if OCTAVE_API_VERSION_OPTION>0
#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_OPTION
#else
#include <octave/version.h>
#ifdef OCTAVE_API_VERSION_N
#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_N
#ifndef OCTAVE_API_VERSION_NUMBER
#else // Interim hack to distinguish between Octave 3.2 and earlier versions.
#define ComplexLU __ignore
#include <octave/CmplxLU.h>
#undef ComplexLU
#ifdef octave_Complex_LU_h
#define USE_OCTAVE_API_VERSION 36
#else
#define USE_OCTAVE_API_VERSION 37
#endif
#endif
// Hack to distinguish between Octave 3.2 and earlier versions before OCTAVE_API_VERSION_NUMBER existed
#define ComplexLU __ignore
#include <octave/CmplxLU.h>
#undef ComplexLU
#ifdef octave_Complex_LU_h
# define OCTAVE_API_VERSION_NUMBER 36
#else
# define OCTAVE_API_VERSION_NUMBER 37
#endif
#endif
@ -469,7 +461,7 @@ namespace Swig {
install_builtin_function(it->second.first->method, it->first,
it->second.first->doc?it->second.first->doc:std::string());
else if (it->second.second.is_defined()) {
#if USE_OCTAVE_API_VERSION<37
#if OCTAVE_API_VERSION_NUMBER<37
link_to_global_variable(curr_sym_tab->lookup(it->first, true));
#else
symbol_table::varref(it->first);
@ -477,7 +469,7 @@ namespace Swig {
#endif
set_global_value(it->first, it->second.second);
#if USE_OCTAVE_API_VERSION<37
#if OCTAVE_API_VERSION_NUMBER<37
octave_swig_type *ost = Swig::swig_value_deref(it->second.second);
if (ost) {
const char* h = ost->help_text();
@ -1389,7 +1381,7 @@ SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) {
SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) {
octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *));
const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION;
#if USE_OCTAVE_API_VERSION<37
#if OCTAVE_API_VERSION_NUMBER<37
link_to_global_variable(curr_sym_tab->lookup(module_var, true));
#else
symbol_table::varref(module_var);

View file

@ -72,7 +72,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
module_ns->install_global();
module_ns->decref();
#if USE_OCTAVE_API_VERSION<37
#if OCTAVE_API_VERSION_NUMBER<37
link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true));
#else
symbol_table::varref(SWIG_name_d);
@ -80,7 +80,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
#endif
set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns));
#if USE_OCTAVE_API_VERSION>=37
#if OCTAVE_API_VERSION_NUMBER>=37
mlock();
#endif
@ -89,7 +89,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
// workaround bug in octave where installing global variable of custom type and then
// exiting without explicitly clearing the variable causes octave to segfault.
#if USE_OCTAVE_API_VERSION>=37
#if OCTAVE_API_VERSION_NUMBER>=37
struct oct_file_unload {
~oct_file_unload() {
string_vector vars = symbol_table::global_variable_names();

View file

@ -293,7 +293,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_
int newmemory = 0;
*ptr = SWIG_TypeCast(tc,voidptr,&newmemory);
if (newmemory == SWIG_CAST_NEW_MEMORY) {
assert(own);
assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
if (own)
*own = *own | SWIG_CAST_NEW_MEMORY;
}
@ -311,7 +311,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_
*/
SV *obj = sv;
HV *stash = SvSTASH(SvRV(obj));
GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE);
GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
if (isGV(gv)) {
HV *hv = GvHVn(gv);
/*
@ -342,7 +342,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i
stash=SvSTASH(SvRV(obj));
if (flags & SWIG_POINTER_OWN) {
HV *hv;
GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
if (!isGV(gv))
gv_init(gv, stash, "OWNER", 5, FALSE);
hv=GvHVn(gv);

View file

@ -51,3 +51,6 @@
c.module_number = module_number;
zend_register_constant( &c TSRMLS_CC );
}
/* Handled as a global variable. */
%typemap(consttab) SWIGTYPE (CLASS::*) "";

View file

@ -168,7 +168,7 @@ namespace Swig {
{
public:
DirectorPureVirtualException(const char* msg)
: DirectorException(E_ERROR, "Swig director pure virtual method called", msg)
: DirectorException(E_ERROR, "SWIG director pure virtual method called", msg)
{
}
@ -182,7 +182,7 @@ namespace Swig {
{
public:
DirectorMethodException(const char* msg = "")
: DirectorException(E_ERROR, "Swig director method error", msg)
: DirectorException(E_ERROR, "SWIG director method error", msg)
{
}

View file

@ -105,6 +105,16 @@
zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL);
}
%typemap(varinit) SWIGTYPE (CLASS::*)
{
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
zval * resource;
MAKE_STD_ZVAL(resource);
ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr);
zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL);
}
%typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE
{
zval **z_var;
@ -216,6 +226,15 @@
$1 = ($1_ltype)_temp;
}
%typemap(varin) SWIGTYPE (CLASS::*)
{
zval **z_var;
zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var);
void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr);
memcpy(&$1, p, sizeof($1));
}
%typemap(varout) int,
unsigned int,
unsigned short,
@ -328,4 +347,12 @@ deliberate error cos this code looks bogus to me
SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0);
}
%typemap(varout) SWIGTYPE (CLASS::*)
{
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
zval * resource;
MAKE_STD_ZVAL(resource);
ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr);
zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL);
}

View file

@ -55,6 +55,10 @@
%pass_by_val(long, CONVERT_INT_IN);
%pass_by_val(unsigned long, CONVERT_INT_IN);
%pass_by_val(signed long long, CONVERT_LONG_LONG_IN);
%pass_by_val(long long, CONVERT_LONG_LONG_IN);
%pass_by_val(unsigned long long, CONVERT_UNSIGNED_LONG_LONG_IN);
%pass_by_val(signed char, CONVERT_INT_IN);
%pass_by_val(char, CONVERT_CHAR_IN);
%pass_by_val(unsigned char, CONVERT_INT_IN);
@ -194,6 +198,29 @@
ZVAL_LONG(return_value,$1);
}
%typemap(out) long long
%{
if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) {
return_value->value.lval = (long)($1);
return_value->type = IS_LONG;
} else {
char temp[256];
sprintf(temp, "%lld", $1);
ZVAL_STRING(return_value, temp, 1);
}
%}
%typemap(out) unsigned long long
%{
if ($1 <= (unsigned long long)LONG_MAX) {
return_value->value.lval = (long)($1);
return_value->type = IS_LONG;
} else {
char temp[256];
sprintf(temp, "%llu", $1);
ZVAL_STRING(return_value, temp, 1);
}
%}
%typemap(out) const int &,
const unsigned int &,
const short &,
@ -209,6 +236,29 @@
ZVAL_LONG(return_value,*$1);
}
%typemap(out) const long long &
%{
if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) {
return_value->value.lval = (long)(*$1);
return_value->type = IS_LONG;
} else {
char temp[256];
sprintf(temp, "%lld", *$1);
ZVAL_STRING(return_value, temp, 1);
}
%}
%typemap(out) const unsigned long long &
%{
if (*$1 <= (unsigned long long)LONG_MAX) {
return_value->value.lval = (long)(*$1);
return_value->type = IS_LONG;
} else {
char temp[256];
sprintf(temp, "%llu", *$1);
ZVAL_STRING(return_value, temp, 1);
}
%}
%typemap(directorin) int,
unsigned int,
short,
@ -304,6 +354,23 @@
SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner);
%}
%typemap(out) SWIGTYPE (CLASS::*)
{
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
zval * resource;
MAKE_STD_ZVAL(resource);
ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr);
SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner);
}
%typemap(in) SWIGTYPE (CLASS::*)
{
void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr);
memcpy(&$1, p, sizeof($1));
}
%typemap(out) SWIGTYPE *DYNAMIC,
SWIGTYPE &DYNAMIC
{
@ -357,6 +424,8 @@
%php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG)
%php_typecheck(long,SWIG_TYPECHECK_INT64,IS_LONG)
%php_typecheck(unsigned long,SWIG_TYPECHECK_UINT64,IS_LONG)
%php_typecheck(long long,SWIG_TYPECHECK_INT64,IS_LONG)
%php_typecheck(unsigned long long,SWIG_TYPECHECK_UINT64,IS_LONG)
%php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG)
%php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG)
%php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG)

View file

@ -8,5 +8,6 @@
%init %{
SWIG_php_minit {
SWIG_InitializeModule(0);
le_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number);
%}

View file

@ -5,13 +5,13 @@
* phpkw.swg
* ----------------------------------------------------------------------------- */
#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",$isclass,rename="c_%s") `x`
#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x`
#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`
#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x`
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x`
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x`
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
/*
From
@ -355,105 +355,105 @@ PHPBN2(E_STRICT);
PHPBN2(__COMPILER_HALT_OFFSET__);
/* Class names reserved by PHP */
PHPCN(stdClass);
PHPCN(__PHP_Incomplete_Class);
PHPCN(Directory);
/* case insensitive */
PHPCN(stdclass);
PHPCN(__php_incomplete_class);
PHPCN(directory);
/* Added in PHP5 (this list apparently depends which extensions you load by default). */
PHPCN(parent);
PHPCN(self);
PHPCN(Exception);
PHPCN(exception);
PHPCN(php_user_filter);
PHPCN(ErrorException);
PHPCN(XMLWriter);
PHPCN(LibXMLError);
PHPCN(SimpleXMLElement);
PHPCN(SoapClient);
PHPCN(SoapVar);
PHPCN(SoapServer);
PHPCN(SoapFault);
PHPCN(SoapParam);
PHPCN(SoapHeader);
PHPCN(RecursiveIteratorIterator);
PHPCN(FilterIterator);
PHPCN(RecursiveFilterIterator);
PHPCN(ParentIterator);
PHPCN(LimitIterator);
PHPCN(CachingIterator);
PHPCN(RecursiveCachingIterator);
PHPCN(IteratorIterator);
PHPCN(NoRewindIterator);
PHPCN(AppendIterator);
PHPCN(InfiniteIterator);
PHPCN(EmptyIterator);
PHPCN(ArrayObject);
PHPCN(ArrayIterator);
PHPCN(RecursiveArrayIterator);
PHPCN(SplFileInfo);
PHPCN(DirectoryIterator);
PHPCN(RecursiveDirectoryIterator);
PHPCN(SplFileObject);
PHPCN(SplTempFileObject);
PHPCN(SimpleXMLIterator);
PHPCN(LogicException);
PHPCN(BadFunctionCallException);
PHPCN(BadMethodCallException);
PHPCN(DomainException);
PHPCN(InvalidArgumentException);
PHPCN(LengthException);
PHPCN(OutOfRangeException);
PHPCN(RuntimeException);
PHPCN(OutOfBoundsException);
PHPCN(OverflowException);
PHPCN(RangeException);
PHPCN(UnderflowException);
PHPCN(UnexpectedValueException);
PHPCN(SplObjectStorage);
PHPCN(ReflectionException);
PHPCN(Reflection);
PHPCN(ReflectionFunction);
PHPCN(ReflectionParameter);
PHPCN(ReflectionMethod);
PHPCN(ReflectionClass);
PHPCN(ReflectionObject);
PHPCN(ReflectionProperty);
PHPCN(ReflectionExtension);
PHPCN(DOMException);
PHPCN(DOMStringList);
PHPCN(DOMNameList);
PHPCN(DOMImplementationList);
PHPCN(DOMImplementationSource);
PHPCN(DOMImplementation);
PHPCN(DOMNode);
PHPCN(DOMNameSpaceNode);
PHPCN(DOMDocumentFragment);
PHPCN(DOMDocument);
PHPCN(DOMNodeList);
PHPCN(DOMNamedNodeMap);
PHPCN(DOMCharacterData);
PHPCN(DOMAttr);
PHPCN(DOMElement);
PHPCN(DOMText);
PHPCN(DOMComment);
PHPCN(DOMTypeinfo);
PHPCN(DOMUserDataHandler);
PHPCN(DOMDomError);
PHPCN(DOMErrorHandler);
PHPCN(DOMLocator);
PHPCN(DOMConfiguration);
PHPCN(DOMCdataSection);
PHPCN(DOMDocumentType);
PHPCN(DOMNotation);
PHPCN(DOMEntity);
PHPCN(DOMEntityReference);
PHPCN(DOMProcessingInstruction);
PHPCN(DOMStringExtend);
PHPCN(DOMXPath);
PHPCN(XMLReader);
PHPCN(SQLiteDatabase);
PHPCN(SQLiteResult);
PHPCN(SQLiteUnbuffered);
PHPCN(SQLiteException);
PHPCN(errorexception);
PHPCN(xmlwriter);
PHPCN(libxmlerror);
PHPCN(simplexmlelement);
PHPCN(soapclient);
PHPCN(soapvar);
PHPCN(soapserver);
PHPCN(soapfault);
PHPCN(soapparam);
PHPCN(soapheader);
PHPCN(recursiveiteratoriterator);
PHPCN(filteriterator);
PHPCN(recursivefilteriterator);
PHPCN(parentiterator);
PHPCN(limititerator);
PHPCN(cachingiterator);
PHPCN(recursivecachingiterator);
PHPCN(iteratoriterator);
PHPCN(norewinditerator);
PHPCN(appenditerator);
PHPCN(infiniteiterator);
PHPCN(emptyiterator);
PHPCN(arrayobject);
PHPCN(arrayiterator);
PHPCN(recursivearrayiterator);
PHPCN(splfileinfo);
PHPCN(directoryiterator);
PHPCN(recursivedirectoryiterator);
PHPCN(splfileobject);
PHPCN(spltempfileobject);
PHPCN(simplexmliterator);
PHPCN(logicexception);
PHPCN(badfunctioncallexception);
PHPCN(badmethodcallexception);
PHPCN(domainexception);
PHPCN(invalidargumentexception);
PHPCN(lengthexception);
PHPCN(outofrangeexception);
PHPCN(runtimeexception);
PHPCN(outofboundsexception);
PHPCN(overflowexception);
PHPCN(rangeexception);
PHPCN(underflowexception);
PHPCN(unexpectedvalueexception);
PHPCN(splobjectstorage);
PHPCN(reflectionexception);
PHPCN(reflection);
PHPCN(reflectionfunction);
PHPCN(reflectionparameter);
PHPCN(reflectionmethod);
PHPCN(reflectionclass);
PHPCN(reflectionobject);
PHPCN(reflectionproperty);
PHPCN(reflectionextension);
PHPCN(domexception);
PHPCN(domstringlist);
PHPCN(domnamelist);
PHPCN(domimplementationlist);
PHPCN(domimplementationsource);
PHPCN(domimplementation);
PHPCN(domnode);
PHPCN(domnamespacenode);
PHPCN(domdocumentfragment);
PHPCN(domdocument);
PHPCN(domnodelist);
PHPCN(domnamednodemap);
PHPCN(domcharacterdata);
PHPCN(domattr);
PHPCN(domelement);
PHPCN(domtext);
PHPCN(domcomment);
PHPCN(domtypeinfo);
PHPCN(domuserdatahandler);
PHPCN(domdomerror);
PHPCN(domerrorhandler);
PHPCN(domlocator);
PHPCN(domconfiguration);
PHPCN(domcdatasection);
PHPCN(domdocumenttype);
PHPCN(domnotation);
PHPCN(domentity);
PHPCN(domentityreference);
PHPCN(domprocessinginstruction);
PHPCN(domstringextend);
PHPCN(domxpath);
PHPCN(xmlreader);
PHPCN(sqlitedatabase);
PHPCN(sqliteresult);
PHPCN(sqliteunbuffered);
PHPCN(sqliteexception);
/* Built-in PHP functions (incomplete). */
PHPFN(cos);

View file

@ -36,7 +36,7 @@ extern "C" {
#define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
#define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), V, strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), (char*)(V), strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC)
#define SWIG_CHAR_CONSTANT(N, V) do {\
static char swig_char = (V);\
zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\
@ -261,3 +261,12 @@ static void SWIG_Php_SetModule(swig_module_info *pointer) {
TSRMLS_FETCH();
REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0);
}
#define SWIG_MEMBER_PTR ((char*)"CLASS::*")
static void member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
efree(rsrc->ptr);
}
static int le_member_ptr;

View file

@ -30,8 +30,6 @@ namespace std {
map(const map<K,T> &);
unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear();
%extend {
T& get(const K& key) throw (std::out_of_range) {
@ -55,6 +53,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
bool is_empty() const {
return self->empty();
}
}
};
@ -70,8 +71,6 @@ namespace std {
map(const map<K,T> &);
unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear();
%extend {
T& get(K key) throw (std::out_of_range) {
@ -95,6 +94,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
bool is_empty() const {
return self->empty();
}
}
};
%enddef
@ -107,8 +109,6 @@ namespace std {
map(const map<K,T> &);
unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear();
%extend {
T get(const K& key) throw (std::out_of_range) {
@ -132,6 +132,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
bool is_empty() const {
return self->empty();
}
}
};
%enddef
@ -145,8 +148,6 @@ namespace std {
map(const map<K,T> &);
unsigned int size() const;
%rename(is_empty) empty;
bool empty() const;
void clear();
%extend {
T get(K key) throw (std::out_of_range) {
@ -170,6 +171,9 @@ namespace std {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
bool is_empty() const {
return self->empty();
}
}
};
%enddef

View file

@ -112,9 +112,7 @@ int_typemap(long long);
}
%typemap(in) TYPE *REFERENCE (long long lvalue)
%{
// FIXME won't work for values which don't fit in a long...
convert_to_long_ex($input);
lvalue = (long long) (*$input)->value.lval;
CONVERT_LONG_LONG_IN(lvalue, long long, $input)
$1 = &lvalue;
%}
%typemap(argout) long long *REFERENCE
@ -128,6 +126,17 @@ int_typemap(long long);
ZVAL_STRING((*$arg), temp, 1);
}
%}
%typemap(argout) long long &OUTPUT
%{
if ((long long)LONG_MIN <= *arg$argnum && *arg$argnum <= (long long)LONG_MAX) {
($result)->value.lval = (long)(*arg$argnum);
($result)->type = IS_LONG;
} else {
char temp[256];
sprintf(temp, "%lld", *arg$argnum);
ZVAL_STRING($result, temp, 1);
}
%}
int_typemap(unsigned long long);
%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT
{
@ -144,9 +153,7 @@ int_typemap(unsigned long long);
}
%typemap(in) TYPE *REFERENCE (unsigned long long lvalue)
%{
// FIXME won't work for values which don't fit in a long...
convert_to_long_ex($input);
lvalue = (unsigned long long) (*$input)->value.lval;
CONVERT_UNSIGNED_LONG_LONG_IN(lvalue, unsigned long long, $input)
$1 = &lvalue;
%}
%typemap(argout) unsigned long long *REFERENCE
@ -160,6 +167,17 @@ int_typemap(unsigned long long);
ZVAL_STRING((*$arg), temp, 1);
}
%}
%typemap(argout) unsigned long long &OUTPUT
%{
if (*arg$argnum <= (unsigned long long)LONG_MAX) {
($result)->value.lval = (long)(*arg$argnum);
($result)->type = IS_LONG;
} else {
char temp[256];
sprintf(temp, "%llu", *arg$argnum);
ZVAL_STRING($result, temp, 1);
}
%}
%typemap(in) float *INOUT = float *INPUT;
%typemap(in) double *INOUT = double *INPUT;
@ -181,11 +199,13 @@ int_typemap(unsigned long long);
%typemap(in) short &INOUT = short *INPUT;
%typemap(in) long &INOUT = long *INPUT;
%typemap(in) long long &INOUT = long long *INPUT;
%typemap(in) long long &INPUT = long long *INPUT;
%typemap(in) unsigned &INOUT = unsigned *INPUT;
%typemap(in) unsigned short &INOUT = unsigned short *INPUT;
%typemap(in) unsigned long &INOUT = unsigned long *INPUT;
%typemap(in) unsigned char &INOUT = unsigned char *INPUT;
%typemap(in) unsigned long long &INOUT = unsigned long long *INPUT;
%typemap(in) unsigned long long &INPUT = unsigned long long *INPUT;
%typemap(argout) float *INOUT = float *OUTPUT;
%typemap(argout) double *INOUT= double *OUTPUT;

View file

@ -9,6 +9,42 @@
lvar = (t) Z_LVAL_PP(invar);
%enddef
%define CONVERT_LONG_LONG_IN(lvar,t,invar)
switch ((*(invar))->type) {
case IS_DOUBLE:
lvar = (t) (*(invar))->value.dval;
break;
case IS_STRING: {
char * endptr;
errno = 0;
lvar = (t) strtoll((*(invar))->value.str.val, &endptr, 10);
if (*endptr && !errno) break;
/* FALL THRU */
}
default:
convert_to_long_ex(invar);
lvar = (t) (*(invar))->value.lval;
}
%enddef
%define CONVERT_UNSIGNED_LONG_LONG_IN(lvar,t,invar)
switch ((*(invar))->type) {
case IS_DOUBLE:
lvar = (t) (*(invar))->value.dval;
break;
case IS_STRING: {
char * endptr;
errno = 0;
lvar = (t) strtoull((*(invar))->value.str.val, &endptr, 10);
if (*endptr && !errno) break;
/* FALL THRU */
}
default:
convert_to_long_ex(invar);
lvar = (t) (*(invar))->value.lval;
}
%enddef
%define CONVERT_INT_OUT(lvar,invar)
lvar = (t) Z_LVAL_PP(invar);
%enddef

View file

@ -237,7 +237,7 @@ namespace Swig {
try {
throw;
} catch (DirectorException& e) {
std::cerr << "Swig Director exception caught:" << std::endl
std::cerr << "SWIG Director exception caught:" << std::endl
<< e.getMessage() << std::endl;
} catch (std::exception& e) {
std::cerr << "std::exception caught: "<< e.what() << std::endl;
@ -276,12 +276,12 @@ namespace Swig {
class DirectorTypeMismatchException : public Swig::DirectorException {
public:
DirectorTypeMismatchException(PyObject *error, const char* msg="")
: Swig::DirectorException(error, "Swig director type mismatch", msg)
: Swig::DirectorException(error, "SWIG director type mismatch", msg)
{
}
DirectorTypeMismatchException(const char* msg="")
: Swig::DirectorException(PyExc_TypeError, "Swig director type mismatch", msg)
: Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg)
{
}
@ -300,7 +300,7 @@ namespace Swig {
class DirectorMethodException : public Swig::DirectorException {
public:
DirectorMethodException(const char* msg = "")
: DirectorException(PyExc_RuntimeError, "Swig director method error.", msg)
: DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg)
{
}
@ -315,7 +315,7 @@ namespace Swig {
{
public:
DirectorPureVirtualException(const char* msg = "")
: DirectorException(PyExc_RuntimeError, "Swig director pure virtual method called", msg)
: DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg)
{
}

View file

@ -279,15 +279,15 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
}
}
if (ci) {
size_t shift = (ci->ptype) - types;
swig_type_info *ty = types_initial[shift];
size_t ldoc = (c - methods[i].ml_doc);
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
char *ndoc = (char*)malloc(ldoc + lptr + 10);
if (ndoc) {
char *buff = ndoc;
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
if (ptr) {
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
if (ptr) {
size_t shift = (ci->ptype) - types;
swig_type_info *ty = types_initial[shift];
size_t ldoc = (c - methods[i].ml_doc);
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
char *ndoc = (char*)malloc(ldoc + lptr + 10);
if (ndoc) {
char *buff = ndoc;
strncpy(buff, methods[i].ml_doc, ldoc);
buff += ldoc;
strncpy(buff, "swig_ptr: ", 10);

View file

@ -1089,7 +1089,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
int newmemory = 0;
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
if (newmemory == SWIG_CAST_NEW_MEMORY) {
assert(own);
assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
if (own)
*own = *own | SWIG_CAST_NEW_MEMORY;
}

View file

@ -50,7 +50,7 @@ SWIG_InitializeModule(0);
%typemap(scheck) SWIGTYPE[ANY]
%{
# assert(length($input) > $1_dim0)
assert(all(sapply($input, class) == "$R_class"))
assert(all(sapply($input, class) == "$R_class"));
%}
%typemap(out) void "";
@ -122,14 +122,14 @@ SWIG_InitializeModule(0);
/* Handling vector case to avoid warnings,
although we just use the first one. */
%typemap(scheck) unsigned int %{
assert(length($input) == 1 && $input >= 0, "All values must be non-negative")
assert(length($input) == 1 && $input >= 0, "All values must be non-negative");
%}
%typemap(scheck) int, long %{
if(length($input) > 1) {
warning("using only the first element of $input")
}
warning("using only the first element of $input");
};
%}

View file

@ -60,11 +60,11 @@
%typemap(scoercein) std::string, std::string *, std::string &
%{ $input = as($input, "character"); %}
%typemap(scoercein) enum SWIGTYPE
%{ $input = enumToInteger($input, "$R_class") %}
%{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE &
%{ $input = enumToInteger($input, "$R_class") %}
%{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) enum SWIGTYPE *
%{ $input = enumToInteger($input, "$R_class") %}
%{ $input = enumToInteger($input, "$R_class"); %}
%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE &
@ -84,14 +84,14 @@
%typemap(scoercein) SWIGTYPE[ANY]
%{
if(is.list($input))
assert(all(sapply($input, class) == "$R_class"))
assert(all(sapply($input, class) == "$R_class"));
%}
/* **************************************************************** */
%typemap(scoercein) bool, bool *, bool &
"$input = as.logical($input) ";
"$input = as.logical($input);";
%typemap(scoercein) int,
int *,
int &,
@ -100,30 +100,30 @@
long *,
long &,
long[ANY]
"$input = as.integer($input) ";
"$input = as.integer($input); ";
%typemap(scoercein) char *, string, std::string,
string &, std::string &
%{ $input = as($input, "character") %}
%{ $input = as($input, "character"); %}
%typemap(scoerceout) enum SWIGTYPE
%{ $result = enumFromInteger($result, "$R_class") %}
%{ $result = enumFromInteger($result, "$R_class"); %}
%typemap(scoerceout) enum SWIGTYPE &
%{ $result = enumFromInteger($result, "$R_class") %}
%{ $result = enumFromInteger($result, "$R_class"); %}
%typemap(scoerceout) enum SWIGTYPE *
%{ $result = enumToInteger($result, "$R_class") %}
%{ $result = enumToInteger($result, "$R_class"); %}
%typemap(scoerceout) SWIGTYPE
%{ class($result) <- "$&R_class" %}
%{ class($result) <- "$&R_class"; %}
%typemap(scoerceout) SWIGTYPE &
%{ class($result) <- "$R_class" %}
%{ class($result) <- "$R_class"; %}
%typemap(scoerceout) SWIGTYPE *
%{ class($result) <- "$R_class" %}
%{ class($result) <- "$R_class"; %}
/* Override the SWIGTYPE * above. */
%typemap(scoerceout) char,

5
Lib/r/std_map.i Normal file
View file

@ -0,0 +1,5 @@
%fragment("StdMapTraits","header")
%{
%}
%include <std/std_map.i>

View file

@ -1 +1,5 @@
%include<std/std_pair.i>
%fragment("StdPairTraits","header")
%{
%}
%include<std/std_pair.i>

View file

@ -176,7 +176,7 @@ namespace Swig {
try {
throw;
} catch (DirectorException& e) {
std::cerr << "Swig Director exception caught:" << std::endl
std::cerr << "SWIG Director exception caught:" << std::endl
<< e.getMessage() << std::endl;
} catch (std::exception& e) {
std::cerr << "std::exception caught: "<< e.what() << std::endl;
@ -212,12 +212,12 @@ namespace Swig {
class DirectorTypeMismatchException : public Swig::DirectorException {
public:
DirectorTypeMismatchException(VALUE error, const char *msg="")
: Swig::DirectorException(error, "Swig director type mismatch", msg)
: Swig::DirectorException(error, "SWIG director type mismatch", msg)
{
}
DirectorTypeMismatchException(const char *msg="")
: Swig::DirectorException(rb_eTypeError, "Swig director type mismatch", msg)
: Swig::DirectorException(rb_eTypeError, "SWIG director type mismatch", msg)
{
}
@ -238,7 +238,7 @@ namespace Swig {
}
DirectorMethodException(const char* msg = "")
: Swig::DirectorException(rb_eRuntimeError, "Swig director method error.", msg) {
: Swig::DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) {
}
static void raise(VALUE error)
@ -252,7 +252,7 @@ namespace Swig {
{
public:
DirectorPureVirtualException(const char* msg = "")
: DirectorException(rb_eRuntimeError, "Swig director pure virtual method called", msg)
: DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", msg)
{
}

View file

@ -1,5 +1,14 @@
#include <ruby.h>
/* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
* breaks using rb_intern as an lvalue, as SWIG does. We work around this
* issue for now by disabling this.
* https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645
*/
#ifdef rb_intern
# undef rb_intern
#endif
/* Remove global macros defined in Ruby's win32.h */
#ifdef write
# undef write

View file

@ -45,7 +45,7 @@
/* Error manipulation */
#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg)
#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg)
#define SWIG_fail goto fail

View file

@ -27,7 +27,7 @@
};
*/
%define %std_deque_methods(T)
%define %std_deque_methods_noempty(T)
typedef T &reference;
typedef const T& const_reference;
@ -41,7 +41,6 @@
unsigned int size() const;
unsigned int max_size() const;
void resize(unsigned int n, T c = T());
bool empty() const;
const_reference front();
const_reference back();
void push_front(const T& x);
@ -69,7 +68,7 @@
throw std::out_of_range("deque index out of range");
}
void delitem(int i) throw (std::out_of_range) {
int size = int(self->size());
int size = int(self->size());
if (i<0) i+= size;
if (i>=0 && i<size) {
self->erase(self->begin()+i);
@ -77,7 +76,7 @@
throw std::out_of_range("deque index out of range");
}
}
std::deque<T> getslice(int i, int j) {
std::deque<T> getslice(int i, int j) {
int size = int(self->size());
if (i<0) i = size+i;
if (j<0) j = size+j;
@ -112,15 +111,27 @@
self->erase(self->begin()+i,self->begin()+j);
}
};
%enddef
#ifdef SWIGPHP
%define %std_deque_methods(T)
%extend {
bool is_empty() const {
return self->empty();
}
};
%std_deque_methods_noempty(T)
%enddef
#else
%define %std_deque_methods(T)
bool empty() const;
%std_deque_methods_noempty(T)
%enddef
#endif
namespace std {
template<class T> class deque {
public:
%std_deque_methods(T);
};
}

View file

@ -134,6 +134,46 @@ namespace std {
%std_vector_methods_val(vector);
};
// ***
// const pointer specialization
// ***
template<class _Tp, class _Alloc >
class vector<const _Tp *, _Alloc > {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef const _Tp * value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type reference;
typedef value_type const_reference;
typedef _Alloc allocator_type;
%traits_swigtype(_Tp);
%fragment(SWIG_Traits_frag(std::vector<const _Tp *, _Alloc >), "header",
fragment=SWIG_Traits_frag(_Tp),
fragment="StdVectorTraits") {
namespace swig {
template <> struct traits<std::vector<const _Tp *, _Alloc > > {
typedef value_category category;
static const char* type_name() {
return "std::vector<const " #_Tp " *," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<const _Tp *, _Alloc >);
#ifdef %swig_vector_methods_val
// Add swig/language extra methods
%swig_vector_methods_val(std::vector<const _Tp *, _Alloc >);
#endif
%std_vector_methods_val(vector);
};
// ***
// ***
// bool specialization

View file

@ -136,6 +136,11 @@
#define %nocallback %feature("callback","0")
#define %clearcallback %feature("callback","")
/* the %nestedworkaround directive */
#define %nestedworkaround %feature("nestedworkaround")
#define %nonestedworkaround %feature("nestedworkaround","0")
#define %clearnestedworkaround %feature("nestedworkaround","")
/* the %fastdispatch directive */
#define %fastdispatch %feature("fastdispatch")
#define %nofastdispatch %feature("fastdispatch","0")

View file

@ -4,8 +4,8 @@
*
* typemaps.i
*
* Swig typemap library for Tcl8. This file contains various sorts
* of typemaps for modifying Swig's code generation.
* SWIG typemap library for Tcl8. This file contains various sorts
* of typemaps for modifying SWIG's code generation.
* ----------------------------------------------------------------------------- */
#if !defined(SWIG_USE_OLD_TYPEMAPS)

View file

@ -21,7 +21,7 @@ typedef struct SWIGCDATA {
%typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA {
%set_output(SWIG_FromCharPtrAndSize($1.data,$1.len));
}
%typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE);
%typemap(in) (const void *indata, size_t inlen) = (char *STRING, size_t SIZE);
/* -----------------------------------------------------------------------------
@ -70,7 +70,8 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1);
%cdata(void);
/* Memory move function */
/* Memory move function. Due to multi-argument typemaps this appears to be wrapped as
void memmove(void *data, const char *s); */
void memmove(void *data, const void *indata, size_t inlen);

View file

@ -444,15 +444,15 @@ SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
%define %ensure_fragment(Fragment)
%fragment(`Fragment`,"header") {
%#error "Swig language implementation must provide the Fragment fragment"
%#error "SWIG language implementation must provide the Fragment fragment"
}
%enddef
%define %ensure_type_fragments(Type)
%fragment(SWIG_From_frag(Type),"header") {
%#error "Swig language implementation must provide a SWIG_From_frag(Type) fragment"
%#error "SWIG language implementation must provide a SWIG_From_frag(Type) fragment"
}
%fragment(SWIG_AsVal_frag(Type),"header") {
%#error "Swig language implementation must provide a SWIG_AsVal_frag(Type) fragment"
%#error "SWIG language implementation must provide a SWIG_AsVal_frag(Type) fragment"
}
%enddef

View file

@ -20,7 +20,7 @@
Casting Operations:
-------------------
Swig provides the following casting macros, which implement the
SWIG provides the following casting macros, which implement the
corresponding C++ casting operations:
%const_cast(a, Type) const_cast<Type >(a)
@ -173,7 +173,7 @@ nocppval
#endif /* __cplusplus */
/* -----------------------------------------------------------------------------
* Swig names and mangling
* SWIG names and mangling
* ----------------------------------------------------------------------------- */
#define %mangle(Type...) #@Type
@ -210,7 +210,7 @@ nocppval
%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef
/* -----------------------------------------------------------------------------
* Swig flags
* SWIG flags
* ----------------------------------------------------------------------------- */
/*