[go: up one dir, main page]

Menu

[897c37]: / lpvm / object.h  Maximize  Restore  History

Download this file

155 lines (122 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* Definition of an object. If the object is inherited, then it must not be
* destructed !
* Really I'd like to have two object structures (I guess we needs "types"
* of object (as well as object type signatures):
* - named objects (as below)
* - unnamed objects which are essentially "classes"
* (these would be a similar but much smaller struct).
* These could have their variables accessed via
* "named" fields (ie. the names of the variables);
* although we'd need to "import" the definition so we
* didn't need to carry about the global names. hmm..
*
* -- Geoff
*/
#ifndef _OBJECT_H
#define _OBJECT_H
#include <stdint.h>
#include "magic.h"
#include "stralloc.h"
struct object;
struct vector;
struct vector_regexp;
union u
{
Shared * string;
int32_t number;
float real; /* check that it fits :) */
void * handle;
struct object * ob;
struct vector * vec;
struct vector_regexp * reg;
};
struct value
{
union u u;
int type;
};
typedef struct value Val;
struct object
{
#ifdef SHMAGIC
void * magic[2];
#endif
char enable_commands; /* Enable usage of sentence commands */
char cloned; /* A cloned object - pointless. */
char destructed; /* True when the object is destructed */
unsigned short ref; /* Reference count. */
unsigned short level; /* capability based security */
struct CLASS * code; /* class we're cloned from */
struct interactive *interactive;
/* Data about an interactive player */
/* do we give a shit? should this */
/* be passed into LPC and forgotten here? */
/* named object stuff (as opposed to class stuff) */
Shared * name;
Shared * su_name; /* playername for owner */
struct object * next_inv, *next_hash;
struct object * contains;
struct object * super; /* Which object surround us ? */
struct value variables[1];
/* All variables to this program */
/* nice to be of T_POINTER type.. */
};
typedef struct object Obj;
/* new object stuff */
struct CLASS
{
char inherited;
char file_was_suid; /* this is kind of ugly */
unsigned short ref; /* Reference count. */
unsigned short num_variables; /* Number of variables (total) */
unsigned short num_constants; /* number of constants */
Shared * name; /* file we originally came from */
struct function_def * prog;
struct value ** global_table; /* sigh */
struct constval ** constant_table; /* ho hum */
struct CLASS ** inherit; /* Where to inherit from */
/* a list of inheritance pointers */
int * inherit_offsets;
};
typedef struct CLASS Class;
struct OBJECT
{
unsigned short ref; /* Reference count. */
char destructed; /* True when the object is destructed */
char enable_commands; /* Enable move_object support */
Class * code;
// Stuff it'd be nice to handle in others ways
// and not carry around with every object
Shared * name;
Shared * su_name; /* playername for owner */
struct object * next_inv, *next_hash;
struct object * contains;
struct object * super; /* Which object surround us ? */
int level; /* capability based security */
struct interactive *interactive;
/* Data about an interactive player */
struct value * variables;
/* All variables to this program */
/* nice to be of T_POINTER type.. */
};
typedef struct OBJECT Object;
extern struct object *current_object, *command_giver;
extern struct object *obj_list;
/* Runtime definitions - mud only */
void remove_destructed_objects(),
add_ref (struct object *, char *),
free_object (struct object *, char *);
extern int show_otable_status ();
extern Obj
* get_empty_object(),
* find_object(Shared *),
* find_object2(Shared *),
* find_object_cstr(char *),
* instantiate_class(Class * code),
* load_object(Shared *name)
;
void add_functions(Class * obj, Class * which_obj, short offset),
remove_functions(Class * obj, Class * which_obj)
;
#endif