mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
New file.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1241 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
17de3bd4bc
commit
9e44cc662c
24 changed files with 11364 additions and 0 deletions
95
Source/o_cbs_id.m
Normal file
95
Source/o_cbs_id.m
Normal file
|
@ -0,0 +1,95 @@
|
|||
/* Callbacks for the Objective-C object type. */
|
||||
/* Copyright (C) 1996 Free Software Foundation, Inc. */
|
||||
|
||||
/* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
|
||||
* Created: Sat Feb 10 15:55:51 EST 1996
|
||||
* Updated: Sun Feb 11 01:42:20 EST 1996
|
||||
* Serial: 96.02.11.05
|
||||
*
|
||||
* This file is part of the GNU Objective C Class Library.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/**** Included Headers *******************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <objects/callbacks.h>
|
||||
|
||||
/**** Type, Constant, and Macro Definitions **********************************/
|
||||
|
||||
/* FIXME: Is this right?!? */
|
||||
#define _OBJECTS_NOT_AN_ID_MARKER (const void *)(-1)
|
||||
|
||||
const void *objects_not_an_id_marker = _OBJECTS_NOT_AN_ID_MARKER;
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_id =
|
||||
{
|
||||
(objects_hash_func_t) objects_id_hash,
|
||||
(objects_compare_func_t) objects_id_compare,
|
||||
(objects_is_equal_func_t) objects_id_is_equal,
|
||||
(objects_retain_func_t) objects_id_retain,
|
||||
(objects_release_func_t) objects_id_release,
|
||||
(objects_describe_func_t) objects_id_describe,
|
||||
_OBJECTS_NOT_AN_ID_MARKER
|
||||
};
|
||||
|
||||
/**** Function Implementations ***********************************************/
|
||||
|
||||
/* FIXME: It sure would be nice if we had a way of checking whether
|
||||
* or not these objects responded to the messages we're sending them here.
|
||||
* We need a way that is independent of whether we have GNUStep objects,
|
||||
* NEXTSTEP objects, or GNU objects. We could certainly just use the
|
||||
* same trick that the `respondsToSelector:' method itself uses, but I'd hoped
|
||||
* that there was already a built-in call to do this sort of thing. */
|
||||
|
||||
size_t
|
||||
objects_id_hash(id obj)
|
||||
{
|
||||
return (size_t)[obj hash];
|
||||
}
|
||||
|
||||
int
|
||||
objects_id_compare(id obj, id jbo)
|
||||
{
|
||||
return (int)[obj compare:jbo];
|
||||
}
|
||||
|
||||
int
|
||||
objects_id_is_equal(id obj, id jbo)
|
||||
{
|
||||
return (int)[obj isEqual:jbo];
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_id_retain(id obj)
|
||||
{
|
||||
return (const void *)[obj retain];
|
||||
}
|
||||
|
||||
void
|
||||
objects_id_release(id obj)
|
||||
{
|
||||
[obj release];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_id_describe(id obj)
|
||||
{
|
||||
return [obj description];
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue