diff options
Diffstat (limited to 'src/lj_cdata.c')
-rw-r--r-- | src/lj_cdata.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lj_cdata.c b/src/lj_cdata.c index 53605e7e..d01cf62a 100644 --- a/src/lj_cdata.c +++ b/src/lj_cdata.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "lj_gc.h" | 10 | #include "lj_gc.h" |
11 | #include "lj_err.h" | 11 | #include "lj_err.h" |
12 | #include "lj_str.h" | 12 | #include "lj_str.h" |
13 | #include "lj_tab.h" | ||
13 | #include "lj_ctype.h" | 14 | #include "lj_ctype.h" |
14 | #include "lj_cconv.h" | 15 | #include "lj_cconv.h" |
15 | #include "lj_cdata.h" | 16 | #include "lj_cdata.h" |
@@ -74,6 +75,24 @@ void LJ_FASTCALL lj_cdata_free(global_State *g, GCcdata *cd) | |||
74 | } | 75 | } |
75 | } | 76 | } |
76 | 77 | ||
78 | TValue * LJ_FASTCALL lj_cdata_setfin(lua_State *L, GCcdata *cd) | ||
79 | { | ||
80 | global_State *g = G(L); | ||
81 | GCtab *t = ctype_ctsG(g)->finalizer; | ||
82 | if (gcref(t->metatable)) { | ||
83 | /* Add cdata to finalizer table, if still enabled. */ | ||
84 | TValue *tv, tmp; | ||
85 | setcdataV(L, &tmp, cd); | ||
86 | lj_gc_anybarriert(L, t); | ||
87 | tv = lj_tab_set(L, t, &tmp); | ||
88 | cd->marked |= LJ_GC_CDATA_FIN; | ||
89 | return tv; | ||
90 | } else { | ||
91 | /* Otherwise return dummy TValue. */ | ||
92 | return &g->tmptv; | ||
93 | } | ||
94 | } | ||
95 | |||
77 | /* -- C data indexing ----------------------------------------------------- */ | 96 | /* -- C data indexing ----------------------------------------------------- */ |
78 | 97 | ||
79 | /* Index C data by a TValue. Return CType and pointer. */ | 98 | /* Index C data by a TValue. Return CType and pointer. */ |