Setting up medatata works...

And the `inspect` function correctly shows it. However, the `metadata` function segfaults.
This commit is contained in:
Simon Brooke 2019-01-29 18:31:30 +00:00
parent 10098a83bf
commit eb394d153f
16 changed files with 866 additions and 580 deletions

View file

@ -8,6 +8,9 @@
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_consspaceobject_h
#define __psse_consspaceobject_h
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@ -19,8 +22,6 @@
#include "fopen.h"
#ifndef __consspaceobject_h
#define __consspaceobject_h
/**
* The length of a tag, in bytes.
@ -39,6 +40,7 @@
/**
* The string `CONS`, considered as an `unsigned int`.
* @todo tag values should be collected into an enum.
*/
#define CONSTV 1397641027
@ -85,6 +87,16 @@
*/
#define INTEGERTV 1381256777
/**
* A keyword - an interned, self-evaluating string.
*/
#define KEYTAG "KEYW"
/**
* The string `KEYW`, considered as an `unsigned int`.
*/
#define KEYTV 1465468235
/**
* A lambda cell. Lambdas are the interpretable (source) versions of functions.
* \see FUNCTIONTAG.
@ -258,6 +270,11 @@
*/
#define functionp(conspoint) (check_tag(conspoint,FUNCTIONTAG))
/**
* true if `conspoint` points to a keyword, else false
*/
#define keywordp(conspoint) (check_tag(conspoint,KEYTAG))
/**
* true if `conspoint` points to a special Lambda cell, else false
*/
@ -320,6 +337,8 @@
*/
#define writep(conspoint) (check_tag(conspoint,WRITETAG))
#define streamp(conspoint) (check_tag(conspoint,READTAG)||check_tag(conspoint,WRITETAG))
/**
* true if `conspoint` points to a true cell, else false
* (there should only be one of these so it's slightly redundant).
@ -397,10 +416,9 @@ struct exception_payload {
*/
struct function_payload {
/**
* pointer to the source from which the function was compiled, or NIL
* if it is a primitive.
* pointer to metadata (e.g. the source from which the function was compiled).
*/
struct cons_pointer source;
struct cons_pointer meta;
/** pointer to a function which takes a cons pointer (representing
* its argument list) and a cons pointer (representing its environment) and a
* stack frame (representing the previous stack frame) as arguments and returns
@ -475,7 +493,7 @@ struct special_payload {
* pointer to the source from which the special form was compiled, or NIL
* if it is a primitive.
*/
struct cons_pointer source;
struct cons_pointer meta;
/** pointer to a function which takes a cons pointer (representing
* its argument list) and a cons pointer (representing its environment) and a
* stack frame (representing the previous stack frame) as arguments and returns
@ -500,8 +518,9 @@ struct stream_payload {
/**
* payload of a string cell. At least at first, only one UTF character will
* be stored in each cell. The doctrine that 'a symbol is just a string'
* didn't work; however, the payload of a symbol cell is identical to the
* payload of a string cell.
* didn't work; however, the payload of a symbol or keyword cell is identical
* to the payload of a string cell, except that a keyword may store a hash
* of its own value in the padding.
*/
struct string_payload {
/** the actual character stored in this cell */
@ -614,6 +633,12 @@ void inc_ref( struct cons_pointer pointer );
void dec_ref( struct cons_pointer pointer );
struct cons_pointer c_type( struct cons_pointer pointer );
struct cons_pointer c_car( struct cons_pointer arg );
struct cons_pointer c_cdr( struct cons_pointer arg );
struct cons_pointer make_cons( struct cons_pointer car,
struct cons_pointer cdr );
@ -626,6 +651,8 @@ struct cons_pointer make_function( struct cons_pointer src,
struct cons_pointer,
struct cons_pointer ) );
struct cons_pointer c_string_to_lisp_keyword( wchar_t *symbol );
struct cons_pointer make_lambda( struct cons_pointer args,
struct cons_pointer body );
@ -640,11 +667,18 @@ struct cons_pointer make_special( struct cons_pointer src,
struct cons_pointer make_string( wint_t c, struct cons_pointer tail );
struct cons_pointer make_symbol( wint_t c, struct cons_pointer tail );
struct cons_pointer make_symbol_or_key( wint_t c, struct cons_pointer tail,
char *tag );
struct cons_pointer make_read_stream( URL_FILE * input );
#define make_symbol(c, t) (make_symbol_or_key( c, t, SYMBOLTAG))
struct cons_pointer make_write_stream( URL_FILE * output );
#define make_keyword(c, t) (make_symbol_or_key( c, t, KEYTAG))
struct cons_pointer make_read_stream( URL_FILE * input,
struct cons_pointer metadata );
struct cons_pointer make_write_stream( URL_FILE * output,
struct cons_pointer metadata );
struct cons_pointer c_string_to_lisp_string( wchar_t *string );