Tweaks.
This commit is contained in:
@@ -116,7 +116,6 @@ class ArenaContainer : public Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Allocation function.
|
// Allocation function.
|
||||||
void* Place(int size) {
|
void* Place(int size) {
|
||||||
ArenaContainerHeader* header = reinterpret_cast<ArenaContainerHeader*>(header_);
|
ArenaContainerHeader* header = reinterpret_cast<ArenaContainerHeader*>(header_);
|
||||||
@@ -132,7 +131,8 @@ class ArenaContainer : public Container {
|
|||||||
ObjHeader* PlaceObject(const TypeInfo* type_info);
|
ObjHeader* PlaceObject(const TypeInfo* type_info);
|
||||||
|
|
||||||
// Places an array of certain type in this container. Note that array_type_info
|
// Places an array of certain type in this container. Note that array_type_info
|
||||||
// is type infor for an array, not for an individual element.
|
// is type info for an array, not for an individual element. Also note that exactly
|
||||||
|
// same operation could be used to place strings.
|
||||||
ArrayHeader* PlaceArray(const TypeInfo* array_type_info, int count);
|
ArrayHeader* PlaceArray(const TypeInfo* array_type_info, int count);
|
||||||
|
|
||||||
// Dispose whole container ignoring non-zero refcount. Use with care.
|
// Dispose whole container ignoring non-zero refcount. Use with care.
|
||||||
@@ -247,10 +247,6 @@ class ObjRef : public AnyObjRef {
|
|||||||
ObjRef(const ObjRef& other) : AnyObjRef(nullptr) {
|
ObjRef(const ObjRef& other) : AnyObjRef(nullptr) {
|
||||||
Assign(other);
|
Assign(other);
|
||||||
}
|
}
|
||||||
ObjRef& operator=(const ObjRef& other) {
|
|
||||||
Assign(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
void Assign(const ObjRef<T>& other) {
|
void Assign(const ObjRef<T>& other) {
|
||||||
AnyObjRef::Assign(other);
|
AnyObjRef::Assign(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void ReturnByValue(ObjRef<List> value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjRef<List> ReturnByRef(ArenaContainer* container) {
|
ObjRef<List> ReturnByRef(ArenaContainer* container) {
|
||||||
auto result = ObjRef<List>::Alloc(container);
|
ObjRef<List> result(ObjRef<List>::Alloc(container));
|
||||||
result.at<int, data_offset>().set(30);
|
result.at<int, data_offset>().set(30);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -88,18 +88,18 @@ void test_placer() {
|
|||||||
// Pass by reference.
|
// Pass by reference.
|
||||||
while (!cur.null()) {
|
while (!cur.null()) {
|
||||||
UpdateElement(cur);
|
UpdateElement(cur);
|
||||||
cur = cur.at<ObjRef<List>, next_offset>().get();
|
cur.Assign(cur.at<ObjRef<List>, next_offset>().get());
|
||||||
}
|
}
|
||||||
// Pass by value.
|
// Pass by value.
|
||||||
while (!cur.null()) {
|
while (!cur.null()) {
|
||||||
// We could place clone on stack as well.
|
// We could place clone on stack as well.
|
||||||
DoNotUpdateElement(cur.Clone(&heap));
|
DoNotUpdateElement(cur.Clone(&heap));
|
||||||
cur = cur.at<ObjRef<List>, next_offset>().get();
|
cur.Assign(cur.at<ObjRef<List>, next_offset>().get());
|
||||||
}
|
}
|
||||||
cur = head;
|
cur = head;
|
||||||
while (!cur.null()) {
|
while (!cur.null()) {
|
||||||
printf("next is %d\n", cur.at<int, data_offset>().get());
|
printf("next is %d\n", cur.at<int, data_offset>().get());
|
||||||
cur = cur.at<ObjRef<List>, next_offset>().get();
|
cur.Assign(cur.at<ObjRef<List>, next_offset>().get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
heap.Dispose();
|
heap.Dispose();
|
||||||
|
|||||||
Reference in New Issue
Block a user