-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathutil.c
More file actions
43 lines (36 loc) · 818 Bytes
/
Copy pathutil.c
File metadata and controls
43 lines (36 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "sol.h"
#include <stdarg.h>
sol_object_t *sol_util_call(sol_state_t *state, sol_object_t *func, int *error, int elems, ...) {
va_list va;
sol_object_t *args = sol_new_list(state), *res = NULL;
int i;
if(sol_has_error(state)) {
return sol_incref(state->None);
}
if(error) {
*error = 0;
}
sol_list_insert(state, args, 0, func);
va_start(va, elems);
for(i = 0; i < elems; i++) {
sol_list_insert(state, args, i + 1, va_arg(va, sol_object_t *));
}
va_end(va);
if(!func->ops->call) {
return sol_incref(state->None);
}
res = func->ops->call(state, args);
if(!res) {
res = sol_incref(state->None);
}
if(sol_has_error(state)) {
sol_object_t *err = sol_get_error(state);
sol_clear_error(state);
sol_obj_free(res);
if(error) {
*error = 1;
}
res = err;
}
return res;
}