Skip to content

Commit

Permalink
Changes to support windows static builds (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer authored Feb 21, 2024
1 parent fe11875 commit cc3da1a
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 153 deletions.
50 changes: 21 additions & 29 deletions cod/cod.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
extern "C" {
#endif

#ifndef FFS_DECL_SPEC
#if defined(_MSC_VER) && !defined(FFS_SRC)
#define FFS_DECLSPEC __declspec(dllimport)
#else
#define FFS_DECLSPEC
#endif
#endif

#include <stdint.h>

/*!
Expand Down Expand Up @@ -112,7 +104,7 @@ typedef cod_extern_entry *cod_extern_list;
* \return Will return a new initialized cod_parse_context unless there is
* no available memory.
*/
extern FFS_DECLSPEC cod_parse_context new_cod_parse_context(void);
extern cod_parse_context new_cod_parse_context(void);

/*!
* Free a handle to an cod_parse_context.
Expand All @@ -121,7 +113,7 @@ extern FFS_DECLSPEC cod_parse_context new_cod_parse_context(void);
* Calling this routine frees all memory associated with the parse context,
* but not that of code that has been generated from this context.
*/
extern FFS_DECLSPEC void cod_free_parse_context(cod_parse_context context);
extern void cod_free_parse_context(cod_parse_context context);

/*!
* Associate a set of "name, external address" pairs with a parse context
Expand All @@ -135,7 +127,7 @@ extern FFS_DECLSPEC void cod_free_parse_context(cod_parse_context context);
* \param externs the list of "name, external address" pairs to be
* associated. This list should be terminated with a {NULL, 0} pair.
*/
extern FFS_DECLSPEC void cod_assoc_externs(cod_parse_context context,
extern void cod_assoc_externs(cod_parse_context context,
cod_extern_list externs);

/*!
Expand All @@ -151,7 +143,7 @@ extern FFS_DECLSPEC void cod_assoc_externs(cod_parse_context context,
* "int proc(double d, int *i)"
*
*/
extern FFS_DECLSPEC void
extern void
cod_subroutine_declaration(const char *decl, cod_parse_context context);

/*!
Expand All @@ -163,7 +155,7 @@ cod_subroutine_declaration(const char *decl, cod_parse_context context);
* the structure.
* \param context the context in which the type is to be made available.
*/
extern FFS_DECLSPEC void cod_add_simple_struct_type(const char *name, FMFieldList field_list,
extern void cod_add_simple_struct_type(const char *name, FMFieldList field_list,
cod_parse_context context);

/*!
Expand All @@ -174,7 +166,7 @@ extern FFS_DECLSPEC void cod_add_simple_struct_type(const char *name, FMFieldLis
* the structures.
* \param context the context in which the type is to be made available.
*/
extern FFS_DECLSPEC void cod_add_struct_type(FMStructDescList format_list,
extern void cod_add_struct_type(FMStructDescList format_list,
cod_parse_context context);

/*!
Expand All @@ -185,7 +177,7 @@ extern FFS_DECLSPEC void cod_add_struct_type(FMStructDescList format_list,
* \param param_num the numeral of the new parameter (0 is first)
* \param context the context in which the subroutine is being declared.
*/
extern FFS_DECLSPEC void
extern void
cod_add_param(const char *id, const char *typ, int param_num,
cod_parse_context context);

Expand All @@ -199,7 +191,7 @@ cod_add_param(const char *id, const char *typ, int param_num,
* \param context the context in which the subroutine is being declared.
*/
#ifdef __FM__
extern FFS_DECLSPEC void
extern void
cod_add_encoded_param(const char *id, char *data, int param_num,
FMContext c, cod_parse_context context);
#endif
Expand All @@ -210,7 +202,7 @@ cod_add_encoded_param(const char *id, char *data, int param_num,
* \param typ the data type of the return value.
* \param context the context in which the subroutine is being declared.
*/
extern FFS_DECLSPEC void
extern void
cod_set_return_type(char *typ, cod_parse_context context);

/*!
Expand Down Expand Up @@ -263,23 +255,23 @@ int cod_code_verify(char *code, cod_parse_context context);
*
* \param code the handle to the resources that will be free'd.
*/
extern FFS_DECLSPEC void cod_code_free(cod_code code);
extern void cod_code_free(cod_code code);

/*!
* create an execution context associated with a code block
*
* \param code the handle to the code bloc
* \return the created execution context
*/
extern FFS_DECLSPEC cod_exec_context cod_create_exec_context(cod_code code);
extern cod_exec_context cod_create_exec_context(cod_code code);

/*!
* Free all resources associated with the generated code associated with the
* cod_exec_context handle.
*
* \param code the handle to the resources that will be free'd.
*/
extern FFS_DECLSPEC void cod_exec_context_free(cod_exec_context ec);
extern void cod_exec_context_free(cod_exec_context ec);

/*!
* Associate application-level data with an execution context. This is
Expand All @@ -291,7 +283,7 @@ extern FFS_DECLSPEC void cod_exec_context_free(cod_exec_context ec);
* \param key the value that will serve as a key to retrieve the data
* \param value the 'long' data that will be associated with the key
*/
extern FFS_DECLSPEC void cod_assoc_client_data(cod_exec_context ec, int key, intptr_t value);
extern void cod_assoc_client_data(cod_exec_context ec, int key, intptr_t value);

/*!
* Retrieve application-level data with an execution context. This is
Expand All @@ -305,7 +297,7 @@ extern FFS_DECLSPEC void cod_assoc_client_data(cod_exec_context ec, int key, int
* \param key the value that will serve as a key to retrieve the data
* \return the 'long' data that was associated with the key
*/
extern FFS_DECLSPEC intptr_t cod_get_client_data(cod_exec_context ec, int key);
extern intptr_t cod_get_client_data(cod_exec_context ec, int key);

/*!
* Extract static state from an execution context.
Expand All @@ -315,7 +307,7 @@ extern FFS_DECLSPEC intptr_t cod_get_client_data(cod_exec_context ec, int key);
* the length of the returned state block
* \return a pointer to the extracted state
*/
extern FFS_DECLSPEC void *cod_extract_state(cod_exec_context ec, int *length_p);
extern void *cod_extract_state(cod_exec_context ec, int *length_p);

/*!
* Install static state into an execution context.
Expand All @@ -325,7 +317,7 @@ extern FFS_DECLSPEC void *cod_extract_state(cod_exec_context ec, int *length_p);
* \param state_size the size of the state block
* \return 1 on success, 0 on failure
*/
extern FFS_DECLSPEC int cod_install_state(cod_exec_context ec, void *state, int length);
extern int cod_install_state(cod_exec_context ec, void *state, int length);

/*!
* \brief This parses a string to determine what external
Expand Down Expand Up @@ -356,7 +348,7 @@ int cod_parse_for_globals(char *code, cod_parse_context context);
*
* \param context the cod_parse_context to be duplicated.
*/
extern FFS_DECLSPEC cod_parse_context cod_copy_context(cod_parse_context context);
extern cod_parse_context cod_copy_context(cod_parse_context context);

/*!
* Duplicate a handle to an cod_parse_context, specifically adapting the results to
Expand All @@ -365,7 +357,7 @@ extern FFS_DECLSPEC cod_parse_context cod_copy_context(cod_parse_context context
*
* \param context the cod_parse_context to be duplicated.
*/
extern FFS_DECLSPEC cod_parse_context cod_copy_globals(cod_parse_context context);
extern cod_parse_context cod_copy_globals(cod_parse_context context);

/*!
* err_out_func_t is a function pointer type. Functions matching this
Expand Down Expand Up @@ -408,7 +400,7 @@ void cod_dump(cod_code code);
* \param format2 the old format. This is the format of the output message.
* \param xform_code The COD code string that transforms data from format1 to format2.
*/
extern FFS_DECLSPEC cod_code
extern cod_code
gen_rollback_code(FMStructDescList format1, FMStructDescList format2, char *xform_code);

/*!
Expand All @@ -417,7 +409,7 @@ gen_rollback_code(FMStructDescList format1, FMStructDescList format2, char *xfor
* \param value The value of the constant
* \param context the context in which this is to be created
*/
extern FFS_DECLSPEC void cod_add_int_constant_to_parse_context(const char *id, int value,
extern void cod_add_int_constant_to_parse_context(const char *id, int value,
cod_parse_context context);

/*!
Expand All @@ -426,7 +418,7 @@ extern FFS_DECLSPEC void cod_add_int_constant_to_parse_context(const char *id, i
* \param value The value to send
* \param context The context in which the subroutine has been declared.
*/
extern FFS_DECLSPEC void cod_set_closure(char *name, void* value, cod_parse_context context);
extern void cod_set_closure(char *name, void* value, cod_parse_context context);

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
94 changes: 47 additions & 47 deletions ffs/ffs.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,147 +51,147 @@ typedef struct _FFSTypeHandle *FFSTypeHandle;
typedef struct _FFSIndexItem *FFSIndexItem;

#define create_FFSContext() create_FFSContext_FM(NULL)
extern FFS_DECLSPEC FFSContext create_FFSContext_FM(FMContext fmc);
extern FFSContext create_FFSContext_FM(FMContext fmc);

extern FFS_DECLSPEC FFSBuffer create_FFSBuffer();
extern FFS_DECLSPEC FFSBuffer create_fixed_FFSBuffer(char *buffer, size_t size);
extern FFS_DECLSPEC void free_FFSBuffer(FFSBuffer buf);
extern FFSBuffer create_FFSBuffer();
extern FFSBuffer create_fixed_FFSBuffer(char *buffer, size_t size);
extern void free_FFSBuffer(FFSBuffer buf);

extern FFS_DECLSPEC char *
extern char *
FFSencode(FFSBuffer b, FMFormat ioformat, void *data, size_t *buf_size);

typedef struct FFSEncodeVec {
void *iov_base;
@UIO_SIZE_T_TYPE@ iov_len;
} *FFSEncodeVector;

extern FFS_DECLSPEC FFSEncodeVector
extern FFSEncodeVector
FFSencode_vector(FFSBuffer b, FMFormat fmformat, void *data);

extern FFS_DECLSPEC char *
extern char *
FFSencode_no_leaf_copy(FFSBuffer b, FMFormat fmformat, void *data, size_t *buf_size);

extern FFS_DECLSPEC int FFSdecode_in_place_possible(FFSTypeHandle);
extern int FFSdecode_in_place_possible(FFSTypeHandle);

extern FFS_DECLSPEC FFSTypeHandle FFSTypeHandle_from_encode(FFSContext c, char *b);
extern FFSTypeHandle FFSTypeHandle_from_encode(FFSContext c, char *b);

extern FFS_DECLSPEC FFSTypeHandle FFSTypeHandle_by_index(FFSContext c, int index);
extern FFSTypeHandle FFSTypeHandle_by_index(FFSContext c, int index);

extern FFS_DECLSPEC char * FFSTypeHandle_name(FFSTypeHandle f);
extern char * FFSTypeHandle_name(FFSTypeHandle f);

extern FFS_DECLSPEC void
extern void
establish_conversion(FFSContext c, FFSTypeHandle f,
FMStructDescList struct_list);

extern FFS_DECLSPEC int
extern int
FFShas_conversion(FFSTypeHandle format);

extern FFS_DECLSPEC size_t
extern size_t
FFS_est_decode_length(FFSContext context, char *encoded, size_t record_length);

extern FFS_DECLSPEC int
extern int
FFSdecode_in_place(FFSContext context, char *encode, void **dest_ptr);

extern FFS_DECLSPEC int
extern int
FFSdecode_to_buffer(FFSContext context, char *encode, void *dest);

extern FFS_DECLSPEC int
extern int
FFSdecode(FFSContext context, char *encode, char *dest);

extern FFS_DECLSPEC FFSTypeHandle
extern FFSTypeHandle
FFSset_fixed_target(FFSContext c, FMStructDescList struct_list);

extern FFS_DECLSPEC FFSTypeHandle
extern FFSTypeHandle
FFS_target_from_encode(FFSContext c, char *data);

extern FFS_DECLSPEC FMFormat
extern FMFormat
FMFormat_of_original(FFSTypeHandle h);

extern FFS_DECLSPEC FFSEncodeVector
extern FFSEncodeVector
copy_all_to_FFSBuffer(FFSBuffer buf, FFSEncodeVector vec);

extern FFS_DECLSPEC FFSEncodeVector
extern FFSEncodeVector
copy_vector_to_FFSBuffer(FFSBuffer buf, FFSEncodeVector vec);

extern FFS_DECLSPEC FMContext
extern FMContext
FMContext_from_FFS(FFSContext c);

extern FFS_DECLSPEC void
extern void
free_FFSContext(FFSContext c);

extern FFS_DECLSPEC FMStructDescList
extern FMStructDescList
get_localized_formats(FMFormat f);

/* file interface follows*/

extern FFS_DECLSPEC FFSFile
extern FFSFile
open_FFSfile(const char *path, const char *flags);

extern FFS_DECLSPEC FFSFile
extern FFSFile
open_FFSfd(void *fd, const char *flags);

extern FFS_DECLSPEC void
extern void
close_FFSfile(FFSFile file);

extern FFS_DECLSPEC void
extern void
free_FFSfile(FFSFile file);

extern FFS_DECLSPEC int
extern int
write_FFSfile(FFSFile f, FMFormat format, void *data);

extern FFS_DECLSPEC int
extern int
write_FFSfile_attrs(FFSFile f, FMFormat format, void *data, attr_list attrs);

extern FFS_DECLSPEC int
extern int
write_comment_FFSfile(FFSFile f, const char *comment);

extern FFS_DECLSPEC size_t
extern size_t
FFSfile_next_decode_length(FFSFile iofile);

typedef enum {
FFSerror=1, FFSend=2, FFSdata=4, FFSformat=8, FFScomment=16, FFSindex=32
} FFSRecordType;

extern FFS_DECLSPEC void
extern void
FFSset_visible(FFSFile ffsfile, int bitmap);

extern FFS_DECLSPEC FFSRecordType
extern FFSRecordType
FFSnext_record_type(FFSFile ffsfile);

extern FFS_DECLSPEC size_t
extern size_t
FFSnext_data_length(FFSFile file);

extern FFS_DECLSPEC FFSTypeHandle
extern FFSTypeHandle
FFSnext_type_handle(FFSFile ffsfile);

extern FFS_DECLSPEC char *
extern char *
FFSread_comment(FFSFile ffsfile);

extern FFS_DECLSPEC int
extern int
FFSread(FFSFile ffsfile, void *dest);

extern FFS_DECLSPEC int
extern int
FFSread_attr(FFSFile file, void *dest, attr_list *attr);

extern FFS_DECLSPEC int
extern int
FFSread_to_buffer(FFSFile file, FFSBuffer b, void **dest);

extern FFS_DECLSPEC attr_list
extern attr_list
FFSattrs_from_last_read(FFSFile file);

extern FFS_DECLSPEC FFSTypeHandle
extern FFSTypeHandle
FFSread_format(FFSFile ffsfile);

extern FFS_DECLSPEC FFSIndexItem
extern FFSIndexItem
FFSread_index(FFSFile ffsfile);

extern FFS_DECLSPEC FFSContext
extern FFSContext
FFSContext_of_file(FFSFile f);

extern FFS_DECLSPEC FMContext
extern FMContext
FMContext_of_file(FFSFile f);

extern FFS_DECLSPEC int
extern int
FFSseek(FFSFile file, int data_item);

#if defined(__cplusplus) || defined(c_plusplus)
Expand Down
Loading

0 comments on commit cc3da1a

Please sign in to comment.