The Sol Programming Language!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.c 761B

123456789101112131415161718192021222324252627282930
  1. #include "sol.h"
  2. #include <stdarg.h>
  3. sol_object_t *sol_util_call(sol_state_t *state, sol_object_t *func, int elems, ...) {
  4. va_list va;
  5. sol_object_t *args = sol_new_list(state), *res = NULL;
  6. int i;
  7. if(sol_has_error(state)) return sol_incref(state->None);
  8. sol_list_insert(state, args, 0, func);
  9. va_start(va, elems);
  10. for(i=0; i<elems; i++) {
  11. sol_list_insert(state, args, i+1, va_arg(va, sol_object_t *));
  12. }
  13. va_end(va);
  14. if(!func->ops->call) return sol_incref(state->None);
  15. res = func->ops->call(state, args);
  16. if(!res) res = sol_incref(state->None);
  17. if(sol_has_error(state)) {
  18. sol_clear_error(state);
  19. sol_obj_free(res);
  20. res = sol_incref(state->None);
  21. }
  22. return res;
  23. }