aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua/wslua_pinfo.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2011-08-21 18:06:53 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2011-08-21 18:06:53 +0000
commit67149a78742af9436093db2d669413977c44167d (patch)
tree21e9cff3b1160fdf647868c22648283449fe1dee /epan/wslua/wslua_pinfo.c
parent17f5a61ae0ca6164405543489fe6687a0a0c7f99 (diff)
Add some NSTime methods: add, sub and unm.
svn path=/trunk/; revision=38648
Diffstat (limited to 'epan/wslua/wslua_pinfo.c')
-rw-r--r--epan/wslua/wslua_pinfo.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/epan/wslua/wslua_pinfo.c b/epan/wslua/wslua_pinfo.c
index d345156756..a55c64497c 100644
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -95,6 +95,39 @@ WSLUA_METAMETHOD NSTime__tostring(lua_State* L) {
WSLUA_RETURN(1); /* The string representing the nstime. */
}
+WSLUA_METAMETHOD NSTime__add(lua_State* L) { /* Calculates the sum of two NSTimes */
+ NSTime time1 = checkNSTime(L,1);
+ NSTime time2 = checkNSTime(L,2);
+ NSTime time3 = g_malloc (sizeof (nstime_t));
+
+ nstime_sum (time3, time1, time2);
+ pushNSTime (L, time3);
+
+ return 1;
+}
+
+WSLUA_METAMETHOD NSTime__sub(lua_State* L) { /* Calculates the diff of two NSTimes */
+ NSTime time1 = checkNSTime(L,1);
+ NSTime time2 = checkNSTime(L,2);
+ NSTime time3 = g_malloc (sizeof (nstime_t));
+
+ nstime_delta (time3, time1, time2);
+ pushNSTime (L, time3);
+
+ return 1;
+}
+
+WSLUA_METAMETHOD NSTime__unm(lua_State* L) { /* Calculates the negative NSTime */
+ NSTime time1 = checkNSTime(L,1);
+ NSTime time2 = g_malloc (sizeof (nstime_t));
+
+ nstime_set_zero (time2);
+ nstime_subtract (time2, time1);
+ pushNSTime (L, time2);
+
+ return 1;
+}
+
WSLUA_METAMETHOD NSTime__eq(lua_State* L) { /* Compares two NSTimes */
NSTime time1 = checkNSTime(L,1);
NSTime time2 = checkNSTime(L,2);
@@ -251,6 +284,9 @@ WSLUA_META NSTime_meta[] = {
{"__index", NSTime__index},
{"__newindex", NSTime__newindex},
{"__tostring", NSTime__tostring},
+ {"__add", NSTime__add},
+ {"__sub", NSTime__sub},
+ {"__unm", NSTime__unm},
{"__eq", NSTime__eq},
{"__le", NSTime__le},
{"__lt", NSTime__lt},