aboutsummaryrefslogtreecommitdiff
path: root/src/lj_obj.c
diff options
context:
space:
mode:
authorMike Pall <mike>2013-05-13 00:34:15 +0200
committerMike Pall <mike>2013-05-13 01:23:33 +0200
commit625ffca739a703906fbc321ef9405514d72480fe (patch)
treeca279d81071e8aa749797e0867e168c9db5c2bbe /src/lj_obj.c
parent19a9206caf1df71308bd8e4bd61c082026c6811c (diff)
downloadluajit-625ffca739a703906fbc321ef9405514d72480fe.tar.gz
luajit-625ffca739a703906fbc321ef9405514d72480fe.tar.bz2
luajit-625ffca739a703906fbc321ef9405514d72480fe.zip
Refactor raw object to pointer or string conversions.
Diffstat (limited to 'src/lj_obj.c')
-rw-r--r--src/lj_obj.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lj_obj.c b/src/lj_obj.c
index 322b7bec..208e4955 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,18 @@ 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(cTValue *o)
38{
39 if (tvisudata(o))
40 return uddata(udataV(o));
41 else if (tvislightud(o))
42 return lightudV(o);
43 else if (LJ_HASFFI && tviscdata(o))
44 return cdataptr(cdataV(o));
45 else if (tvisgcv(o))
46 return gcV(o);
47 else
48 return NULL;
49}
50