HISE Logo Forum
    • Categories
    • Register
    • Login

    Type safety!

    Scheduled Pinned Locked Moved Scripting
    31 Posts 7 Posters 2.1k 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 @Christoph Hart
      last edited by

      @Christoph-Hart Found another one

      In file included from ../../../../../HISE/hi_scripting/hi_scripting_01.cpp:98,
                       from ../../JuceLibraryCode/include_hi_scripting_01.cpp:9:
      ../../../../../HISE/hi_scripting/scripting/api/ScriptingApi.cpp:3601:64: error: macro "ADD_TYPED_API_METHOD_2" requires 3 arguments, but only 2 given
       3601 |     ADD_TYPED_API_METHOD_2(setAttribute, VarTypeChecker::Number);
      

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

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        What's going on here?

        Too many arguments in API call Server.callWithPOST(). Expected: 1

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

        1 Reply Last reply Reply Quote 0
        • oskarshO
          oskarsh
          last edited by

          super nice! now I can obsessively type everything :D

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

            I notice this now returns an error

            local myVariable;
            myComponent.set("tooltip", myVariable);
            

            In my actual project myVariable may or may not contain a value. So now I have to add an isDefined check.

            Would it be possible to add something like:
            myComponent.set("tooltip", myVariable || ""); ?

            Edit: Oh actually that appears to already work!

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

            1 Reply Last reply Reply Quote 0
            • A
              aaronventure
              last edited by

              From the source code, these are the types and the identifiers, right?

              static const Identifier Undefined("undefined");
                  static const Identifier Integer("int");
                  static const Identifier Double("double");
                  static const Identifier Number("number");
                  static const Identifier String("string");
                  DECLARE_ID(Colour);
                  DECLARE_ID(Array);
                  DECLARE_ID(Buffer);
                  DECLARE_ID(ObjectWithLength);
                  DECLARE_ID(JSON);
                  DECLARE_ID(ScriptObject);
                  static const Identifier Object("object");
                  DECLARE_ID(Function);
                  DECLARE_ID(ComplexType);
                  DECLARE_ID(NotUndefined);
              

              @Christoph-Hart Please correct me, then add this to the docs 😄

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

                In my actual project myVariable may or may not contain a value. So now I have to add an isDefined check.

                Yes but this was already the case - you can't call functions with an undefined variable - I've introduced this "limitation" to HiseScript years ago because the times it silently fails is much higher than when you actually want to pass on an undefined value. It was just that the detection logic so far didn't catch these problems when the object that you call it to is dynamic:

                // A const object
                const var MyEffect = Synth.getEffect("My Effect");
                
                // The same object but not accessed through a const var
                const var MyDynamicEffect = [MyEffect];
                
                // This will throw an error
                MyEffect.setAttribute(undefined, 12);
                
                // Up until now this went through fine, but should also cause an error just like the line above
                MyDynamicEffect[0].setAttribute(undefined, 12);
                

                then add this to the docs

                Done, but it's not in the HISE docs website because I need to rebuild the HTML files when I'm back tomorrow.

                1 Reply Last reply Reply Quote 2
                • d.healeyD
                  d.healey
                  last edited by

                  I'm finding since this change I am getting some fun errors, but the line numbers given are not correct (or at least are not clear).

                  For example:

                  0d9ba5a6-e5ca-4aa7-a151-bf903629814d-image.png

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

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

                    @d-healey ah good catch, it mistakenly interpreted a function as a JSON object (which is technically correct, but it should identify as Function before). Should be fixed now.

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

                      @Christoph-Hart Thank you

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

                      1 Reply Last reply Reply Quote 0
                      • Dan KorneffD
                        Dan Korneff
                        last edited by Dan Korneff

                        This safety check is pretty aggressive. I'm trying to track down some API call with undefined parameter 0 errors, but HISE isn't being helpful at the moment.
                        I get an error at a line that doesn't contain code, and if I comment out the ENTIRE script I still get the error 🤷
                        The only way to make it clear the error is to restart HISE.

                        It seems to be circling around addComboBox, and that combo box initializes with a value of 0.0.

                        edit:
                        it seems to initialize to 0.0 if "saveInPreset": "0" . Is that by design?

                        Dan Korneff - Producer / Mixer / Audio Nerd

                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @Dan Korneff
                          last edited by d.healey

                          @Dan-Korneff said in Type safety!:

                          I get an error at a line that doesn't contain code

                          I'm seeing this a lot too. However if you look above the Console, on the same line as the Compile button you might get a more helpful message.

                          ComboBox values start at 1, so that might be the issue.

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

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

                            You guys know you can just change a flag in HISE to restore the old compiler strictness?

                            Link Preview Image
                            HISE/hi_scripting/hi_scripting.h at d91fb47d5cec35358dbf56235fb412bc931a723e · christophhart/HISE

                            The open source framework for sample based instruments - HISE/hi_scripting/hi_scripting.h at d91fb47d5cec35358dbf56235fb412bc931a723e · christophhart/HISE

                            favicon

                            GitHub (github.com)

                            I really stand by this decision from a language design perspective, undefined as function arguments cause more pain than it is useful, but I understand how annoying it is if you just want to pull the latest changes and find your interface completely broken because of a new restriction.

                            Anyways, I've changed the default value here so that old projects load without issues, and you even can deactivate the warning in the Hise preferences (Development -> Warn If Undefined Parameters) if you want to go full on ostrich on your code quality :)

                            Dan KorneffD Adam_GA 2 Replies Last reply Reply Quote 3
                            • Dan KorneffD
                              Dan Korneff @Christoph Hart
                              last edited by

                              @Christoph-Hart nah, I'd rather know that these issues exist and deal with them. Thankful for the feature, annoyed with debugging 🤘

                              Dan Korneff - Producer / Mixer / Audio Nerd

                              1 Reply Last reply Reply Quote 0
                              • Adam_GA
                                Adam_G @Christoph Hart
                                last edited by

                                @Christoph-Hart do we just need to change #define HISE_WARN_UNDEFINED_PARAMETER_CALLS 0 to 1? or is there something else that needs to be changed?

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

                                  @Adam_G pull the latest changes, then this flag is set and prints the warning. If you then want to disable the warning, untick the box in the preferences.

                                  Adam_GA 1 Reply Last reply Reply Quote 0
                                  • Adam_GA
                                    Adam_G @Christoph Hart
                                    last edited by

                                    @Christoph-Hart getting some errors on compiling hise.JPG

                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @Adam_G
                                      last edited by

                                      @Adam_G I think that means you are low on RAM. Try closing other programs that you are not using when compiling or reduce the number of threads that VS is using during the compilation.

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

                                      LindonL Adam_GA 2 Replies Last reply Reply Quote 0
                                      • LindonL
                                        Lindon @d.healey
                                        last edited by Lindon

                                        @d-healey said in Type safety!:

                                        @Adam_G I think that means you are low on RAM. Try closing other programs that you are not using when compiling or reduce the number of threads that VS is using during the compilation.

                                        • its more likely to mean that the plugin is using too many png's or wav files stored inside the plugin itself - past about 50Mb (if I recall correctly) the compiler runs out of heap space....on Windows only

                                        HISE Development for hire.
                                        www.channelrobot.com

                                        1 Reply Last reply Reply Quote 1
                                        • Adam_GA
                                          Adam_G @d.healey
                                          last edited by

                                          @d-healey doh! you were right. too many other programs open

                                          LindonL 1 Reply Last reply Reply Quote 0
                                          • LindonL
                                            Lindon @Adam_G
                                            last edited by

                                            @Adam_G said in Type safety!:

                                            @d-healey doh! you were right. too many other programs open

                                            careful --- re-running the compile when th eissue is the one I pointed at can sometimes run successfully...

                                            HISE Development for hire.
                                            www.channelrobot.com

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

                                            43

                                            Online

                                            1.8k

                                            Users

                                            12.0k

                                            Topics

                                            104.4k

                                            Posts