aboutsummaryrefslogtreecommitdiff
path: root/src/lj_obj.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_obj.c')
-rw-r--r--src/lj_obj.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lj_obj.c b/src/lj_obj.c
index 528b3a58..65cbe1a1 100644
--- a/src/lj_obj.c
+++ b/src/lj_obj.c
@@ -20,7 +20,7 @@ LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */
20}; 20};
21 21
22/* Compare two objects without calling metamethods. */ 22/* Compare two objects without calling metamethods. */
23int lj_obj_equal(cTValue *o1, cTValue *o2) 23int LJ_FASTCALL lj_obj_equal(cTValue *o1, cTValue *o2)
24{ 24{
25 if (itype(o1) == itype(o2)) { 25 if (itype(o1) == itype(o2)) {
26 if (tvispri(o1)) 26 if (tvispri(o1))
@@ -33,3 +33,19 @@ int lj_obj_equal(cTValue *o1, cTValue *o2)
33 return numberVnum(o1) == numberVnum(o2); 33 return numberVnum(o1) == numberVnum(o2);
34} 34}
35 35
36/* Return pointer to object or its object data. */
37const void * LJ_FASTCALL lj_obj_ptr(global_State *g, cTValue *o)
38{
39 UNUSED(g);
40 if (tvisudata(o))
41 return uddata(udataV(o));
42 else if (tvislightud(o))
43 return lightudV(g, o);
44 else if (LJ_HASFFI && tviscdata(o))
45 return cdataptr(cdataV(o));
46 else if (tvisgcv(o))
47 return gcV(o);
48 else
49 return NULL;
50}
51