Last change
on this file since 524 was
496,
checked in by Sam Hocevar, 12 years ago
|
lisp: implement LObject::Eval.
|
-
Property svn:keywords set to
Id
|
File size:
1.2 KB
|
Line | |
---|
1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com or |
---|
8 | * Jonathan Clark. |
---|
9 | */ |
---|
10 | |
---|
11 | #include "stack.h" |
---|
12 | #ifndef __LISP_GC_HPP_ |
---|
13 | #define __LISP_GC_HPP_ |
---|
14 | |
---|
15 | extern grow_stack<void> l_user_stack; // stack user progs can push data and have it GCed |
---|
16 | |
---|
17 | void collect_space(int which_space); // should be tmp or permenant |
---|
18 | |
---|
19 | void register_pointer(void *&addr); |
---|
20 | void unregister_pointer(void *&addr); |
---|
21 | |
---|
22 | // This pointer reference stack lists all pointers to temporary lisp |
---|
23 | // objects. This allows the pointers to be automatically modified if an |
---|
24 | // object allocation triggers a garbage collection. |
---|
25 | class PtrRef |
---|
26 | { |
---|
27 | public: |
---|
28 | template<typename T> inline PtrRef(T *&ref) |
---|
29 | { |
---|
30 | stack.push((void **)&ref); |
---|
31 | } |
---|
32 | |
---|
33 | template<typename T> inline PtrRef(T * const &ref) |
---|
34 | { |
---|
35 | stack.push((void **)&ref); |
---|
36 | } |
---|
37 | |
---|
38 | inline ~PtrRef() |
---|
39 | { |
---|
40 | stack.pop(1); |
---|
41 | } |
---|
42 | |
---|
43 | // stack of user pointers, user pointers get remapped on GC |
---|
44 | static grow_stack<void *>stack; |
---|
45 | }; |
---|
46 | |
---|
47 | #endif |
---|
48 | |
---|
Note: See
TracBrowser
for help on using the repository browser.