blob: 38d82f06483b10cef0a21cd4273edc3540f9ef75 [file] [log] [blame]
from . import CWrapPlugin
class NullableArguments(CWrapPlugin):
def process_single_check(self, code, arg, arg_accessor):
if 'nullable' in arg and arg['nullable']:
return '({} || {} == Py_None)'.format(code, arg_accessor)
return code
def process_single_unpack(self, code, arg, arg_accessor):
if 'nullable' in arg and arg['nullable']:
return '({} == Py_None ? NULL : {})'.format(arg_accessor, code)
return code
class UndefinedArguments(CWrapPlugin):
def process_single_check(self, code, arg, arg_accessor):
if 'nullable' in arg and arg['nullable']:
return '({} || {} == Py_None)'.format(code, arg_accessor)
return code
def process_single_unpack(self, code, arg, arg_accessor):
if 'nullable' in arg and arg['nullable']:
return '({} == Py_None ? at::Tensor() : {})'.format(arg_accessor, code)
return code