Skip to content
Authors

File prod_janet.c

FileList > prod_janet > src > prod_janet.c

Go to the source code of this file

Defines the functionality of a Janet production, allowing for injection of arbitrary Janet code. More...

  • #include "prod_janet.h"
  • #include <string.h>
  • #include <pdgl_defs.h>
  • #include <janet.h>
  • #include <fmem.h>
  • #include <stdbool.h>

Public Attributes

Type Name
const unsigned char init_script_janet
An external reference to a build time created byte array of ./init_script.janet .

Public Static Attributes

Type Name
const JanetReg cfuns = /* multi line expression */
A collection of c functions to pass to the Janet environment at init.

Public Functions

Type Name
STATIC_INLINE char * prod_janet_execute (const void * config, const char * script)
Execute a production in a Janet VM.
STATIC_INLINE Janet prod_janet_pdglcout (int32_t argc, Janet * argv)
Parse a print calling back from Janet to c.
const char * prod_janet_resolve (const void * config)
The resolve function for the Janet production type.
const char * prod_janet_terminate (const void * config)
The resolve function for the Janet production type.

Detailed Description

Author:

Joe Starr

Public Attributes Documentation

variable init_script_janet

An external reference to a build time created byte array of ./init_script.janet .

const unsigned char init_script_janet[];


Public Static Attributes Documentation

variable cfuns

A collection of c functions to pass to the Janet environment at init.

const JanetReg cfuns[];


Public Functions Documentation

function prod_janet_execute

Execute a production in a Janet VM.

STATIC_INLINE char * prod_janet_execute (
    const void * config,
    const char * script
) 

Create a Janet VM with an overloaded print statement. Pass the current production script to the Janet VM and run the script.

Parameters:

  • config The current production configuration. Must be cast to the Janet type.
  • script The script to execute one of replacement or terminal.

Returns:

A pointer to the output string. NULL on error.


function prod_janet_pdglcout

Parse a print calling back from Janet to c.

STATIC_INLINE Janet prod_janet_pdglcout (
    int32_t argc,
    Janet * argv
) 

From inside a Janet VM call back into the PDGL c code. Add the first argument to the output string buffer of the config pointed to by the second argument.

Parameters:

  • argc A count of arguments.
  • argv A list of void pointers to argument.

Returns:

Pass back to the Janet VM a nil value.


function prod_janet_resolve

The resolve function for the Janet production type.

const char * prod_janet_resolve (
    const void * config
) 

Starts a Janet VM and executes the configured resolution script.

Parameters:

  • config A configuration of a production.

Returns:

A pointer to the output of the resolution.


function prod_janet_terminate

The resolve function for the Janet production type.

const char * prod_janet_terminate (
    const void * config
) 

Starts a Janet VM and executes the configured terminal script.

Parameters:

  • config A configuration of a production.

Returns:

A pointer to the output of the resolution.



The documentation for this class was generated from the following file source/prod_janet/src/prod_janet.c