Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add an OwnedResizablePMCArray, along the same lines as OwnedHash.
- Loading branch information
Showing
2 changed files
with
230 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| /* Represents a ResizablePMCArray that is owned by a serialization context. | ||
| * If it gets modified, we need to trigger the SC write barrier. */ | ||
|
|
||
| #include "../6model/sixmodelobject.h" | ||
|
|
||
| pmclass OwnedResizablePMCArray extends ResizablePMCArray auto_attrs dynpmc group nqp { | ||
| /* The object that owns this RPA. */ | ||
| ATTR PMC *owner; | ||
|
|
||
| VTABLE void set_integer_keyed(PMC* key, INTVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_integer_keyed_str(STRING* key, INTVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
|
|
||
| VTABLE void set_number_keyed(PMC* key, FLOATVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_number_keyed_str(STRING* key, FLOATVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
|
|
||
| VTABLE void set_string_keyed(PMC* key, STRING* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_string_keyed_int(INTVAL key, STRING* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_string_keyed_str(STRING* key, STRING* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
|
|
||
| VTABLE void set_pmc_keyed(PMC* key, PMC* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_pmc_keyed_int(INTVAL key, PMC* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
| VTABLE void set_pmc_keyed_str(STRING* key, PMC* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(key, value); | ||
| } | ||
|
|
||
| VTABLE INTVAL pop_integer() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
| VTABLE FLOATVAL pop_float() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
| VTABLE STRING* pop_string() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
| VTABLE PMC* pop_pmc() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
|
|
||
| VTABLE void push_integer(INTVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
| VTABLE void push_float(FLOATVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
| VTABLE void push_string(STRING* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
| VTABLE void push_pmc(PMC* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
|
|
||
| VTABLE INTVAL shift_integer() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
| VTABLE FLOATVAL shift_float() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
| VTABLE STRING* shift_string() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
| VTABLE PMC* shift_pmc() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| return SUPER(); | ||
| } | ||
|
|
||
| VTABLE void unshift_integer(INTVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
| VTABLE void unshift_float(FLOATVAL value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
| VTABLE void unshift_string(STRING* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
| VTABLE void unshift_pmc(PMC* value) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value); | ||
| } | ||
|
|
||
| void splice(PMC* value, INTVAL offset, INTVAL count) { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| if (!PMC_IS_NULL(owner)) | ||
| OBJ_SC_WRITE_BARRIER(owner); | ||
| SUPER(value, offset, count); | ||
| } | ||
|
|
||
| VTABLE void mark() { | ||
| PMC *owner; | ||
| GET_ATTR_owner(interp, SELF, owner); | ||
| Parrot_gc_mark_PMC_alive(INTERP, owner); | ||
| SUPER(); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters