2020-10-28 05:16:30 +00:00
|
|
|
#include "cbaselib.h"
|
|
|
|
#include "cvalue.h"
|
|
|
|
#include "cobj.h"
|
2020-11-03 04:32:39 +00:00
|
|
|
#include "cmem.h"
|
2020-10-28 05:16:30 +00:00
|
|
|
|
|
|
|
void cosmoB_loadlibrary(CState *state) {
|
2020-11-03 04:32:39 +00:00
|
|
|
cosmoM_freezeGC(state);
|
2020-10-28 05:16:30 +00:00
|
|
|
cosmoV_register(state, "print", cosmoV_newObj(cosmoO_newCFunction(state, cosmoB_print)));
|
2020-11-03 04:32:39 +00:00
|
|
|
cosmoM_unfreezeGC(state);
|
2020-10-28 05:16:30 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 01:44:12 +00:00
|
|
|
CValue cosmoB_print(CState *state, int nargs, CValue *args) {
|
2020-10-28 05:16:30 +00:00
|
|
|
for (int i = 0; i < nargs; i++) {
|
|
|
|
CObjString *str = cosmoV_toString(state, args[i]);
|
|
|
|
printf("%s", cosmoO_readCString(str));
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
2020-11-10 01:44:12 +00:00
|
|
|
return cosmoV_newNil(); // print doesn't return any args
|
2020-10-28 05:16:30 +00:00
|
|
|
}
|