summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-complex
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-02-05 21:54:49 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-02-05 21:54:49 +0900
commitd898002096ca20471a657a69ca25aec5e25cf6f0 (patch)
tree071a6e624e639b4871d84f954baa65f04c8ec2b6 /mrbgems/mruby-complex
parentc6149370b05d6e775022501a607055c44b01cf5a (diff)
downloadmruby-d898002096ca20471a657a69ca25aec5e25cf6f0.tar.gz
mruby-d898002096ca20471a657a69ca25aec5e25cf6f0.zip
Add a few new API for complex access.
Diffstat (limited to 'mrbgems/mruby-complex')
-rw-r--r--mrbgems/mruby-complex/src/complex.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/mrbgems/mruby-complex/src/complex.c b/mrbgems/mruby-complex/src/complex.c
index 5305e09d8..13e030829 100644
--- a/mrbgems/mruby-complex/src/complex.c
+++ b/mrbgems/mruby-complex/src/complex.c
@@ -67,8 +67,17 @@ complex_ptr(mrb_state *mrb, mrb_value v)
}
#endif
-static mrb_value
-complex_new(mrb_state *mrb, mrb_float real, mrb_float imaginary)
+void
+mrb_complex_get(mrb_state *mrb, mrb_value cpx, mrb_float *r, mrb_float *i)
+{
+ struct mrb_complex *c = complex_ptr(mrb, cpx);
+
+ *r = c->real;
+ *i = c->imaginary;
+}
+
+mrb_value
+mrb_complex_new(mrb_state *mrb, mrb_float real, mrb_float imaginary)
{
struct RClass *c = mrb_class_get_id(mrb, MRB_SYM(Complex));
struct mrb_complex *p;
@@ -80,6 +89,8 @@ complex_new(mrb_state *mrb, mrb_float real, mrb_float imaginary)
return mrb_obj_value(comp);
}
+#define complex_new(mrb, real, imag) mrb_complex_new(mrb, real, imag)
+
static mrb_value
complex_real(mrb_state *mrb, mrb_value self)
{