1226031Sstas/*
2226031Sstas * Copyright (c) 2010 Kungliga Tekniska H��gskolan
3226031Sstas * (Royal Institute of Technology, Stockholm, Sweden).
4226031Sstas * All rights reserved.
5226031Sstas *
6226031Sstas * Portions Copyright (c) 2010 Apple Inc. All rights reserved.
7226031Sstas *
8226031Sstas * Redistribution and use in source and binary forms, with or without
9226031Sstas * modification, are permitted provided that the following conditions
10226031Sstas * are met:
11226031Sstas *
12226031Sstas * 1. Redistributions of source code must retain the above copyright
13226031Sstas *    notice, this list of conditions and the following disclaimer.
14226031Sstas *
15226031Sstas * 2. Redistributions in binary form must reproduce the above copyright
16226031Sstas *    notice, this list of conditions and the following disclaimer in the
17226031Sstas *    documentation and/or other materials provided with the distribution.
18226031Sstas *
19226031Sstas * 3. Neither the name of the Institute nor the names of its contributors
20226031Sstas *    may be used to endorse or promote products derived from this software
21226031Sstas *    without specific prior written permission.
22226031Sstas *
23226031Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24226031Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25226031Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26226031Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27226031Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28226031Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29226031Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30226031Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31226031Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32226031Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33226031Sstas * SUCH DAMAGE.
34226031Sstas */
35226031Sstas
36226031Sstastypedef void (*heim_type_init)(void *);
37226031Sstastypedef heim_object_t (*heim_type_copy)(void *);
38226031Sstastypedef int (*heim_type_cmp)(void *, void *);
39226031Sstastypedef unsigned long (*heim_type_hash)(void *);
40226031Sstas
41226031Sstastypedef struct heim_type_data *heim_type_t;
42226031Sstas
43226031Sstasenum {
44226031Sstas    HEIM_TID_NUMBER = 0,
45226031Sstas    HEIM_TID_NULL = 1,
46226031Sstas    HEIM_TID_BOOL = 2,
47226031Sstas    HEIM_TID_TAGGED_UNUSED2 = 3,
48226031Sstas    HEIM_TID_TAGGED_UNUSED3 = 4,
49226031Sstas    HEIM_TID_TAGGED_UNUSED4 = 5,
50226031Sstas    HEIM_TID_TAGGED_UNUSED5 = 6,
51226031Sstas    HEIM_TID_TAGGED_UNUSED6 = 7,
52226031Sstas    HEIM_TID_MEMORY = 128,
53226031Sstas    HEIM_TID_ARRAY = 129,
54226031Sstas    HEIM_TID_DICT = 130,
55226031Sstas    HEIM_TID_STRING = 131,
56226031Sstas    HEIM_TID_AUTORELEASE = 132,
57226031Sstas    HEIM_TID_USER = 255
58226031Sstas
59226031Sstas};
60226031Sstas
61226031Sstasstruct heim_type_data {
62226031Sstas    heim_tid_t tid;
63226031Sstas    const char *name;
64226031Sstas    heim_type_init init;
65226031Sstas    heim_type_dealloc dealloc;
66226031Sstas    heim_type_copy copy;
67226031Sstas    heim_type_cmp cmp;
68226031Sstas    heim_type_hash hash;
69226031Sstas};
70226031Sstas
71226031Sstasheim_type_t _heim_get_isa(heim_object_t);
72226031Sstas
73226031Sstasheim_type_t
74226031Sstas_heim_create_type(const char *name,
75226031Sstas		  heim_type_init init,
76226031Sstas		  heim_type_dealloc dealloc,
77226031Sstas		  heim_type_copy copy,
78226031Sstas		  heim_type_cmp cmp,
79226031Sstas		  heim_type_hash hash);
80226031Sstas
81226031Sstasheim_object_t
82226031Sstas_heim_alloc_object(heim_type_t type, size_t size);
83226031Sstas
84226031Sstasheim_tid_t
85226031Sstas_heim_type_get_tid(heim_type_t type);
86226031Sstas
87226031Sstas/* tagged tid */
88226031Sstasextern struct heim_type_data _heim_null_object;
89226031Sstasextern struct heim_type_data _heim_bool_object;
90226031Sstasextern struct heim_type_data _heim_number_object;
91226031Sstasextern struct heim_type_data _heim_string_object;
92