Index: src/int.c ================================================================== --- src/int.c +++ src/int.c @@ -39,10 +39,39 @@ integer->value = va_arg(args, intmax_t); return true; } + +static bool +equal(void *ptr1, void *ptr2) +{ + CFWObject *obj2 = ptr2; + CFWInt *int1, *int2; + + if (obj2->cls != cfw_int) + return false; + + int1 = ptr1; + int2 = ptr2; + + return (int1->value == int2->value); +} + +static uint32_t +hash(void *ptr) +{ + CFWInt *integer = ptr; + + return (uint32_t)integer->value; +} + +static void* +copy(void *ptr) +{ + return cfw_ref(ptr); +} intmax_t cfw_int_value(CFWInt *integer) { return integer->value; @@ -49,8 +78,11 @@ } static CFWClass class = { .name = "CFWInt", .size = sizeof(CFWInt), - .ctor = ctor + .ctor = ctor, + .equal = equal, + .hash = hash, + .copy = copy }; CFWClass *cfw_int = &class;