Raised This Month: $51 Target: $400
 12% 

Returning null handle in native


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 05-28-2016 , 19:24   Returning null handle in native
Reply With Quote #1

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 pluginnumParams) {
  
ValidateNativeParams(0numParams);
  if (
g_aExts == null) {
    return 
view_as<int>(null);
  }

  return 
view_as<int>(g_aExts.Clone());

Tirant is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode