sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Testing Ruby VALUES in C-extension.

    Scheduled Pinned Locked Moved Developers' Forum
    69 Posts 6 Posters 3.2k Views 6 Watching
    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.
    • G Offline
      Garry K
      last edited by

      good article - it has already answered some of my questions.

      1 Reply Last reply Reply Quote 0
      • tt_suT Offline
        tt_su
        last edited by

        It explains the important parts better than the Ruby C API readme:
        https://github.com/ruby/ruby/blob/trunk/README.EXT

        1 Reply Last reply Reply Quote 0
        • jiminy-billy-bobJ Offline
          jiminy-billy-bob
          last edited by

          I just came accross an issue you guys should know about (if you don't already) : We can't pass more than 15 arguments in a single function from ruby to C++.

          25% off Skatter for SketchUcation Premium Members

          1 Reply Last reply Reply Quote 0
          • G Offline
            Garry K
            last edited by

            It looks like I'll have to use the visual studio compiler for c extensions in sketchup.
            There is an MS specific config file and no other counterparts for borland etc.

            ThirdParty\include\ruby\2.0\win32\i386-mswin32_100\ruby\config.h

            1 Reply Last reply Reply Quote 0
            • tt_suT Offline
              tt_su
              last edited by

              @jiminy-billy-bob said:

              I just came accross an issue you guys should know about (if you don't already) : We can't pass more than 15 arguments in a single function from ruby to C++.

              You actually hit that limit? 😲

              1 Reply Last reply Reply Quote 0
              • tt_suT Offline
                tt_su
                last edited by

                @garry k said:

                It looks like I'll have to use the visual studio compiler for c extensions in sketchup.
                There is an MS specific config file and no other counterparts for borland etc.

                ThirdParty\include\ruby\2.0\win32\i386-mswin32_100\ruby\config.h

                For the examples we provided projects only for Visual Studio on Windows and Xcode on OSX. If you want to compile with another compiler you are free to do so - but we don't provide examples for all compilers.

                1 Reply Last reply Reply Quote 0
                • jiminy-billy-bobJ Offline
                  jiminy-billy-bob
                  last edited by

                  @tt_su said:

                  @jiminy-billy-bob said:

                  I just came accross an issue you guys should know about (if you don't already) : We can't pass more than 15 arguments in a single function from ruby to C++.

                  You actually hit that limit? 😲

                  Well... 😕 I try to limit the back-and-forth between ruby and C++, so I pass all the information in one go, and treat everything in C++.

                  25% off Skatter for SketchUcation Premium Members

                  1 Reply Last reply Reply Quote 0
                  • tt_suT Offline
                    tt_su
                    last edited by

                    @jiminy-billy-bob said:

                    @tt_su said:

                    @jiminy-billy-bob said:

                    I just came accross an issue you guys should know about (if you don't already) : We can't pass more than 15 arguments in a single function from ruby to C++.

                    You actually hit that limit? 😲

                    Well... 😕 I try to limit the back-and-forth between ruby and C++, so I pass all the information in one go, and treat everything in C++.

                    A Hash would be good to pass instead - much easier to manage whenever you change some of the data you pass. No need to worry about changing argument order etc.

                    1 Reply Last reply Reply Quote 0
                    • G Offline
                      Garry K
                      last edited by

                      I have a good start on SUEX_HelloWorld using C++Builder 6

                      I've added cbuilder folder at the same level as the i386-mswin32_100 folder. Then I added a ruby folder and copied over the config.h files. Then I've edited the config files. I'm happy to say that I didn't have to edit any other 3rd party file.

                      Then I ran implib.exe -a msvcrt-ruby200.lib msvcrt-ruby200.dll and created Borland's flavor of each lib file.
                      After that I set up a couple of include file paths and added msvcrt-ruby200.lib to the probject.
                      Turned off precompiled headers and unchecked use dynamic rtl

                      I now have it compiling - but currently just for the win32 flavor for SU 2014
                      Now for a bit of testing.

                      Hopefully I'm on the right path. I'm pretty sure I need to export the function as cdecl for this to work.

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        Garry K
                        last edited by

                        Turns out it's a stdcall which has no mangling.

                        I can debug the c extension in CBuilder. Very fast.
                        Now I need to experiment with arguments etc. That will be the acid test for stdcall
                        If anyone is interested I can post the files and the steps.

                        Once I get a real good handle on this I'll try it out with XE7 which is a compiler that compiles Win32, Win64 and OSX.

                        I will also test this on my lap top where Borland memory manager (a dll) doesn't exist. It will tell me if I need to include any of these files or not.

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 4
                        • 1 / 4
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement