Giter Site home page Giter Site logo

apigen's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

apigen's Issues

Add ability to specify common symbol prefix

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 ability to specify library version in spec file

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.