BladeSmithJohn / nixysa

Automatically exported from code.google.com/p/nixysa
Apache License 2.0
0 stars 0 forks source link

nullable (?) IDL return values are never actually null. #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Declare a class with [binding_model=by_pointer]
2. Define a nullable return value on a member function. 

In my case: 
[binding_model=by_pointer] class MyClass {
  ...
  [static] MyObject? myFunction(int x); 
}

Despite explicitly declaring this member as nullable, a wrapper object is 
always returned. 

The cause of this is the function GetNPObject defined in 
by_pointer_binding.py which ignores the passed value and always returns the 
proxy wrapper object. This is easily fixed with the one line change below.

--- a/plugin/third_party/nixysa/by_pointer_binding.py
+++ b/plugin/third_party/nixysa/by_pointer_binding.py
@@ -334,6 +334,7 @@ static void Deallocate(NPObject *header) {
 }

 NPAPIObject *GetNPObject(NPP npp, ${Class} *object) {
+  if(object == NULL) return NULL;
   NPAPIObject *npobject = static_cast<NPAPIObject *>(
       NPN_CreateObject(npp, &npclass));
   npobject->set_value(object);

Original issue reported on code.google.com by aaron...@gmail.com on 25 Aug 2009 at 11:01

GoogleCodeExporter commented 9 years ago

Original comment by piman+personal@google.com on 28 Aug 2009 at 2:42

GoogleCodeExporter commented 9 years ago

Original comment by pimanttr3@gmail.com on 2 Sep 2009 at 12:26