Skip to content

Commit e5c9030

Browse files
committed
Rough implementation of rb_get_kwargs
1 parent b8dbeea commit e5c9030

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/main/c/cext/ruby.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4656,7 +4656,23 @@ VALUE rb_current_receiver(void) {
46564656
}
46574657

46584658
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values) {
4659-
rb_tr_error("rb_get_kwargs not implemented");
4659+
if (optional == -1) {
4660+
rb_tr_error("rb_get_kwargs with rest not implemented");
4661+
}
4662+
4663+
if (optional > 0) {
4664+
rb_tr_error("rb_get_kwargs with optional not implemented");
4665+
}
4666+
4667+
if (optional < 0) {
4668+
rb_tr_error("rb_get_kwargs with rest and optional not implemented");
4669+
}
4670+
4671+
for (int n = 0; n < required; n++) {
4672+
values[n] = rb_hash_fetch(keyword_hash, table[n]);
4673+
}
4674+
4675+
return required;
46604676
}
46614677

46624678
VALUE rb_extract_keywords(VALUE *orighash) {

0 commit comments

Comments
 (0)