Format code.

This commit is contained in:
2018-05-17 14:53:48 -07:00
parent 97543a3d19
commit c3a7657c71
21 changed files with 215 additions and 213 deletions

View File

@@ -55,9 +55,8 @@ typedef struct libab_basetype_s libab_basetype;
* @param n the number of type parameters it has.
* @param params the parameters this basetype accepts.
*/
void libab_basetype_init(libab_basetype* basetype,
void (*free_function)(void*), int n,
const libab_basetype_param params[]);
void libab_basetype_init(libab_basetype* basetype, void (*free_function)(void*),
int n, const libab_basetype_param params[]);
/**
* Frees the given basetype.
* @param basetype the type to free.

View File

@@ -2,8 +2,8 @@
#define LIBABACUS_CUSTOM_H
#include "parsetype.h"
#include "tree.h"
#include "ref_trie.h"
#include "tree.h"
/**
* A function pointer that is called
@@ -101,7 +101,7 @@ typedef struct libab_function_s libab_function;
* @param type the type of the behavior.
* @param func the function that this behavior calls.
*/
void libab_behavior_init_internal(libab_behavior* behavior,
void libab_behavior_init_internal(libab_behavior* behavior,
libab_function_ptr func);
/**
* Initializes a behavior that uses a tree that has been
@@ -110,8 +110,7 @@ void libab_behavior_init_internal(libab_behavior* behavior,
* @param type the type of the behavior.
* @param tree the tree that this behavior uses.
*/
void libab_behavior_init_tree(libab_behavior* behavior,
libab_tree* tree);
void libab_behavior_init_tree(libab_behavior* behavior, libab_tree* tree);
/**
* Frees the given behavior.
* @param behavior the behavior to free.
@@ -122,13 +121,14 @@ void libab_behavior_free(libab_behavior* behavior);
* @param op the operator to initialize.
* @param variant the variant of the operator (infix, prefix, etc)
* @param precedence the precedence of the operator.
* @param associativity the associativity (left = -1, right = 1) of the operator.
* @param associativity the associativity (left = -1, right = 1) of the
* operator.
* @param type the type of the operator.
* @param func the function used to implement the operator.
*/
void libab_operator_init(libab_operator* op, libab_operator_variant variant,
void libab_operator_init(libab_operator* op, libab_operator_variant variant,
int precedence, int associativity, libab_ref* type,
libab_function_ptr func);
libab_function_ptr func);
/**
* Frees the given operator.
* @param op the operator to free.

View File

@@ -1,10 +1,10 @@
#ifndef LIBABACUS_INTERPRETER_H
#define LIBABACUS_INTERPRETER_H
#include "table.h"
#include "tree.h"
#include "impl.h"
#include "libabacus.h"
#include "table.h"
#include "tree.h"
struct libab_s;
@@ -15,8 +15,8 @@ struct libab_interpreter_s {
typedef struct libab_interpreter_s libab_interpreter;
void libab_interpreter_init(libab_interpreter* intr, struct libab_s* ab);
libab_result libab_interpreter_run(libab_interpreter* intr,
libab_tree* tree, libab_ref* into);
libab_result libab_interpreter_run(libab_interpreter* intr, libab_tree* tree,
libab_ref* into);
void libab_interpreter_free(libab_interpreter* intr);
#endif

View File

@@ -1,14 +1,14 @@
#ifndef LIBABACUS_H
#define LIBABACUS_H
#include "interpreter.h"
#include "custom.h"
#include "ht.h"
#include "impl.h"
#include "interpreter.h"
#include "lexer.h"
#include "parser.h"
#include "result.h"
#include "table.h"
#include "impl.h"
/**
* The main struct of libabacus,

View File

@@ -47,7 +47,7 @@ typedef struct libab_parsetype_s libab_parsetype;
* @return the result of the instantiation.
*/
libab_result libab_parsetype_init(libab_parsetype* into, libab_basetype* from,
size_t n, ...);
size_t n, ...);
/**
* Same as _init, but using a pre-initialized va_list.
* @param into the reference to store the new type into.
@@ -56,8 +56,9 @@ libab_result libab_parsetype_init(libab_parsetype* into, libab_basetype* from,
* @param args the list of parameters to this parsetype.
* @return the result of the instantiation.
*/
libab_result libab_parsetype_init_va(libab_parsetype* into, libab_basetype* from,
size_t n, va_list args);
libab_result libab_parsetype_init_va(libab_parsetype* into,
libab_basetype* from, size_t n,
va_list args);
/**
* Frees the data associated with this type, ignoring

View File

@@ -54,7 +54,7 @@ void libab_ref_trie_init(libab_ref_trie* trie);
* @param copy_of the trie to copy.
* @return the result of the initialization.
*/
libab_result libab_ref_trie_init_copy(libab_ref_trie* trie,
libab_result libab_ref_trie_init_copy(libab_ref_trie* trie,
const libab_ref_trie* copy_of);
/**
* Stores a reference counted value into the trie.
@@ -73,8 +73,8 @@ libab_result libab_ref_trie_put(libab_ref_trie* trie, const char* key,
* @param key the key to look under.
* @return a reference stored under the given key. This can be a NULL reference.
*/
void libab_ref_trie_get(const libab_ref_trie* trie,
const char* key, libab_ref* into);
void libab_ref_trie_get(const libab_ref_trie* trie, const char* key,
libab_ref* into);
/**
* Releases the trie, decrementing the refcounts of all
* the values stored inside.

View File

@@ -34,11 +34,11 @@ struct libab_ref_s {
/**
* Whether this reference is a strong reference.
*/
unsigned int strong:1;
unsigned int strong : 1;
/**
* Whether this reference is a NULL reference.
*/
unsigned int null:1;
unsigned int null : 1;
/**
* The reference count struct keeping track
* of how many references are pointing to the value.

View File

@@ -3,9 +3,9 @@
#include "basetype.h"
#include "custom.h"
#include "refcount.h"
#include "result.h"
#include "trie.h"
#include "refcount.h"
/**
* A struct that represents a structure
@@ -29,11 +29,7 @@ struct libab_table_s {
* Enum that represents the type of a table
* entry.
*/
enum libab_table_entry_variant_e {
ENTRY_VALUE,
ENTRY_BASETYPE,
ENTRY_OP
};
enum libab_table_entry_variant_e { ENTRY_VALUE, ENTRY_BASETYPE, ENTRY_OP };
/**
* An entry in the table.
@@ -107,9 +103,8 @@ libab_basetype* libab_table_search_basetype(libab_table* table,
* @param string the table entry key.
* @param ref the reference to store the result into.
*/
void libab_table_search_value(libab_table* table,
const char* string,
libab_ref* ref);
void libab_table_search_value(libab_table* table, const char* string,
libab_ref* ref);
/**
* Stores the given entry in the table under the given key.
* @param table the table to store the entry into.

View File

@@ -1,12 +1,12 @@
#ifndef LIBABACUS_UTIL_H
#define LIBABACUS_UTIL_H
#include "function_list.h"
#include "libds.h"
#include "liblex.h"
#include "parsetype.h"
#include "result.h"
#include "table.h"
#include "function_list.h"
#include <string.h>
/**
@@ -65,7 +65,7 @@ libab_result libab_resolve_parsetype(libab_parsetype* to_resolve,
* @return the result of the instantiation.
*/
libab_result libab_instantiate_basetype(libab_basetype* to_instantiate,
libab_ref* into, size_t n, ...);
libab_ref* into, size_t n, ...);
/**
* Creates a new libab_table, and stores it into the given reference.
* @param into the reference to store the table into.
@@ -80,7 +80,8 @@ libab_result libab_create_table(libab_ref* into, libab_ref* parent);
* @param type the type to give the value.
* @return the result of necessary allocations.
*/
libab_result libab_create_value_ref(libab_ref* into, libab_ref* data, libab_ref* type);
libab_result libab_create_value_ref(libab_ref* into, libab_ref* data,
libab_ref* type);
/**
* Allocates a new reference counted value with the given type and data.
* @param into the reference to store the allocated data into.
@@ -88,7 +89,8 @@ libab_result libab_create_value_ref(libab_ref* into, libab_ref* data, libab_ref*
* @param type the type to give the value.
* @return the result of necessary allocations.
*/
libab_result libab_create_value_raw(libab_ref* into, void* data, libab_ref* type);
libab_result libab_create_value_raw(libab_ref* into, void* data,
libab_ref* type);
/**
* Allocates a function that uses internal code to run.
* @param into the reference into which to store the new function.
@@ -96,7 +98,8 @@ libab_result libab_create_value_raw(libab_ref* into, void* data, libab_ref* type
* @param fun the function implementation.
* @return libab_result the result of any necessary allocations.
*/
libab_result libab_create_function_internal(libab_ref* into, void (*free_function)(void*),
libab_result libab_create_function_internal(libab_ref* into,
void (*free_function)(void*),
libab_function_ptr fun);
/**
* Allocates a function that uses a tree to run.
@@ -105,7 +108,8 @@ libab_result libab_create_function_internal(libab_ref* into, void (*free_functio
* @param tree the function implementation.
* @return libab_result the result of any necessary allocations.
*/
libab_result libab_create_function_tree(libab_ref* into, void (*free_function)(void*),
libab_result libab_create_function_tree(libab_ref* into,
void (*free_function)(void*),
libab_tree* tree);
/**
* Creates a function list object, storing it in to the given reference.
@@ -121,7 +125,7 @@ libab_result libab_create_function_list(libab_ref* into, libab_ref* type);
* @param value the value to store into the table.
* @param result the result of the operation.
*/
libab_result libab_put_table_value(libab_table* table,
const char* key, libab_ref* value);
libab_result libab_put_table_value(libab_table* table, const char* key,
libab_ref* value);
#endif

View File

@@ -24,19 +24,22 @@ typedef struct libab_value_s libab_value;
* Initializes a new value with the given reference counted data
* and the given type.
* @param value the value to initialize.
* @param data the data for this value. Its refcount is decreased when the value is freed.
* @param data the data for this value. Its refcount is decreased when the value
* is freed.
* @param type the type of this value.
*/
void libab_value_init_ref(libab_value* value, libab_ref* data, libab_ref* type);
/**
* Initializes a new value with the given raw allocated data, and a type,
* whose basetype's free function is used to release the data when the value is freed.
* whose basetype's free function is used to release the data when the value is
* freed.
* @param value the value to initialize.
* @param data the data this value holds.
* @param type the type of this value.
* @return the result of any necessary allocations.
*/
libab_result libab_value_init_raw(libab_value* value, void* data, libab_ref* type);
libab_result libab_value_init_raw(libab_value* value, void* data,
libab_ref* type);
/**
* Frees the given value.
* @param value the value to free.