+ // Equality operator
+ public static bool operator == (BaseHandle x, BaseHandle y)
+ {
+ // if the C# objects are the same return true
+ if( BaseHandle.ReferenceEquals( x, y ) )
+ {
+ return true;
+ }
+ if ( !BaseHandle.ReferenceEquals( x, null ) && !BaseHandle.ReferenceEquals( y, null ) )
+ {
+ // drop into native code to see if both handles point to the same body
+ return x.IsEqual( y) ;
+ }
+ return false;
+
+ }
+
+ // Inequality operator. Returns Null if either operand is Null
+ public static bool operator !=(BaseHandle x, BaseHandle y)
+ {
+ return !(x==y);
+ }
+
+ // Logical AND operator for &&
+ // It's possible when doing a && this function (opBitwiseAnd) is never called due
+ // to short circuiting. E.g.
+ // If you perform x && y What actually is called is
+ // BaseHandle.op_False( x ) ? BaseHandle.op_True( x ) : BaseHandle.opTrue( BaseHandle.opBitwiseAnd(x,y) )
+ //
+ public static BaseHandle operator &(BaseHandle x, BaseHandle y)
+ {
+ if( x == y )
+ {
+ return x;
+ }
+ return null;
+ }
+
+ // Logical OR operator for ||
+ // It's possible when doing a || this function (opBitwiseOr) is never called due
+ // to short circuiting. E.g.
+ // If you perform x || y What actually is called is
+ // BaseHandle.op_True( x ) ? BaseHandle.op_True( x ) : BaseHandle.opTrue( BaseHandle.opBitwiseOr(x,y) )
+ public static BaseHandle operator |(BaseHandle x, BaseHandle y)
+ {
+ if ( !BaseHandle.ReferenceEquals( x, null ) || !BaseHandle.ReferenceEquals( y, null ) )
+ {
+ if( x.HasBody() )
+ {
+ return x;
+ }
+ if( y.HasBody() )
+ {
+ return y;
+ }
+ return null;
+ }
+ return null;
+ }
+
+ // Logical ! operator
+ public static bool operator !(BaseHandle x)
+ {
+ // if the C# object is null, return true
+ if( BaseHandle.ReferenceEquals( x, null ) )
+ {
+ return true;
+ }
+ if( x.HasBody() )
+ {
+ return false;
+ }
+ return true;
+ }