Storing Lua function in struct?

  • From: "Soni L." <fakedme+lj@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 29 Mar 2015 23:17:31 -0300

I'm trying to write a JIT-able IO lib, but the way I'm handling file:close() causes blacklisting and NYIs.


This is my "main" cdef:

-------------------------------------------------------------------------------------------------------------
typedef struct FILE FILE;

typedef struct SExIO_CloseResult {
  bool status;
  char *msg;
  int en;
} SExIO_CloseResult;

struct SExIO_Stream;

typedef struct SExIO_Stream {
  FILE *f;  /* stream (NULL for incompletely created streams) */
SExIO_CloseResult *(*closef)(struct SExIO_Stream *stream); /* to close stream (NULL for closed streams) */
} SExIO_Stream;
-------------------------------------------------------------------------------------------------------------

Obviously using callbacks for this is a bad idea, as it causes blacklisting and NYIs. What would be the proper way for me to do this?

Other related posts: