//////////////////////////////////////////////////////////////////////////////// // Copyright 2016 Google Inc. // // This software is licensed under the terms defined in the Widevine Master // License Agreement. For a copy of this agreement, please contact // widevine-licensing@google.com. //////////////////////////////////////////////////////////////////////////////// namespace std { template class unique_ptr {}; } %define _UNIQUE_PTR_TEMPLATE(type) template <> class std::unique_ptr {}; %enddef %define UNIQUE_PTR(type) _UNIQUE_PTR_TEMPLATE(type); %typemap(out) std::unique_ptr %{ $result = SWIG_NewPointerObj( SWIG_as_voidptr($1.release()), $descriptor(type*), SWIG_POINTER_OWN); %} %enddef %define UNIQUE_PTR_WITH_ERROR(type, err_str) _UNIQUE_PTR_TEMPLATE(type); %typemap(out) std::unique_ptr %{ if ($1) { $result = SWIG_NewPointerObj( SWIG_as_voidptr($1.release()), $descriptor(type*), SWIG_POINTER_OWN); } else { SWIG_exception(SWIG_ValueError, err_str); } %} %enddef %define UNIQUE_PTR_ARGOUT(type, arg_name) _UNIQUE_PTR_TEMPLATE(type) %typemap(in, numinputs=0) std::unique_ptr* arg_name (std::unique_ptr temp) %{ $1 = &temp; %} %typemap(argout) std::unique_ptr* arg_name %{ %append_output(SWIG_NewPointerObj(SWIG_as_voidptr($1->release()), $descriptor(type*), SWIG_POINTER_OWN)); %} %enddef