I'm learning how to write natives, and I would like to have a native return a handle. My use-case is that I would either like to return a null ArrayList handle (0) in the case that the source handle is null, and the handle from a clone of the ArrayList in the case that it is not. In the code below, when trying to cast
null to an
int, I am getting
Code:
error 148: cannot assign null to a non-nullable type
However, the
documentation dictates that
null is just another representation for
INVALID_HANDLE, and replacing
null with
INVALID_HANDLE resolves the behavior. Is this a bug? I think being able to use
null in this context is
syntactic sugar. Is there some way to use
null instead?
PHP Code:
public int Native_GetExtensions(Handle plugin, numParams) {
ValidateNativeParams(0, numParams);
if (g_aExts == null) {
return view_as<int>(null);
}
return view_as<int>(g_aExts.Clone());
}