Skip to content

function: Handle case of a bare GDestroyNotify in a function's args

Philip Chimento requested to merge ptomato/gjs:221-param-unknown into master

For example, g_memory_input_stream_new_from_data() has a GDestroyNotify parameter which isn't associated with a callback, but with static data. I don't know of an annotation which will express the relation of a destroy parameter to anything other than a callback.

Previously, since we assumed that all GDestroyNotify parameters were associated with callbacks, we'd mark their type as PARAM_SKIPPED. Their GIArgument would later be filled in when processing the calllback parameter. In the case of g_memory_input_stream_new_from_data(), this would crash because there was no callback parameter, so the GIArgument of the destroy parameter would never be filled in, and uninitialized data would be passed to the C function.

Instead, mark such parameters as PARAM_UNKNOWN, a new parameter type indicating that we don't know what to pass for that parameter. If JS code tries to call a function with a PARAM_UNKNOWN parameter, then an exception will be thrown.

Closes: #221 (closed)

Merge request reports