Object.h
inter/Object.h · 2.4 KB
From the archive interlude_1beta5.tar.gz
Download the archive « Back to the archive contents
#ifndef OBJECT_H
#define OBJECT_H 1
#pragma interface
#include "Structures.h"
#include "command.h"
/************************************************************************
************ Object: the big deal ... one object. *********************
************************************************************************/
#define MAXPARENTS 20 /** basically, nothing should have more, but */
/** if they do, this will cope. */
#define NOPARENTS -1
class intlist{
friend class Object;
friend class Object_Store;
friend class Frame;
protected:
int allocated;
int size;
int *list;
void grow(int by = MAXPARENTS);
public:
intlist(char** inbuff_ptr, int max = MAXPARENTS);
intlist(int iparent, int max = MAXPARENTS);
intlist(int* vallist, int max = MAXPARENTS); /** -1 terminated **/
intlist(); /** creates an empty intlist **/
~intlist();
int check_is_inlist (int i);
void set_contents (intlist source);
void push (int);
void pop ();
int peek ();
char* dump (char*);
void dump_to_stdout();
Value* toval ();
};
class Object {
friend class intlist;
friend class Value;
friend class StringValHash;
friend class ReStringHash;
friend class Object_Store;
public:
Object (ifstream*, int onum); // compile an object
Object (char* buffer, int object_num); // construct from packed memory
Object (int oid, int iparent = NOPARENTS); // creates a blank new object
~Object();
int set_var (String* name, Value* initial_val)
{return symbols.add(initial_val, name);}
Value* lookup_var (String* name) {return symbols.lookup(name);}
char* pack_object(char* buf);
Value* get_parent_list();
Value* tostr();
Value* list_vars () {return symbols.list_vars();}
int set_sym (Value*, String*); /* returns 0 if string not already used */
int rm_sym (String*);
int add_cmd (Val_List* key, String* data);
int rm_cmd (String*);
void purge_cmds ();
Value* list_cmds () {return commands.list_cmds();}
String* match_cmd (String* pattern) {return commands.lookup (pattern);}
Val_List* all_matches (String* pattern)
{return commands.lookup_all (pattern);}
void dump_to_stdout();
int change_parents (int* ilist);
protected:
StringValHash symbols;
CommandList commands;
intlist *parents;
int id;
};
#endif /* OBJECT_H */