Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang format #263

Open
wants to merge 2 commits into
base: asar_2_beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 88
IndentWidth: 4
AccessModifierOffset: -4
SortIncludes: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
DerivePointerAlignment: false
MaxEmptyLinesToKeep: 2
...
200 changes: 101 additions & 99 deletions src/asar-dll-bindings/c/asardll.h
Original file line number Diff line number Diff line change
@@ -1,131 +1,133 @@
// note for asar devs: autogenerated by update_c_bind.py, don't edit this
// directly! either edit asardll.h.in or interface-lib.cpp.
#ifndef ASAR_DLL_H_INCLUDED
# define ASAR_DLL_H_INCLUDED
#define ASAR_DLL_H_INCLUDED

#define expectedapiversion 400

#include <stdbool.h>
#include <stddef.h> // for size_t
#include <stddef.h> // for size_t

// These structures are returned from various functions
struct stackentry {
const char * fullpath;
const char * prettypath;
int lineno;
const char * details;
const char* fullpath;
const char* prettypath;
int lineno;
const char* details;
};

struct errordata {
const char * fullerrdata;
const char * rawerrdata;
const char * block;
const char * filename;
int line;
const struct stackentry * callstack;
int callstacksize;
const char * errname;
const char* fullerrdata;
const char* rawerrdata;
const char* block;
const char* filename;
int line;
const struct stackentry* callstack;
int callstacksize;
const char* errname;
};

struct labeldata {
const char * name;
int location;
const char* name;
int location;
};

struct definedata {
const char * name;
const char * contents;
const char* name;
const char* contents;
};

struct warnsetting {
const char * warnid;
bool enabled;
const char* warnid;
bool enabled;
};

struct memoryfile {
const char* path;
const void* buffer;
size_t length;
const char* path;
const void* buffer;
size_t length;
};

enum mappertype {
invalid_mapper,
lorom,
hirom,
sa1rom,
bigsa1rom,
sfxrom,
exlorom,
exhirom,
norom
invalid_mapper,
lorom,
hirom,
sa1rom,
bigsa1rom,
sfxrom,
exlorom,
exhirom,
norom
};

struct writtenblockdata {
int pcoffset;
int snesoffset;
int numbytes;
int pcoffset;
int snesoffset;
int numbytes;
};

struct patchparams {
// The size of this struct. Set to (int)sizeof(patchparams).
int structsize;

// Same parameters as asar_patch()
const char * patchloc;
char * romdata;
int buflen;
int * romlen;

// Include paths to use when searching files.
const char** includepaths;
int numincludepaths;

// A list of additional defines to make available to the patch.
const struct definedata* additional_defines;
int additional_define_count;

// Path to a text file to parse standard include search paths from.
// Set to NULL to not use any standard includes search paths.
const char* stdincludesfile;

// Path to a text file to parse standard defines from.
// Set to NULL to not use any standard defines.
const char* stddefinesfile;

// A list of warnings to enable or disable.
// Specify warnings in the format "WXXXX" where XXXX = warning ID.
const struct warnsetting * warning_settings;
int warning_setting_count;

// List of memory files to create on the virtual filesystem.
const struct memoryfile * memory_files;
int memory_file_count;

// Set override_checksum_gen to true and generate_checksum to true/false
// to force generating/not generating a checksum.
bool override_checksum_gen;
bool generate_checksum;

// Set this to true for generated error and warning texts to always
// contain their full call stack.
bool full_call_stack;
// The size of this struct. Set to (int)sizeof(patchparams).
int structsize;

// Same parameters as asar_patch()
const char* patchloc;
char* romdata;
int buflen;
int* romlen;

// Include paths to use when searching files.
const char** includepaths;
int numincludepaths;

// A list of additional defines to make available to the patch.
const struct definedata* additional_defines;
int additional_define_count;

// Path to a text file to parse standard include search paths from.
// Set to NULL to not use any standard includes search paths.
const char* stdincludesfile;

// Path to a text file to parse standard defines from.
// Set to NULL to not use any standard defines.
const char* stddefinesfile;

// A list of warnings to enable or disable.
// Specify warnings in the format "WXXXX" where XXXX = warning ID.
const struct warnsetting* warning_settings;
int warning_setting_count;

// List of memory files to create on the virtual filesystem.
const struct memoryfile* memory_files;
int memory_file_count;

// Set override_checksum_gen to true and generate_checksum to true/false
// to force generating/not generating a checksum.
bool override_checksum_gen;
bool generate_checksum;

// Set this to true for generated error and warning texts to always
// contain their full call stack.
bool full_call_stack;
};

