| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef VMCSET_H |
| 19 |
#define VMCSET_H |
| 20 |
|
| 21 |
#include <stdlib.h> |
| 22 |
#include "vmtype.h" |
| 23 |
#include "vmobj.h" |
| 24 |
#include "vmglob.h" |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
class CVmObjCharSet: public CVmObject |
| 48 |
{ |
| 49 |
friend class CVmMetaclassCharSet; |
| 50 |
|
| 51 |
public: |
| 52 |
|
| 53 |
static class CVmMetaclass *metaclass_reg_; |
| 54 |
class CVmMetaclass *get_metaclass_reg() const { return metaclass_reg_; } |
| 55 |
|
| 56 |
|
| 57 |
virtual int is_of_metaclass(class CVmMetaclass *meta) const |
| 58 |
{ |
| 59 |
|
| 60 |
return (meta == metaclass_reg_ |
| 61 |
|| CVmObject::is_of_metaclass(meta)); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
static vm_obj_id_t create_from_stack(VMG_ const uchar **pc_ptr, |
| 66 |
uint argc); |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
static int call_stat_prop(VMG_ vm_val_t *result, |
| 73 |
const uchar **pc_ptr, uint *argc, |
| 74 |
vm_prop_id_t prop) |
| 75 |
{ |
| 76 |
|
| 77 |
return CVmObject::call_stat_prop(vmg_ result, pc_ptr, argc, prop); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
virtual void reserve_const_data(VMG_ class CVmConstMapper *, |
| 82 |
vm_obj_id_t ) |
| 83 |
{ |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
virtual void convert_to_const_data(VMG_ class CVmConstMapper *, |
| 89 |
vm_obj_id_t ) |
| 90 |
{ |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
static vm_obj_id_t create(VMG_ int in_root_set); |
| 99 |
|
| 100 |
|
| 101 |
static vm_obj_id_t create(VMG_ int in_root_set, const char *charset_name, |
| 102 |
size_t charset_name_len); |
| 103 |
|
| 104 |
|
| 105 |
static int is_charset(VMG_ vm_obj_id_t obj) |
| 106 |
{ return vm_objp(vmg_ obj)->is_of_metaclass(metaclass_reg_); } |
| 107 |
|
| 108 |
|
| 109 |
void notify_delete(VMG_ int in_root_set); |
| 110 |
|
| 111 |
|
| 112 |
void set_prop(VMG_ class CVmUndo *undo, |
| 113 |
vm_obj_id_t self, vm_prop_id_t prop, const vm_val_t *val); |
| 114 |
|
| 115 |
|
| 116 |
int get_prop(VMG_ vm_prop_id_t prop, vm_val_t *val, |
| 117 |
vm_obj_id_t self, vm_obj_id_t *source_obj, uint *argc); |
| 118 |
|
| 119 |
|
| 120 |
void notify_new_savept() { } |
| 121 |
void apply_undo(VMG_ struct CVmUndoRecord *) { } |
| 122 |
|
| 123 |
|
| 124 |
void mark_undo_ref(VMG_ struct CVmUndoRecord *) { } |
| 125 |
void remove_stale_undo_weak_ref(VMG_ struct CVmUndoRecord *) { } |
| 126 |
void mark_refs(VMG_ uint ) { } |
| 127 |
void remove_stale_weak_refs(VMG0_) { } |
| 128 |
|
| 129 |
|
| 130 |
void load_from_image(VMG_ vm_obj_id_t self, const char *ptr, size_t siz); |
| 131 |
|
| 132 |
|
| 133 |
virtual ulong rebuild_image(VMG_ char *buf, ulong buflen); |
| 134 |
|
| 135 |
|
| 136 |
void save_to_file(VMG_ class CVmFile *fp); |
| 137 |
|
| 138 |
|
| 139 |
void restore_from_file(VMG_ vm_obj_id_t self, |
| 140 |
class CVmFile *fp, class CVmObjFixup *fixups); |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
int equals(VMG_ vm_obj_id_t self, const vm_val_t *val, int depth) const; |
| 147 |
|
| 148 |
|
| 149 |
uint calc_hash(VMG_ vm_obj_id_t self, int depth) const; |
| 150 |
|
| 151 |
|
| 152 |
int is_changed_since_load() const { return FALSE; } |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
class CCharmapToLocal *get_to_local(VMG0_) const; |
| 159 |
class CCharmapToUni *get_to_uni(VMG0_) const; |
| 160 |
|
| 161 |
protected: |
| 162 |
|
| 163 |
CVmObjCharSet() { ext_ = 0; } |
| 164 |
|
| 165 |
|
| 166 |
CVmObjCharSet(VMG_ const char *charset_name, size_t charset_name_len); |
| 167 |
|
| 168 |
|
| 169 |
void alloc_ext(VMG_ const char *charset_name, size_t charset_name_len); |
| 170 |
|
| 171 |
|
| 172 |
const struct vmobj_charset_ext_t *get_ext_ptr() const |
| 173 |
{ return (vmobj_charset_ext_t *)ext_; } |
| 174 |
|
| 175 |
|
| 176 |
static int is_rt_mappable(wchar_t c, class CCharmapToLocal *to_local, |
| 177 |
class CCharmapToUni *to_uni); |
| 178 |
|
| 179 |
|
| 180 |
int getp_undef(VMG_ vm_obj_id_t, vm_val_t *, uint *) { return FALSE; } |
| 181 |
|
| 182 |
|
| 183 |
int getp_get_name(VMG_ vm_obj_id_t self, vm_val_t *val, uint *argc); |
| 184 |
|
| 185 |
|
| 186 |
int getp_is_known(VMG_ vm_obj_id_t self, vm_val_t *val, uint *argc); |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
int getp_is_mappable(VMG_ vm_obj_id_t self, vm_val_t *val, uint *argc); |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
int getp_is_rt_mappable(VMG_ vm_obj_id_t self, vm_val_t *val, uint *argc); |
| 201 |
|
| 202 |
|
| 203 |
static int (CVmObjCharSet::*func_table_[])( |
| 204 |
VMG_ vm_obj_id_t self, vm_val_t *retval, uint *argc); |
| 205 |
}; |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
struct vmobj_charset_ext_t |
| 211 |
{ |
| 212 |
|
| 213 |
class CCharmapToLocal *to_local; |
| 214 |
|
| 215 |
|
| 216 |
class CCharmapToUni *to_uni; |
| 217 |
|
| 218 |
|
| 219 |
size_t charset_name_len; |
| 220 |
|
| 221 |
|
| 222 |
char charset_name[1]; |
| 223 |
}; |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
class CVmMetaclassCharSet: public CVmMetaclass |
| 230 |
{ |
| 231 |
public: |
| 232 |
|
| 233 |
const char *get_meta_name() const { return "character-set/030001"; } |
| 234 |
|
| 235 |
|
| 236 |
void create_for_image_load(VMG_ vm_obj_id_t id) |
| 237 |
{ |
| 238 |
new (vmg_ id) CVmObjCharSet(); |
| 239 |
G_obj_table->set_obj_gc_characteristics(id, FALSE, FALSE); |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
void create_for_restore(VMG_ vm_obj_id_t id) |
| 244 |
{ |
| 245 |
new (vmg_ id) CVmObjCharSet(); |
| 246 |
G_obj_table->set_obj_gc_characteristics(id, FALSE, FALSE); |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
vm_obj_id_t create_from_stack(VMG_ const uchar **pc_ptr, uint argc) |
| 251 |
{ return CVmObjCharSet::create_from_stack(vmg_ pc_ptr, argc); } |
| 252 |
|
| 253 |
|
| 254 |
int call_stat_prop(VMG_ vm_val_t *result, |
| 255 |
const uchar **pc_ptr, uint *argc, |
| 256 |
vm_prop_id_t prop) |
| 257 |
{ |
| 258 |
return CVmObjCharSet::call_stat_prop(vmg_ result, pc_ptr, argc, prop); |
| 259 |
} |
| 260 |
}; |
| 261 |
|
| 262 |
#endif |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
VM_REGISTER_METACLASS(CVmObjCharSet) |