aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2011-08-21 18:06:53 +0000
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>2011-08-21 18:06:53 +0000
commitdbcfb25b0e3436b3e52d4237cb723cf731025885 (patch)
tree21e9cff3b1160fdf647868c22648283449fe1dee /epan/wslua
parenta0f06df7b54b95b1086b51f75671577ead9b5710 (diff)
Add some NSTime methods: add, sub and unm.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38648 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/wslua')
-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},