next up previous contents
Next: Writing JavaScript FFI Code Up: The Foreign Function Interface Previous: The Foreign Function Interface   Contents

Writing C FFI Code

C source files connecting to the Ur/Web FFI should include urweb.h, and C++ source files should include urweb_cpp.h.

A server-side FFI type or value Module.ident must have a corresponding type or value definition uw_Module_ident in C code. With the current Ur/Web version, it's not generally possible to work with Ur records or complex datatypes in C code, but most other kinds of types are fair game.

The C FFI version of a Ur function with type T1 -> ... -> TN -> R or T1 -> ... -> TN -> transaction R has a C prototype like R uw_Module_ident(uw_context, T1, ..., TN). Only functions with types of the second form may have side effects. uw_context is the type of state that persists across handling a client request. Many functions that operate on contexts are prototyped in include/urweb/urweb_cpp.h. Most should only be used internally by the compiler. A few are useful in general FFI implementation:


next up previous contents
Next: Writing JavaScript FFI Code Up: The Foreign Function Interface Previous: The Foreign Function Interface   Contents
2014-07-14