summaryrefslogtreecommitdiff
path: root/Lib/lua
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-08-20 15:40:53 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-08-31 19:40:14 +0100
commite139a3651157a42e0086b15ce9df5dcba48cf4b2 (patch)
tree22d0c28382122bb3cd6b291d3dfa5a86e4e1d9b5 /Lib/lua
parent0634883089550070c55e53a9f788a6794f3efaf2 (diff)
downloadswig-e139a3651157a42e0086b15ce9df5dcba48cf4b2.tar.gz
SWIGTYPE && input typemaps now assume object has been moved
Replicated Java implementation. Fully implemented for: - C# - D - Guile - Javascript (UTL) - Lua - MzScheme - Octave (UTL) - Perl (UTL) - PHP - Python (UTL) - Ruby (UTL) - Tcl (UTL) PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
Diffstat (limited to 'Lib/lua')
-rw-r--r--Lib/lua/luatypemaps.swg14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg
index fdb9b3a97..7d23917ee 100644
--- a/Lib/lua/luatypemaps.swg
+++ b/Lib/lua/luatypemaps.swg
@@ -151,11 +151,17 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
}
%}
-%typemap(in,checkfn="lua_isuserdata") SWIGTYPE&&
-%{
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){
- SWIG_fail_ptr("$symname",$argnum,$descriptor);
+%typemap(in,checkfn="lua_isuserdata",fragment="<memory>") SWIGTYPE&& (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) %{
+ res = SWIG_ConvertPtr(L, $input, &argp, $descriptor, SWIG_POINTER_RELEASE);
+ if (!SWIG_IsOK(res)) {
+ if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
+ lua_pushfstring(L, "Cannot release ownership as memory is not owned for argument $argnum of type '$1_type' in $symname"); SWIG_fail;
+ } else {
+ SWIG_fail_ptr("$symname", $argnum, $descriptor);
+ }
}
+ $1 = ($1_ltype)argp;
+ rvrdeleter.reset($1);
%}
// out is simple