ikskuh / apigen Goto Github PK
View Code? Open in Web Editor NEWGenerate cross-language API definitions from a definite source of truth
Generate cross-language API definitions from a definite source of truth
global_prefix "SDL_"; // syntax up to debate
constexpr MS_PER_SECOND: u16 = 1000;
constexpr US_PER_SECOND: u32 = 1000000;
constexpr NS_PER_SECOND: u64 = 1000000000;
constexpr NS_PER_MS: u32 = 1000000;
constexpr NS_PER_US: u16 = 1000;
fn GetTicks() u64;
fn GetTicksNS() u64;
fn GetPerformanceCounter() u64;
fn GetPerformanceFrequency() u64;
fn Delay(ms: u32) void;
fn DelayNS(ns: u64) void;
type TimerCallback = * const fn(interval: u32, param: ?*anyopaque) u32;
type TimerID = c_int;
fn AddTimer(interval: u32, callback: TimerCallback, param: ?*anyopaque) TimerID;
fn RemoveTimer(id: TimerID) bool;
will then generate something like
#define SDL_MS_PER_SECOND 1000
#define SDL_US_PER_SECOND 1000000
#define SDL_NS_PER_SECOND 1000000000LL
#define SDL_NS_PER_MS 1000000
#define SDL_NS_PER_US 1000
extern DECLSPEC Uint64 SDLCALL SDL_GetTicks(void);
extern DECLSPEC Uint64 SDLCALL SDL_GetTicksNS(void);
extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void);
extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
extern DECLSPEC void SDLCALL SDL_DelayNS(Uint64 ns);
typedef Uint32(SDLCALL *SDL_TimerCallback)(Uint32 interval, void *param);
typedef int SDL_TimerID;
extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param);
extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id);
Add inclusion/exclusion options for everything in the API (parameters, fields, members, functions, types, ...)
fn apigen_memory_arena_init(arena: *apigen_MemoryArena) void version(from=1.3.0); // introduction
fn apigen_memory_arena_init(arena: *apigen_MemoryArena) void version(to=2.0.0); // deprecation
fn apigen_memory_arena_init(arena: *apigen_MemoryArena) void version(from=1.3.0, to=2.0.0); // range
type SDL_PixelFormatEnum version(from=2.0.0) = enum {
SDL_PIXELFORMAT_ABGR32 version(from=2.0.5) = 10,
};
type SDL_Pixel = struct {
r: u8,
g: u8,
b: u8,
x: u8 version(to=2.0.0),
a: u8 version(from=2.0.0),
};
from
is inclusive semver, to
is exclusive semver
include "sdl2/video.api";
include "sdl2/pixel.api";
include "sdl2/sound.api";
Including will not be as in C (paste here), but "analyze later and integrate into the AST"
So it is performed after parsing, but before semantic analysis
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.