wip: working on dynamic linking

- Feat: add example for wrapping dynamically linked library
- Feat: add new tokens (import, extern, type, handle, struct, ref, out)
This commit is contained in:
samsonium
2026-10-28 21:43:56 +03:00
parent d93c315359
commit 567bf49d27
2 changed files with 79 additions and 33 deletions
+38
View File
@@ -0,0 +1,38 @@
extern "libglfw" {
type GLFWwindow = handle;
type GLFWmonitor = handle;
struct GLFWvidmode {
int width;
int height;
int redBits;
int greenBits;
int blueBits;
int refreshRate;
}
/// GLFWvidmode*
type GLFWvidmodeRef = ref GLFWvidmode;
/// Create window with specified [width], [height] and [title]
fn glfw_mkWindow(
int width,
int height,
str title,
GLFWmonitor mon,
GLFWwindow shr
) GLFWwindow = "glfwCreateWindow";
/// Get videomode from monitor [mon]
fn glfw_getVideoMode(
GLFWmonitor mon
) GLFWvidmodeRef = "glfwGetVideoMode";
/// Get framebuffer [width] and [height]
fn glfw_getFrameBufferSize(
GLFWwindow win,
out int width,
out int height
) = "glfwGetFramebufferSize";
}
+41 -33
View File
@@ -8,32 +8,40 @@
// Token type // Token type
typedef enum typedef enum
{ {
FZL_TOKTYPE_CLASS, // class FZL_TOKTYPE_IMPORT, // `import`
FZL_TOKTYPE_NEW, // new FZL_TOKTYPE_EXTERN, // `extern`
FZL_TOKTYPE_TYPEDEF, // `type`
FZL_TOKTYPE_HANDLE, // `handle`
FZL_TOKTYPE_STRUCT, // `struct`
FZL_TOKTYPE_REFERENCE, // `ref`
FZL_TOKTYPE_OUT, // `out`
FZL_TOKTYPE_FUNCTION, // fn FZL_TOKTYPE_CLASS, // `class`
FZL_TOKTYPE_RETURN, // return FZL_TOKTYPE_NEW, // `new`
FZL_TOKTYPE_FOR, // for FZL_TOKTYPE_FUNCTION, // `fn`
FZL_TOKTYPE_WHILE, // while FZL_TOKTYPE_RETURN, // `return`
FZL_TOKTYPE_BREAK, // break
FZL_TOKTYPE_IF, // if FZL_TOKTYPE_FOR, // `for`
FZL_TOKTYPE_ELSE, // else FZL_TOKTYPE_WHILE, // `while`
FZL_TOKTYPE_BREAK, // `break`
FZL_TOKTYPE_IF, // `if`
FZL_TOKTYPE_ELSE, // `else`
FZL_TOKTYPE_NAME, // abc FZL_TOKTYPE_NAME, // abc
FZL_TOKTYPE_TYPE, // i16 FZL_TOKTYPE_TYPE, // i16
FZL_TOKTYPE_DDASH, // // :D FZL_TOKTYPE_DDASH, // `//` :D
FZL_TOKTYPE_LPAREN, // ( FZL_TOKTYPE_LPAREN, // `(`
FZL_TOKTYPE_RPAREN, // ) FZL_TOKTYPE_RPAREN, // `)`
FZL_TOKTYPE_LBRACE, // { FZL_TOKTYPE_LBRACE, // `{`
FZL_TOKTYPE_RBRACE, // } FZL_TOKTYPE_RBRACE, // `}`
FZL_TOKTYPE_COMMA, // , FZL_TOKTYPE_COMMA, // `,`
FZL_TOKTYPE_DOT, // . FZL_TOKTYPE_DOT, // `.`
FZL_TOKTYPE_SEMICOLON, // ; FZL_TOKTYPE_SEMICOLON, // `;`
FZL_TOKTYPE_STR_LITERAL, // "" FZL_TOKTYPE_STR_LITERAL, // ""
FZL_TOKTYPE_NUM_LITERAL, // 123 FZL_TOKTYPE_NUM_LITERAL, // 123
@@ -43,25 +51,25 @@ typedef enum
FZL_TOKTYPE_STR_FORMAT_START, // `$` before `"` FZL_TOKTYPE_STR_FORMAT_START, // `$` before `"`
FZL_TOKTYPE_STR_FORMAT_END, // end of string formatting sequence FZL_TOKTYPE_STR_FORMAT_END, // end of string formatting sequence
FZL_TOKTYPE_DAMPERSAND, // && FZL_TOKTYPE_DAMPERSAND, // `&&`
FZL_TOKTYPE_DVBAR, // || FZL_TOKTYPE_DVBAR, // `||`
FZL_TOKTYPE_EQEQ, // == FZL_TOKTYPE_EQEQ, // `==`
FZL_TOKTYPE_REQ, // >= FZL_TOKTYPE_REQ, // `>=`
FZL_TOKTYPE_LEQ, // <= FZL_TOKTYPE_LEQ, // `<=`
FZL_TOKTYPE_NEQ, // != FZL_TOKTYPE_NEQ, // `!=`
FZL_TOKTYPE_LANGLE, // < FZL_TOKTYPE_LANGLE, // `<`
FZL_TOKTYPE_RANGLE, // > FZL_TOKTYPE_RANGLE, // `>`
FZL_TOKTYPE_NOT, // ! FZL_TOKTYPE_NOT, // `!`
FZL_TOKTYPE_STAR, // * FZL_TOKTYPE_STAR, // `*`
FZL_TOKTYPE_SLASH, // / FZL_TOKTYPE_SLASH, // `/`
FZL_TOKTYPE_PLUS, // + FZL_TOKTYPE_PLUS, // `+`
FZL_TOKTYPE_MINUS, // - FZL_TOKTYPE_MINUS, // `-`
FZL_TOKTYPE_CARET, // ^ FZL_TOKTYPE_CARET, // `^`
FZL_TOKTYPE_PERCENT, // % FZL_TOKTYPE_PERCENT, // `%`
FZL_TOKTYPE_EQ // = FZL_TOKTYPE_EQ // `=`
} fzl_toktype_t; } fzl_toktype_t;
// Token descriptor // Token descriptor