01: /*
02: * $Id: CPtr.java,v 1.4 2006/12/22 14:06:40 thiago Exp $
03: * Copyright (C) 2003-2007 Kepler Project.
04: *
05: * Permission is hereby granted, free of charge, to any person obtaining
06: * a copy of this software and associated documentation files (the
07: * "Software"), to deal in the Software without restriction, including
08: * without limitation the rights to use, copy, modify, merge, publish,
09: * distribute, sublicense, and/or sell copies of the Software, and to
10: * permit persons to whom the Software is furnished to do so, subject to
11: * the following conditions:
12: *
13: * The above copyright notice and this permission notice shall be
14: * included in all copies or substantial portions of the Software.
15: *
16: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22: * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23: */
24:
25: package org.keplerproject.luajava;
26:
27: /**
28: * An abstraction for a C pointer data type. A CPtr instance represents, on
29: * the Java side, a C pointer. The C pointer could be any <em>type</em> of C
30: * pointer.
31: */
32: public class CPtr {
33:
34: /**
35: * Compares this <code>CPtr</code> to the specified object.
36: *
37: * @param other a <code>CPtr</code>
38: * @return true if the class of this <code>CPtr</code> object and the
39: * class of <code>other</code> are exactly equal, and the C
40: * pointers being pointed to by these objects are also
41: * equal. Returns false otherwise.
42: */
43: public boolean equals(Object other) {
44: if (other == null)
45: return false;
46: if (other == this )
47: return true;
48: if (CPtr.class != other.getClass())
49: return false;
50: return peer == ((CPtr) other).peer;
51: }
52:
53: /* Pointer value of the real C pointer. Use long to be 64-bit safe. */
54: private long peer;
55:
56: /**
57: * Gets the value of the C pointer abstraction
58: * @return long
59: */
60: protected long getPeer() {
61: return peer;
62: }
63:
64: /* No-args constructor. */
65: CPtr() {
66: }
67:
68: }
|