#ifdef __cplusplus
extern "C" {
#endif

//Initializes Asar. Call this before doing anything.
//If it returns false, something went wrong, and you may not use any other Asar functions. This is
//either due to not finding the library, or not finding all expected functions in the library.
// Initializes Asar. Call this before doing anything.
// If it returns false, something went wrong, and you may not use any other Asar
// functions. This is either due to not finding the library, or not finding all expected
// functions in the library.
bool asar_init(void);

// Same as above, but instead of automatically looking for and trying to load asar.dll, takes
// a path to the Asar DLL and tries to load it.
// The path is expected to be UTF-8-encoded, even on Windows.
bool asar_init_with_dll_path(const char * dllpath);
// Same as above, but instead of automatically looking for and trying to load asar.dll,
// takes a path to the Asar DLL and tries to load it. The path is expected to be
// UTF-8-encoded, even on Windows.
bool asar_init_with_dll_path(const char* dllpath);

//Frees all of Asar's structures and unloads the module. Only asar_init may be called after calling
// Frees all of Asar's structures and unloads the module. Only asar_init may be called
// after calling
// this; anything else will lead to segfaults.
void asar_close(void);

Expand Down Expand Up @@ -159,7 +161,7 @@ extern bool (*asar_reset)(void);
* be left unchanged.
* See the documentation of struct patchparams for more information.
*/
extern bool (*asar_patch)(const struct patchparams *params);
extern bool (*asar_patch)(const struct patchparams* params);

/* Returns the maximum possible size of the output ROM from asar_patch().
* Giving this size to buflen guarantees you will not get any buffer too small
Expand All @@ -173,59 +175,59 @@ extern int (*asar_maxromsize)(void);
* called again, or until asar_patch, asar_reset or asar_close is called,
* whichever comes first. Copy the contents if you need it for a longer time.
*/
extern const struct errordata * (*asar_geterrors)(int * count);
extern const struct errordata* (*asar_geterrors)(int* count);

/* Get a list of all warnings.
*/
extern const struct errordata * (*asar_getwarnings)(int * count);
extern const struct errordata* (*asar_getwarnings)(int* count);

/* Get a list of all printed data.
*/
extern const char * const * (*asar_getprints)(int * count);
extern const char* const* (*asar_getprints)(int* count);

/* Get a list of all labels.
*/
extern const struct labeldata * (*asar_getalllabels)(int * count);
extern const struct labeldata* (*asar_getalllabels)(int* count);

/* Get the ROM location of one label. -1 means "not found".
*/
extern int (*asar_getlabelval)(const char * name);
extern int (*asar_getlabelval)(const char* name);

/* Get the value of a define.
*/
extern const char * (*asar_getdefine)(const char * name);
extern const char* (*asar_getdefine)(const char* name);

/* Parses all defines in the parameter. Note that it may emit errors.
*/
extern const char * (*asar_resolvedefines)(const char * data);
extern const char* (*asar_resolvedefines)(const char* data);

/* Gets the values and names of all defines.
*/
extern const struct definedata * (*asar_getalldefines)(int * count);
extern const struct definedata* (*asar_getalldefines)(int* count);

/* Parses a string containing math. It automatically assumes global scope (no
* namespaces), and has access to all functions and labels from the last call
* to asar_patch. Remember to check error to see if it's successful (NULL) or
* if it failed (non-NULL, contains a descriptive string). It does not affect
* asar_geterrors.
*/
extern double (*asar_math)(const char * math_, const char ** error);
extern double (*asar_math)(const char* math_, const char** error);

/* Get a list of all the blocks written to the ROM by calls such as
* asar_patch().
*/
extern const struct writtenblockdata * (*asar_getwrittenblocks)(int * count);
extern const struct writtenblockdata* (*asar_getwrittenblocks)(int* count);

/* Get the mapper currently used by Asar.
*/
extern enum mappertype (*asar_getmapper)(void);

/* Generates the contents of a symbols file for in a specific format.
*/
extern const char * (*asar_getsymbolsfile)(const char* type);
extern const char* (*asar_getsymbolsfile)(const char* type);

#ifdef __cplusplus
}
}
#endif

#endif // ASAR_DLL_H_INCLUDED
#endif // ASAR_DLL_H_INCLUDED
Loading