Export provisioning sdk
Change-Id: I4d47d80444c9507f84896767dc676112ca11e901
This commit is contained in:
51
provisioning_sdk/public/python/unique_ptr.i
Normal file
51
provisioning_sdk/public/python/unique_ptr.i
Normal file
@@ -0,0 +1,51 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 T> class unique_ptr {};
|
||||
}
|
||||
|
||||
%define _UNIQUE_PTR_TEMPLATE(type)
|
||||
template <> class std::unique_ptr <type> {};
|
||||
%enddef
|
||||
|
||||
%define UNIQUE_PTR(type)
|
||||
_UNIQUE_PTR_TEMPLATE(type);
|
||||
|
||||
%typemap(out) std::unique_ptr<type> %{
|
||||
$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<type> %{
|
||||
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<type>* arg_name
|
||||
(std::unique_ptr<type> temp) %{
|
||||
$1 = &temp;
|
||||
%}
|
||||
|
||||
%typemap(argout) std::unique_ptr<type>* arg_name %{
|
||||
%append_output(SWIG_NewPointerObj(SWIG_as_voidptr($1->release()),
|
||||
$descriptor(type*), SWIG_POINTER_OWN));
|
||||
%}
|
||||
%enddef
|
||||
Reference in New Issue
Block a user