summaryrefslogtreecommitdiff
path: root/ext/dl/cptr.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-06 18:02:30 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-06 18:02:30 +0000
commitc2d7621d8d379980afd0b74870588c1438418fed (patch)
tree2fcd356477cdc2d12af29f099024d643673082d3 /ext/dl/cptr.c
parent32acedd2867d9577b824d0ab255e533d4ff14ea9 (diff)
* ext/dl/cptr.c (rb_dlptr_inspect, rb_dlptr_plus, rb_dlptr_minus)
documenting +, -, inspect * text/dl/test_cptr.rb (test_minus, test_plus, test_inspect) testing minus, plus, and inspect git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/cptr.c')
-rw-r--r--ext/dl/cptr.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c
index cdcc23c7275..393cc116502 100644
--- a/ext/dl/cptr.c
+++ b/ext/dl/cptr.c
@@ -331,7 +331,13 @@ rb_dlptr_to_str(int argc, VALUE argv[], VALUE self)
return val;
}
-VALUE
+/*
+ * call-seq: inspect
+ *
+ * Returns a string formatted with an easily readable representation of the
+ * internal state of the DL::CPtr
+ */
+static VALUE
rb_dlptr_inspect(VALUE self)
{
struct ptr_data *data;
@@ -386,7 +392,13 @@ rb_dlptr_cmp(VALUE self, VALUE other)
return diff > 0 ? INT2NUM(1) : INT2NUM(-1);
}
-VALUE
+/*
+ * call-seq:
+ * ptr + n => new cptr
+ *
+ * Returns a new DL::CPtr that has been advanced +n+ bytes.
+ */
+static VALUE
rb_dlptr_plus(VALUE self, VALUE other)
{
void *ptr;
@@ -398,7 +410,13 @@ rb_dlptr_plus(VALUE self, VALUE other)
return rb_dlptr_new((char *)ptr + num, size - num, 0);
}
-VALUE
+/*
+ * call-seq:
+ * ptr - n => new cptr
+ *
+ * Returns a new DL::CPtr that has been moved back +n+ bytes.
+ */
+static VALUE
rb_dlptr_minus(VALUE self, VALUE other)
{
void *ptr;