Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.47 KB

HACKING.md

File metadata and controls

57 lines (37 loc) · 1.47 KB

Hacking hs-perl5

Useful Perl FFI documentation

"How to embed perl in your C program"

  • a good starting point on the Perl C API

"perlguts -- Introduction to the Perl API"

  • more detail

"Perl API"

  • reference documentation

C source files

cbits/glue.c largely contain wrappers around Perl C API functions (documented in https://perldoc.perl.org/perlapi), adding a hsperl_ prefix to them. This is necessary because the "functions" are often actually macros, and macro trickery is used to make them operate on an implicit Perl interpreter instance.

cbits/glue.h, unsurprisingly, contains prototypes for the functions in cbits/glue.c.

cbits/perlxsi.h contains an xs_init() function, required for the Perl interpreter to be initialized. It's generated by running

perl -MExtUtils::Embed -e xsinit  -- -o cbits/perlxsi.h

It's checked into version control, despite being a generated file, because it seems to be standard boilerplate that doesn't change from one Perl installation to another. (The standard name for the file is perlxsi.c, but we use it as a header.)

Editing with Intero in Vim/NeoVim

You'll want to run the following command in vim:

  : let g:intero_ghci_options='-fobject-code -O0'

else Intero won't start properly.