mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-10-04 16:50:14 +00:00
Added boilerplate for CObjStream
This commit is contained in:
@@ -7,6 +7,7 @@ typedef enum CObjType {
|
||||
COBJ_STRING,
|
||||
COBJ_OBJECT,
|
||||
COBJ_TABLE,
|
||||
COBJ_STREAM,
|
||||
COBJ_FUNCTION,
|
||||
COBJ_CFUNCTION,
|
||||
// internal use
|
||||
@@ -44,6 +45,11 @@ struct CObjString {
|
||||
bool isIString;
|
||||
};
|
||||
|
||||
struct CObjStream {
|
||||
CommonHeader; // "is a" CObj
|
||||
int fd; // handle to file descriptor, on POSIX compliant OSes this can also be a socket :pog:
|
||||
};
|
||||
|
||||
struct CObjError {
|
||||
CommonHeader; // "is a" CObj
|
||||
CValue err; // error string
|
||||
@@ -109,6 +115,7 @@ struct CObjUpval {
|
||||
|
||||
#define IS_STRING(x) isObjType(x, COBJ_STRING)
|
||||
#define IS_OBJECT(x) isObjType(x, COBJ_OBJECT)
|
||||
#define IS_STREAM(x) isObjType(x, COBJ_STREAM)
|
||||
#define IS_TABLE(x) isObjType(x, COBJ_TABLE)
|
||||
#define IS_FUNCTION(x) isObjType(x, COBJ_FUNCTION)
|
||||
#define IS_CFUNCTION(x) isObjType(x, COBJ_CFUNCTION)
|
||||
@@ -117,6 +124,7 @@ struct CObjUpval {
|
||||
|
||||
#define cosmoV_readString(x) ((CObjString*)cosmoV_readRef(x))
|
||||
#define cosmoV_readCString(x) (((CObjString*)cosmoV_readRef(x))->str)
|
||||
#define cosmoV_readFD(x) (((CObjStream*)cosmoV_readRef(x))->fd)
|
||||
#define cosmoV_readObject(x) ((CObjObject*)cosmoV_readRef(x))
|
||||
#define cosmoV_readTable(x) ((CObjTable*)cosmoV_readRef(x))
|
||||
#define cosmoV_readFunction(x) ((CObjFunction*)cosmoV_readRef(x))
|
||||
@@ -142,6 +150,7 @@ bool cosmoO_equal(CState *state, CObj* obj1, CObj* obj2);
|
||||
bool cosmoO_isDescendant(CObj *obj, CObjObject *proto);
|
||||
|
||||
CObjObject *cosmoO_newObject(CState *state);
|
||||
CObjStream *cosmoO_newStream(CState *state, int fd);
|
||||
CObjTable *cosmoO_newTable(CState *state);
|
||||
CObjFunction *cosmoO_newFunction(CState *state);
|
||||
CObjCFunction *cosmoO_newCFunction(CState *state, CosmoCFunction func);
|
||||
|
Reference in New Issue
Block a user