Implemented a resizable heap abstraction over mmap(). Allows us to
[panda.git] / src / st-behavior.h
blob69b5a2bf2b4e9930a239630056cdb0d792e01e7d
1 /*
2 * st-behavior.h
4 * Copyright (C) 2008 Vincent Geddes
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #ifndef __ST_BEHAVIOR_H__
26 #define __ST_BEHAVIOR_H__
28 #include <st-types.h>
29 #include <st-object.h>
30 #include <st-memory.h>
31 #include <st-small-integer.h>
33 #define ST_BEHAVIOR(oop) ((struct st_behavior *) ST_POINTER (oop))
34 #define ST_CLASS(oop) ((struct st_class *) ST_POINTER (oop))
35 #define ST_METACLASS(oop) ((struct st_metaclass *) ST_POINTER (oop))
37 struct st_behavior
39 struct st_header header;
41 st_oop format;
42 st_oop superclass;
43 st_oop instance_size;
44 st_oop method_dictionary;
45 st_oop instance_variables;
48 struct st_class
50 struct st_behavior parent;
52 st_oop name;
55 struct st_metaclass
57 struct st_behavior parent;
59 st_oop instance_class;
62 static inline st_oop
63 st_object_new (st_space *space, st_oop class)
65 return st_descriptors[st_smi_value (ST_BEHAVIOR (class)->format)]->allocate (space, class);
68 static inline st_oop
69 st_object_new_arrayed (st_space *space, st_oop class, st_smi size)
71 return st_descriptors[st_smi_value (ST_BEHAVIOR (class)->format)]->allocate_arrayed (space, class, size);
74 st_list *st_behavior_all_instance_variables (st_oop class);
78 #endif /* __ST_BEHAVIOR_H__ */