diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py index 35ccb5cc2809bd42539043599a01d9bb4fd9a641..72bd908a3a613aae45363ebfed2d7217795d4b52 100644 --- a/pyopencl/cffi_cl.py +++ b/pyopencl/cffi_cl.py @@ -214,17 +214,29 @@ def _parse_context_properties(properties): if len(prop_tuple) != 2: raise RuntimeError("Context", status_code.INVALID_VALUE, "property tuple must have length 2") prop, value = prop_tuple + if prop is None: + raise RuntimeError("Context", status_code.INVALID_VALUE, "invalid context property") + props.append(prop) if prop == context_properties.PLATFORM: props.append(value.int_ptr) - # elif prop == context_properties.WGL_HDC_KHR: - # raise NotImplementedError() - #elif - else: # TODO_PLAT CL_WGL_HDC_KHR and more + elif prop == getattr(context_properties, "WGL_HDC_KHR"): # TODO if _WIN32? Why? + props.append(value) + elif prop in [getattr(context_properties, key, None) for key in ( + 'CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE', + 'GL_CONTEXT_KHR', + 'EGL_DISPLAY_KHR', + 'GLX_DISPLAY_KHR', + 'CGL_SHAREGROUP_KHR', + )]: + # TODO: without ctypes? + import ctypes + val = (ctypes.cast(value, ctypes.c_void_p)).value + props.append(0 if val is None else val) + else: raise RuntimeError("Context", status_code.INVALID_VALUE, "invalid context property") props.append(0) - #c_props = [_ffi.new('cl_context_properties *', prop) for prop in props] - return _ffi.new('cl_context_properties[]', props) + return _ffi.new('intptr_t[]', props) class Context(_Common): diff --git a/src/c_wrapper/wrap_cl.cpp b/src/c_wrapper/wrap_cl.cpp index 715cf3e5b46d876e1a2fa992e559b30c0a022d44..cc51ff29dbb89bb0625498952500bca2df2528e6 100644 --- a/src/c_wrapper/wrap_cl.cpp +++ b/src/c_wrapper/wrap_cl.cpp @@ -804,7 +804,7 @@ generic_info get_info(cl_device_info param_name) const case CL_WGL_HDC_KHR: case CL_CGL_SHAREGROUP_KHR: #endif - info.type = "cl_context_properties *"; + info.type = "intptr_t *"; info.value = (void*)result[i+1]; break;