blob: ed7c009ee101a14a6aadc03cbafd67b78679aea7 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001/* This sefun is to provide the old semantics of the efun object_info().
2 * Feel free to add it to your mudlibs, if you have much code relying on that.
3 */
4
5#if __EFUN_DEFINED__(driver_info) /* Newer version is there */
6
7#include <objectinfo.h>
8#include <object_info.h>
9
10mixed object_info(object ob, int what, varargs int* index)
11{
12 mixed * result;
13
14 if (sizeof(index) > 1)
15 raise_error("Too many arguments to object_info\n");
16
17 switch(what)
18 {
19 default:
20 raise_error(sprintf("Illegal value %d for object_info().\n", what));
21
22 case OINFO_BASIC:
23 {
24 result = allocate(OIB_MAX);
25
26 result[OIB_HEART_BEAT] = efun::object_info(ob, OC_HEART_BEAT);
27 result[OIB_IS_WIZARD] = 0; /* Not supported anymore. */
28 result[OIB_ENABLE_COMMANDS] = efun::object_info(ob, OC_COMMANDS_ENABLED);
29 result[OIB_CLONE] = efun::clonep(ob);
30 result[OIB_DESTRUCTED] = 0; /* Not possible anymore. */
31 result[OIB_SWAPPED] = efun::object_info(ob, OI_SWAPPED);
32 result[OIB_ONCE_INTERACTIVE] = efun::object_info(ob, OI_ONCE_INTERACTIVE);
33 result[OIB_RESET_STATE] = efun::object_info(ob, OI_RESET_STATE);
34 result[OIB_WILL_CLEAN_UP] = efun::object_info(ob, OI_WILL_CLEAN_UP);
35 result[OIB_LAMBDA_REFERENCED] = efun::object_info(ob, OI_LAMBDA_REFERENCED);
36 result[OIB_SHADOW] = efun::object_info(ob, OI_SHADOW_PREV) && 1;
37 result[OIB_REPLACED] = efun::object_info(ob, OI_REPLACED);
38 result[OIB_NEXT_RESET] = efun::object_info(ob, OI_NEXT_RESET_TIME);
39 result[OIB_TIME_OF_REF] = efun::object_info(ob, OI_LAST_REF_TIME);
40 result[OIB_REF] = efun::object_info(ob, OI_OBJECT_REFS);
41 result[OIB_GIGATICKS] = efun::object_info(ob, OI_GIGATICKS);
42 result[OIB_TICKS] = efun::object_info(ob, OI_TICKS);
43 result[OIB_SWAP_NUM] = efun::object_info(ob, OI_SWAP_NUM);
44 result[OIB_PROG_SWAPPED] = efun::object_info(ob, OI_PROG_SWAPPED);
45 result[OIB_VAR_SWAPPED] = efun::object_info(ob, OI_VAR_SWAPPED);
46 result[OIB_NAME] = efun::object_name(ob);
47 result[OIB_LOAD_NAME] = efun::load_name(ob);
48 result[OIB_NEXT_ALL] = efun::object_info(ob, OI_OBJECT_NEXT);
49 result[OIB_PREV_ALL] = efun::object_info(ob, OI_OBJECT_PREV);
50 result[OIB_NEXT_CLEANUP] = efun::object_info(ob, OI_NEXT_CLEANUP_TIME);
51 break;
52 }
53
54 case OINFO_POSITION:
55 {
56 result = allocate(OIP_MAX);
57
58 result[OIP_NEXT] = efun::object_info(ob, OI_OBJECT_NEXT);
59 result[OIP_PREV] = efun::object_info(ob, OI_OBJECT_PREV);
60 result[OIP_POS] = efun::object_info(ob, OI_OBJECT_POS);
61 break;
62 }
63
64 case OINFO_MEMORY:
65 {
66 result = allocate(OIM_MAX);
67
68 result[OIM_REF] = efun::object_info(ob, OI_PROG_REFS);
69 result[OIM_NAME] = efun::program_name(ob);
70 result[OIM_PROG_SIZE] = efun::object_info(ob, OI_PROG_SIZE);
71 result[OIM_NUM_FUNCTIONS] = efun::object_info(ob, OI_NUM_FUNCTIONS);
72 result[OIM_SIZE_FUNCTIONS] = efun::object_info(ob, OI_SIZE_FUNCTIONS);
73 result[OIM_NUM_VARIABLES] = efun::object_info(ob, OI_NUM_VARIABLES);
74 result[OIM_SIZE_VARIABLES] = efun::object_info(ob, OI_SIZE_VARIABLES);
75 result[OIM_NUM_STRINGS] = efun::object_info(ob, OI_NUM_STRINGS);
76 result[OIM_SIZE_STRINGS] = efun::object_info(ob, OI_SIZE_STRINGS);
77 result[OIM_SIZE_STRINGS_DATA] = efun::object_info(ob, OI_SIZE_STRINGS_DATA);
78 result[OIM_SIZE_STRINGS_TOTAL] = efun::object_info(ob, OI_SIZE_STRINGS_DATA_TOTAL);
79 result[OIM_NUM_INHERITED] = efun::object_info(ob, OI_NUM_INHERITED);
80 result[OIM_SIZE_INHERITED] = efun::object_info(ob, OI_SIZE_INHERITED);
81 result[OIM_TOTAL_SIZE] = efun::object_info(ob, OI_PROG_SIZE_TOTAL);
82 result[OIM_DATA_SIZE] = efun::object_info(ob, OI_DATA_SIZE);
83 result[OIM_TOTAL_DATA_SIZE] = efun::object_info(ob, OI_DATA_SIZE_TOTAL);
84 result[OIM_NO_INHERIT] = efun::object_info(ob, OI_NO_INHERIT);
85 result[OIM_NO_CLONE] = efun::object_info(ob, OI_NO_CLONE);
86 result[OIM_NO_SHADOW] = efun::object_info(ob, OI_NO_SHADOW);
87 result[OIM_NUM_INCLUDES] = efun::object_info(ob, OI_NUM_INCLUDED);
88 result[OIM_SHARE_VARIABLES] = efun::object_info(ob, OI_SHARE_VARIABLES);
89 break;
90 }
91 }
92
93 if (sizeof(index))
94 {
95 int idx = index[0];
96 if (idx < 0 || idx >= sizeof(result))
97 raise_error(sprintf("Illegal index for object_info(): %d, expected 0..%d\n",
98 idx, sizeof(result)-1));
99
100 return result[idx];
101 }
102 else
103 return result;
104}
105
106#endif