Using classparse is easy, refer to the building section on guide how to install. Basic usage is covered in the examples section.
To build and install the library globally:
make TARGET=linux # Build for Linux
sudo make install # Install header and shared library
Command | Description |
---|---|
make or make dev |
Development build (sanitizers, debug symbols, profiling) |
make prod |
Production build (optimized with -O3 and LTO) |
Append TARGET=<platform>
to any build command:
Target | Description | Output Extension |
---|---|---|
TARGET=linux |
Linux shared library | .so |
TARGET=win32 |
Windows DLL | .dll |
TARGET=wasm |
WebAssembly module | .wasm |
Examples:
make dev TARGET=wasm # Dev build for WebAssembly
make prod TARGET=win32 # Optimized Windows build
Enable by defining the STANDALONE
macro or setting STANDALONE=1 in Makefile
Classparse supports standalone mode, which will use minimal amount of functions from the standard C library.
This is optimal for things like custom operating systems or any non-libc compliant systems.
Heres a list of extern
'd functions, which needs to be present:
void *malloc(size_t size)
,void free(void *ptr)
- required for memory allocationsint strcmp(const char *s1, const char *s2)
char *strcpy(char *dest, const char *src)
char *strchr(const char *s, int c)
,char *strrchr(const char *s, int c)
size_t strlen(const char *ptr)
void *memcpy(void *dest, const void *src)
We tried to strip it down as much as possible, but some of these are just necessity :)
- Compiler:
-std=gnu11
- Flags:
-g -Wall -Wextra -fsanitize=address -fno-omit-frame-pointer -pg
- No optimizations
- Compiler:
-std=gnu11
- Flags:
-O3 -flto -Wall -Wextra
- Full optimizations enabled
Examples can be found inside the examples/
directory, you can compile all of them using the make
command.
Please note that it's recommended to run make
and make install
in the root directory to assure that the linkage of the library will succceed!
These are some of the most commonly used functions:
ClassFile *ReadFromStream(FILE *stream);
will read the given classfile from C-style stream.void FreeClassFile(ClassFile *cf);
should be always used to free the resources allocated by reading.Method *GetMethodByName(ClassFile *cf, const char *name);
etc. can be used as utilities to make your life easier.
The rest of them can be found in the classparse.h
The library is pretty easy to understand, so if you have any recommendations, feel free to submit your changes as PR, I will gladly merge them!
Licensed under the MIT License.