summaryrefslogtreecommitdiff
path: root/devtools/swigwin-1.3.34/Lib/ruby/timeval.i
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /devtools/swigwin-1.3.34/Lib/ruby/timeval.i
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'devtools/swigwin-1.3.34/Lib/ruby/timeval.i')
-rw-r--r--devtools/swigwin-1.3.34/Lib/ruby/timeval.i64
1 files changed, 64 insertions, 0 deletions
diff --git a/devtools/swigwin-1.3.34/Lib/ruby/timeval.i b/devtools/swigwin-1.3.34/Lib/ruby/timeval.i
new file mode 100644
index 0000000..91b5691
--- /dev/null
+++ b/devtools/swigwin-1.3.34/Lib/ruby/timeval.i
@@ -0,0 +1,64 @@
+/*
+ struct timeval *
+ time_t
+
+ Ruby has builtin class Time. INPUT/OUTPUT typemap for timeval and
+ time_t is provided.
+
+*/
+%{
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+struct timeval rb_time_timeval(VALUE);
+#endif
+#ifdef __cplusplus
+}
+#endif
+%}
+
+%typemap(in) struct timeval *INPUT (struct timeval temp)
+{
+ if (NIL_P($input))
+ $1 = NULL;
+ else {
+ temp = rb_time_timeval($input);
+ $1 = &temp;
+ }
+}
+
+%typemap(in,numinputs=0) struct timeval *OUTPUT(struct timeval temp)
+{
+ $1 = &temp;
+}
+
+%typemap(argout) struct timeval *OUTPUT
+{
+ $result = rb_time_new($1->tv_sec, $1->tv_usec);
+}
+
+%typemap(out) struct timeval *
+{
+ $result = rb_time_new($1->tv_sec, $1->tv_usec);
+}
+
+%typemap(out) struct timespec *
+{
+ $result = rb_time_new($1->tv_sec, $1->tv_nsec / 1000);
+}
+
+// time_t
+%typemap(in) time_t
+{
+ if (NIL_P($input))
+ $1 = (time_t)-1;
+ else
+ $1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0));
+}
+
+%typemap(out) time_t
+{
+ $result = rb_time_new($1, 0);
+}