Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CPunch committed Dec 26, 2023
1 parent a337e26 commit 5296495
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
14 changes: 8 additions & 6 deletions src/cbaselib.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ int cosmoB_ogetProto(CState *state, int nargs, CValue *args)
}

cosmoV_pushRef(state, proto); // just return the proto
return 1; // 1 result
return 1; // 1 result
}

int cosmoB_ogetKeys(CState *state, int nargs, CValue *args)
Expand Down Expand Up @@ -337,7 +337,8 @@ int fileB_read(CState *state, int nargs, CValue *args)
return 1;
}

int fileB_write(CState *state, int nargs, CValue *args) {
int fileB_write(CState *state, int nargs, CValue *args)
{
CObjObject *fileObj;
CObjString *str;
FILE *file;
Expand Down Expand Up @@ -365,14 +366,14 @@ int fileB_write(CState *state, int nargs, CValue *args) {
return 0;
}

int fileB_gc(CState *state, int nargs, CValue *args) {
int fileB_gc(CState *state, int nargs, CValue *args)
{
if (nargs != 1) {
cosmoV_error(state, "file:read() expected 1 argument, got %d!", nargs);
}

if (!cosmoV_isValueUserType(state, args[0], COSMO_USER_FILE)) {
cosmoV_typeError(state, "file:__gc()", "<file>", "%s",
cosmoV_typeStr(args[0]));
cosmoV_typeError(state, "file:__gc()", "<file>", "%s", cosmoV_typeStr(args[0]));
}

CObjObject *fileObj = cosmoV_readObject(args[0]);
Expand Down Expand Up @@ -411,7 +412,8 @@ int cosmoB_osOpen(CState *state, int nargs, CValue *args)

if (nargs == 2) {
if (!IS_STRING(args[1])) {
cosmoV_typeError(state, "os.open()", "<string>, <string>", "%s, %s", cosmoV_typeStr(args[0]), cosmoV_typeStr(args[1]));
cosmoV_typeError(state, "os.open()", "<string>, <string>", "%s, %s",
cosmoV_typeStr(args[0]), cosmoV_typeStr(args[1]));
}

mode = cosmoV_readCString(args[1]);
Expand Down
1 change: 0 additions & 1 deletion src/cmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ static void sweep(CState *state)
cosmoV_call(state, 1, 0);
}


cosmoO_free(state, oldObj);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/cobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ void cosmoO_unlock(CObjObject *object)
object->isLocked = false;
}


bool rawgetIString(CState *state, CObjObject *object, int flag, CValue *val)
{
if (readFlag(object->istringFlags, flag))
Expand Down
9 changes: 6 additions & 3 deletions src/cstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ void cosmoV_addRegistry(CState *state, int pairs)
}

// expects 1 key on the stack, pushes result
void cosmoV_getRegistry(CState *state) {
void cosmoV_getRegistry(CState *state)
{
CValue key = *cosmoV_pop(state);
CValue val;

Expand All @@ -179,12 +180,14 @@ void cosmoV_getRegistry(CState *state) {
cosmoV_pushValue(state, val);
}

void cosmoV_setProto(CState *state) {
void cosmoV_setProto(CState *state)
{
StkPtr objVal = cosmoV_getTop(state, 1);
StkPtr protoVal = cosmoV_getTop(state, 0);

if (!IS_REF(*objVal) || !IS_OBJECT(*protoVal)) {
cosmoV_error(state, "cannot set %s to proto of type %s", cosmoV_typeStr(*objVal), cosmoV_typeStr(*protoVal));
cosmoV_error(state, "cannot set %s to proto of type %s", cosmoV_typeStr(*objVal),
cosmoV_typeStr(*protoVal));
}

// actually set the protos
Expand Down
6 changes: 3 additions & 3 deletions src/cstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ struct CState

CObjUpval *openUpvalues; // tracks all of our still open (meaning still on the stack) upvalues
CObjTable *globals;
CValue *top; // top of the stack
CObj *objects; // tracks all of our allocated objects
CValue *top; // top of the stack
CObj *objects; // tracks all of our allocated objects
CPanic *panic;

size_t allocatedBytes;
size_t nextGC; // when allocatedBytes reaches this threshhold, trigger a GC event
int freezeGC; // when > 0, GC events will be ignored (for internal use)
int freezeGC; // when > 0, GC events will be ignored (for internal use)
int frameCount;
};

Expand Down
8 changes: 4 additions & 4 deletions src/cvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void callCValue(CState *state, CValue func, int args, int nresults, int offset)

// push the nils to fill up the expected return values.
// -1 since the we already pushed the important value
for (int i = 0; i < nresults - 1;i++) {
for (int i = 0; i < nresults - 1; i++) {
cosmoV_pushValue(state, cosmoV_newNil());
}
}
Expand Down Expand Up @@ -582,7 +582,8 @@ void cosmoV_getMethod(CState *state, CObj *obj, CValue key, CValue *val)
}
}

bool cosmoV_isValueUserType(CState *state, CValue val, int userType) {
bool cosmoV_isValueUserType(CState *state, CValue val, int userType)
{
if (!IS_OBJECT(val)) {
return false;
}
Expand Down Expand Up @@ -853,8 +854,7 @@ int cosmoV_execute(CState *state)

CObj *obj = cosmoV_readRef(*temp);
CObjObject *proto = cosmoO_grabProto(obj);
CValue val = cosmoV_newNil(); // to hold our value

CValue val = cosmoV_newNil(); // to hold our value

if (proto != NULL) {
// check for __index metamethod
Expand Down
3 changes: 2 additions & 1 deletion src/cvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ COSMO_API bool cosmoV_undump(CState *state, cosmo_Reader reader, const void *ud)
COSMO_API void cosmoV_get(CState *state);

/*
expects object to be pushed, then the key, and finally the new value. pops the object, key & value
expects object to be pushed, then the key, and finally the new value. pops the object, key &
value
*/
COSMO_API void cosmoV_set(CState *state);

Expand Down

0 comments on commit 5296495

Please sign in to comment.