| 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 |
#ifndef VMCOLL_H |
| 26 |
#define VMCOLL_H |
| 27 |
|
| 28 |
#include <stdlib.h> |
| 29 |
#include "vmtype.h" |
| 30 |
#include "vmobj.h" |
| 31 |
#include "vmglob.h" |
| 32 |
#include "vmerr.h" |
| 33 |
#include "vmerrnum.h" |
| 34 |
|
| 35 |
|
| 36 |
class CVmObjCollection: public CVmObject |
| 37 |
{ |
| 38 |
friend class CVmMetaclassCollection; |
| 39 |
|
| 40 |
public: |
| 41 |
|
| 42 |
static class CVmMetaclass *metaclass_reg_; |
| 43 |
class CVmMetaclass *get_metaclass_reg() const { return metaclass_reg_; } |
| 44 |
|
| 45 |
|
| 46 |
virtual int is_of_metaclass(class CVmMetaclass *meta) const |
| 47 |
{ |
| 48 |
|
| 49 |
return (meta == metaclass_reg_ |
| 50 |
|| CVmObject::is_of_metaclass(meta)); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
static int call_stat_prop(VMG_ vm_val_t *result, |
| 58 |
const uchar **pc_ptr, uint *argc, |
| 59 |
vm_prop_id_t prop) |
| 60 |
{ return CVmObject::call_stat_prop(vmg_ result, pc_ptr, argc, prop); } |
| 61 |
|
| 62 |
|
| 63 |
int get_prop(VMG_ vm_prop_id_t prop, vm_val_t *retval, |
| 64 |
vm_obj_id_t self, vm_obj_id_t *source_obj, uint *argc); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
int const_get_coll_prop(VMG_ vm_prop_id_t prop, vm_val_t *retval, |
| 72 |
const vm_val_t *self_val, vm_obj_id_t *src_obj, |
| 73 |
uint *argc); |
| 74 |
|
| 75 |
protected: |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
virtual void new_iterator(VMG_ vm_val_t *retval, |
| 82 |
const vm_val_t *self_val) = 0; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
virtual void new_live_iterator(VMG_ vm_val_t *retval, |
| 90 |
const vm_val_t *self_val) = 0; |
| 91 |
|
| 92 |
|
| 93 |
int getp_undef(VMG_ vm_val_t *, const vm_val_t *, uint *) |
| 94 |
{ return FALSE; } |
| 95 |
|
| 96 |
|
| 97 |
int getp_create_iter(VMG_ vm_val_t *retval, const vm_val_t *self_val, |
| 98 |
uint *argc); |
| 99 |
|
| 100 |
|
| 101 |
int getp_create_live_iter(VMG_ vm_val_t *retval, |
| 102 |
const vm_val_t *self_val, uint *argc); |
| 103 |
|
| 104 |
|
| 105 |
static int (CVmObjCollection::*func_table_[])(VMG_ vm_val_t *retval, |
| 106 |
const vm_val_t *self_val, uint *argc); |
| 107 |
}; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
class CVmMetaclassCollection: public CVmMetaclass |
| 115 |
{ |
| 116 |
public: |
| 117 |
|
| 118 |
const char *get_meta_name() const { return "collection/030000"; } |
| 119 |
|
| 120 |
|
| 121 |
void create_for_image_load(VMG_ vm_obj_id_t id) |
| 122 |
{ err_throw(VMERR_BAD_STATIC_NEW); } |
| 123 |
|
| 124 |
|
| 125 |
void create_for_restore(VMG_ vm_obj_id_t id) |
| 126 |
{ err_throw(VMERR_BAD_STATIC_NEW); } |
| 127 |
|
| 128 |
|
| 129 |
vm_obj_id_t create_from_stack(VMG_ const uchar **pc_ptr, uint argc) |
| 130 |
{ |
| 131 |
err_throw(VMERR_BAD_DYNAMIC_NEW); |
| 132 |
AFTER_ERR_THROW(return VM_INVALID_OBJ;) |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
int call_stat_prop(VMG_ vm_val_t *result, |
| 137 |
const uchar **pc_ptr, uint *argc, |
| 138 |
vm_prop_id_t prop) |
| 139 |
{ |
| 140 |
return CVmObjCollection:: |
| 141 |
call_stat_prop(vmg_ result, pc_ptr, argc, prop); |
| 142 |
} |
| 143 |
}; |
| 144 |
|
| 145 |
#endif |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
VM_REGISTER_METACLASS(CVmObjCollection) |
| 151 |
|