mrb_kwargs numbers changed to `mrb_int` from `uint32_t`
They are unsigned but `mrb_int` is more common among mruby
implementation, e.g. length of strings and arrays.
MODIFY
include/mruby.h
include/mruby.h
@@ -976,8 +976,8 @@ typedef const char *mrb_args_format;
*
* // def method(a: 1, b: 2)
*
- * uint32_t kw_num = 2;
- * uint32_t kw_required = 0;
+ * mrb_int kw_num = 2;
+ * mrb_int kw_required = 0;
* mrb_sym kw_names[] = { mrb_intern_lit(mrb, "a"), mrb_intern_lit(mrb, "b") };
* mrb_value kw_values[kw_num];
* mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, NULL };
@@ -1007,8 +1007,8 @@ typedef struct mrb_kwargs mrb_kwargs;
struct mrb_kwargs
{
- uint32_t num; /* number of keyword arguments */
- uint32_t required; /* number of required keyword arguments */
+ mrb_int num; /* number of keyword arguments */
+ mrb_int required; /* number of required keyword arguments */
const mrb_sym *table; /* C array of symbols for keyword names */
mrb_value *values; /* keyword argument values */
mrb_value *rest; /* keyword rest (dict) */

MODIFY
src/class.c
src/class.c
@@ -1249,13 +1249,15 @@ get_args_v(mrb_state *mrb, mrb_args_format format, void** ptr, va_list ap)
rest = NULL;
}
else {
- uint32_t kwnum = kwargs->num;
- uint32_t required = kwargs->required;
+ mrb_int kwnum = kwargs->num;
+ mrb_int required = kwargs->required;
const mrb_sym *kname = kwargs->table;
mrb_value *values = kwargs->values;
uint32_t j;
const uint32_t keyword_max = 40;
+ mrb_assert(kwnum >= 0);
+ mrb_assert(required >= 0);
if (kwnum > keyword_max || required > kwnum) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "keyword number is too large");
}

mrb_kwargs numbers changed to `mrb_int` from `uint32_t`

They are unsigned but `mrb_int` is more common among mruby
implementation, e.g. length of strings and arrays.