HISE Logo Forum
    • Categories
    • Register
    • Login

    Added C Preprocessor to HiseScript!

    Scheduled Pinned Locked Moved General Questions
    5 Posts 3 Posters 338 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey
      last edited by

      Tell us more. https://github.com/christophhart/HISE/commits/develop

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      Christoph HartC 1 Reply Last reply Reply Quote 2
      • Christoph HartC
        Christoph Hart @d.healey
        last edited by

        @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.

        Link Preview Image
        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

        favicon

        (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).

        d.healeyD 1 Reply Last reply Reply Quote 1
        • d.healeyD
          d.healey @Christoph Hart
          last edited by

          @Lindon I think you'll like this

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          LindonL 1 Reply Last reply Reply Quote 0
          • LindonL
            Lindon @d.healey
            last edited by

            @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.

            HISE Development for hire.
            www.channelrobot.com

            Christoph HartC 1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart @Lindon
              last edited by

              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:

              Link Preview Image
              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.

              favicon

              GitHub (github.com)

              1 Reply Last reply Reply Quote 3
              • First post
                Last post

              42

              Online

              1.7k

              Users

              11.7k

              Topics

              101.8k

              Posts