title: Calling function with ctypes or pyObjc
body: <p>I want to make a call out to the IOKit framework from Python.</p>
  
  <p>Here's the signature of the Objective-C function I want to call:</p>
  
  <pre><code>IOReturn IODisplayGetFloatParameter(io_service_t service, IOOptionBits options, CFStringRef parameterName, float *value);
  </code></pre>
  
  <p>With <code>pyObjc</code>, after importing, I'd do this:</p>
  
  <pre><code>brightness = 0.0
  IODisplayGetFloatParameter(service, 0, kIODisplayBrightnessKey, brightness)
  </code></pre>
  
  <p>However, I get this error:</p>
  
  <pre><code>ValueError: depythonifying 'pointer', got 'float'
  </code></pre>
  
  <p>This is the relevant bit of the BridgeSupport file from which <code>pyObjc</code> is generating handles on <code>IOKit.IODisplayGetFloatParameter()</code>:</p>
  
  <pre><code>&lt;function name='IODisplayGetFloatParameter'&gt;
  &lt;arg type='I'/&gt;
  &lt;arg type='L' type64='I'/&gt;
  &lt;arg type='^{__CFString=}'/&gt;
  &lt;arg type='^f'/&gt;
  &lt;retval type='i'/&gt;
  </code></pre>
  
  <p>Which leads me to believe I need to create <code>pyObjc</code> object that represents a pointer that points to a <code>float</code>, but I'm having trouble finding the relevant documentation to do so.</p>
  
  <p>So, I tried to use <code>ctypes</code>, but it segfaults because I am not giving it the right <code>argtypes</code> nor passing the correct values to the function.</p>
  
  <pre><code>from ctypes import CDLL, c_void_p, byref, c_char_p, c_int, c_float, pointer, POINTER
  from ctypes.utils import find_library
  
  c_float_p = POINTER(c_float) 
  float_ptr = c_float_p(c_float(0.0))
  IOKit = CDLL(find_library('IOKit'))
  
  IOKit.IODisplaySetFloatParameter.argtypes = [c_int, c_int, c_char_p, c_float_p]
  IOKit.IODisplaySetFloatParameter(service_goes_here, 0, "brightness", float_pointer)
  Segmentation fault: 11
  </code></pre>
  
  <p>Can anyone point me in the direction of how to either:</p>
  
  <ol>
  <li>Pass a float pointer to a <code>pyObjc</code> wrapped function?</li>
  <li>Use <code>ctypes</code> to call <code>IODisplayGetFloatParameter</code>?</li>
  </ol>