-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up GC by making WeakRef first class
- Loading branch information
Evan Phoenix
committed
Aug 24, 2009
1 parent
0d2d248
commit 90c657e
Showing
11 changed files
with
98 additions
and
52 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
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
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
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
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,16 @@ | ||
#include "builtin/weakref.hpp" | ||
#include "builtin/class.hpp" | ||
|
||
namespace rubinius { | ||
void WeakRef::init(STATE) { | ||
GO(cls_weakref).set(state->new_class("WeakRef", G(object))); | ||
G(cls_weakref)->set_object_type(state, WeakRefType); | ||
} | ||
|
||
WeakRef* WeakRef::create(STATE, Object* obj) { | ||
WeakRef* ref = state->new_object<WeakRef>(G(cls_weakref)); | ||
ref->set_object(obj); | ||
|
||
return ref; | ||
} | ||
} |
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,38 @@ | ||
#ifndef RBX_BUILTIN_WEAKREF_HPP | ||
#define RBX_BUILTIN_WEAKREF_HPP | ||
|
||
#include "builtin/object.hpp" | ||
#include "builtin/exception.hpp" | ||
#include "type_info.hpp" | ||
|
||
namespace rubinius { | ||
class WeakRef : public Object { | ||
public: | ||
const static object_type type = WeakRefType; | ||
|
||
private: | ||
Object* object_; | ||
|
||
public: | ||
|
||
// Ruby.primitive+ :weakref_object | ||
Object* object() { | ||
return object_; | ||
} | ||
|
||
void set_object(Object* obj) { | ||
object_ = obj; | ||
} | ||
|
||
static void init(STATE); | ||
|
||
// Ruby.primitive+ :weakref_new | ||
static WeakRef* create(STATE, Object* obj); | ||
|
||
bool alive_p() { | ||
return object_->reference_p(); | ||
} | ||
}; | ||
} | ||
|
||
#endif |
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
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
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
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
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