On this page:
_  pointer-to
ptr-box
define-ptr
borrow
attach-cleanup
call-with-cleanup
let*-with-cleanup
raylib-ffi-lib
8.12

1 Raylib Support🔗ℹ

 (require raylib/support) package: raylib

Various utilities to make interfacing with Raylib nicer.

syntax

(_pointer-to type)

A ctype? which represents a pointer to type.

This just returns _pointer, but is more helpful for documentation.

procedure

(ptr-box type value)  cpointer?

  type : ctype?
  value : any/c
Returns a new type pointer, with value written to it.

syntax

(define-ptr name type value)

Define a pointer variable, as if by (define name value), which behaves like a normal variable, but can be referenced as a pointer with borrow.

type must evaluate to an appropriate ctype?, and values will be converted to and from this whenever name is referenced or set!.

syntax

(borrow var)

"Borrow" a pointer variable, taking its memory address as a cpointer?.

procedure

(attach-cleanup cleanup value)  any/c

  cleanup : (-> any/c any)
  value : any/c
Attach a cleanup procedure to value, as if by allocator, returning the value.

cleanup is added as a finalizer for value, such that it is called with value when it is about to be garbage collected, or under other similar conditions.

See allocator for more details on behavior. Notably, a second call to attach-cleanup overwrites the original cleanup procedure.

procedure

(call-with-cleanup cleanup value proc)  any

  cleanup : (-> any/c any)
  value : any/c
  proc : (-> any/c any)
Call proc with value, calling cleanup on value on exit by normal return, exceptions, continuation jumps or prompt aborts.

This also installs a continuation barrier by call-with-continuation-barrier, to prevent continuation jumps back into proc, so cleanup doesn’t get called more than once.

syntax

(let*-with-cleanup ([name cleanup value] ...) body ...)

Like let*, but calling each cleanup on its respective value on exit, in reverse order.

call-with-cleanup is called for each binding, ensuring that each cleanup procedure is called at most once, and that it is called even if a following value expression throws an exception or escapes otherwise. Notably this also introduces a continuation barrier for each binding.

The Racket foreign-library value for Raylib.

Use this if you want to redefine any functions to better suit your application. The alternative is to use (ffi-lib #f) after requiring this module.