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
25 #ifndef __ST_BEHAVIOR_H__
26 #define __ST_BEHAVIOR_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))
39 struct st_header header
;
44 st_oop method_dictionary
;
45 st_oop instance_variables
;
50 struct st_behavior parent
;
57 struct st_behavior parent
;
59 st_oop instance_class
;
62 #define ST_BEHAVIOR_FORMAT(oop) (ST_BEHAVIOR (oop)->format)
63 #define ST_BEHAVIOR_SUPERCLASS(oop) (ST_BEHAVIOR (oop)->superclass)
64 #define ST_BEHAVIOR_INSTANCE_SIZE(oop) (ST_BEHAVIOR (oop)->instance_size)
65 #define ST_BEHAVIOR_METHOD_DICTIONARY(oop) (ST_BEHAVIOR (oop)->method_dictionary)
66 #define ST_BEHAVIOR_INSTANCE_VARIABLES(oop) (ST_BEHAVIOR (oop)->instance_variables)
67 #define ST_CLASS_NAME(oop) (ST_CLASS (oop)->name)
68 #define ST_METACLASS_INSTANCE_CLASS(oop) (ST_METACLASS (oop)->instance_class)
72 st_object_new (st_oop
class)
74 return st_descriptors
[st_smi_value (ST_BEHAVIOR (class)->format
)]->allocate (class);
78 st_object_new_arrayed (st_oop
class, st_smi size
)
80 return st_descriptors
[st_smi_value (ST_BEHAVIOR (class)->format
)]->allocate_arrayed (class, size
);
83 st_list
*st_behavior_all_instance_variables (st_oop
class);
87 #endif /* __ST_BEHAVIOR_H__ */