001 /*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005 package org.bridj;
006
007 import java.util.Stack;
008
009 /**
010 * Base class for native objects.
011 * @author Olivier
012 */
013 public abstract class NativeObject implements NativeObjectInterface {
014
015 protected Pointer<? extends NativeObject> peer;
016 protected BridJRuntime.TypeInfo typeInfo;
017
018 protected NativeObject(Pointer<? extends NativeObject> peer) {
019 BridJ.initialize(this, peer);
020 }
021
022 protected NativeObject() {
023 BridJ.initialize(this);
024 }
025
026 protected NativeObject(int constructorId, Object... args) {
027 BridJ.initialize(this, constructorId, args);
028 }
029 /*
030 @Override
031 protected void finalize() throws Throwable {
032 BridJ.deallocate(this);
033 }*/
034
035 public NativeObject clone() throws CloneNotSupportedException {
036 return BridJ.clone(this);
037 }
038
039 @Override
040 public boolean equals(Object o) {
041 if (!(o instanceof NativeObject))
042 return false;
043
044 return typeInfo.equal(this, (NativeObject)o);
045 }
046 }