Added C Preprocessor to HiseScript!
-
Tell us more. https://github.com/christophhart/HISE/commits/develop
-
@d-healey It basically gives you a simplified version of the C preprocessor that you can use in script files to define constants, comment out codes or add little macros for minimal functions.
Preprocessors in C
The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process. In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do the required pre-processing before the actual compilation. We'll refer to the C Preprocessor as
(www.tutorialspoint.com)
This is not a feature-complete preprocessor so the list of available directives boils down to:
#define SOME_VALUE 12 // constant definition #define DOUBLE(x) x * 2 // macro definition (simple functions) #if SOME VALUE // branching #elif DOUBLE(SOME_VALUE) == 12 #else #endif // Unsupported: // #include - we already have include("someFile.js") // #undef - rather useful in big C/C++ codebases where you need to manage the include order etc. // #ifndef // #error - this can be achieved with Console.assertTrue(false); #on
The last one is a HISE special directive and only used for activating preprocessing for a single file if you haven't enabled global preprocessing for your project (as the preprocessor might slow down script compilation a bit).
The special feature here is that the preprocessor will be evaluated when you export the plugin, so you can actually remove script content from compilation, which is helpful in certain cases (eg. removing functionality from a demo that you don't want to hide behind a
if(DEMO)
branch which can be easily bypassed), but it is also useful for code organization (so you can deactivate lines quickly with an#if 0
statement without having to use multiline comments etc).I'm not 100% finished with it (I wrote the preprocessor as part of the SNEX compiler so the core functionality is there, but there are a few things related to HiseScript that needs some fine-tuning, but I'll update the docs once it's ready).
-
@Lindon I think you'll like this
-
@d-healey said in Added C Preprocessor to HiseScript!:
@Lindon I think you'll like this
--yes that was the thing I was asking for I think.
-
Alright, I think I've implemented most stuff so feel free to play around with it.
I've added some docs, but I'm too lazy to put it to the docs website, but here is the markdown:
hise_documentation/scripting/scripting-in-hise/additions-in-hise.md at master · christophhart/hise_documentation
The markdown files for the online documentation. Contribute to christophhart/hise_documentation development by creating an account on GitHub.
GitHub (github.com)