#NEWLINE# def __init__( self , sig , get_pointer , cconv = None ) : #NEWLINE# #INDENT# from .. typing.templates import AbstractTemplate , make_concrete_template , signature #NEWLINE# from . import ffi_forced_object #NEWLINE# if ( sig . return_type == ffi_forced_object ) : #NEWLINE# #INDENT# raise TypeError ( 'Cannot return a pyobject from a external function' ) #NEWLINE# #UNINDENT# self . sig = sig #NEWLINE# self . requires_gil = any ( ( ( a == ffi_forced_object ) for a in self . sig . args ) ) #NEWLINE# self . get_pointer = get_pointer #NEWLINE# self . cconv = cconv #NEWLINE# if get_pointer . requires_gil : #NEWLINE# #INDENT# class GilRequiringDefn ( AbstractTemplate ) : #NEWLINE# #INDENT# key = self . sig #NEWLINE# def generic( self , args , kws ) : #NEWLINE# #INDENT# if kws : #NEWLINE# #INDENT# raise TypeError ( 'does not support keyword arguments' ) #NEWLINE# #UNINDENT# coerced = [ ( actual if ( formal == ffi_forced_object ) else formal ) for ( actual , formal ) in zip ( args , self . key . args ) ] #NEWLINE# return signature ( self . key . return_type , * coerced ) #NEWLINE# #UNINDENT# #UNINDENT# template = GilRequiringDefn #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# template = make_concrete_template ( 'CFuncPtr' , sig , [ sig ] ) #NEWLINE# #UNINDENT# super ( ExternalFunctionPointer , self ) . __init__ ( template )