generator: null check for handle (NativeStructGen)

Check Handle against IntPtr.Zero before marshalling.
generator: added handling of optional parameters