summaryrefslogtreecommitdiff
path: root/Lib/typemaps/std_strings.swg
diff options
context:
space:
mode:
authorMarcelo Matus <mmatus@acms.arizona.edu>2005-12-10 23:53:53 +0000
committerMarcelo Matus <mmatus@acms.arizona.edu>2005-12-10 23:53:53 +0000
commitabbf8b406a156095e54404d6c45b38776337f3d0 (patch)
tree75463ae96b4f384ea30167d40d57fa6bea3a4633 /Lib/typemaps/std_strings.swg
parentee6f1efd8364505ce859927c11d7cf1babbf11f2 (diff)
downloadswig-abbf8b406a156095e54404d6c45b38776337f3d0.tar.gz
more on the TypeQuery fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7971 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/typemaps/std_strings.swg')
-rw-r--r--Lib/typemaps/std_strings.swg34
1 files changed, 22 insertions, 12 deletions
diff --git a/Lib/typemaps/std_strings.swg b/Lib/typemaps/std_strings.swg
index ddba34b1f..86729a5d3 100644
--- a/Lib/typemaps/std_strings.swg
+++ b/Lib/typemaps/std_strings.swg
@@ -6,22 +6,32 @@
SWIGINTERN int
SWIG_AsPtr_dec(String)(SWIG_Object obj, String **val)
{
- static swig_type_info* string_info = SWIG_TypeQuery(#String " *");
- String *vptr;
- if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1) {
- if (val) *val = vptr;
- return SWIG_OLDOBJ;
+ Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
+ if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
+ if (buf) {
+ if (val) *val = new String(buf, size - 1);
+ if (alloc == SWIG_NEWOBJ) %delete_array(buf);
+ return SWIG_NEWOBJ;
+ } else {
+ if (val) *val = 0;
+ return SWIG_OLDOBJ;
+ }
} else {
- Char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
- if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
- if (buf) {
- if (val) *val = new String(buf, size - 1);
- if (alloc == SWIG_NEWOBJ) %delete_array(buf);
- return SWIG_NEWOBJ;
+ static int init = 0;
+ static swig_type_info* descriptor = 0;
+ if (!init) {
+ descriptor = SWIG_TypeQuery(#String " *");
+ init = 1;
+ }
+ if (descriptor) {
+ String *vptr;
+ if ((SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0) == SWIG_OK)) {
+ if (val) *val = vptr;
+ return SWIG_OLDOBJ;
}
}
- return 0;
}
+ return 0;
}
}
%enddef