sketchucation logo sketchucation
    • Login
    1. Home
    2. olilej
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download
    O
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 8
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Memory management in C++ Extension

      From what I understand, static function variables persists out of the scope of the function and are only allocated once in a specific memory area.
      As this memory was allocated using a VALUE pointer unknown from Ruby, the Garbage Collector cleaned it up and I ended up with a Memory Access Violation.

      So I would say, it is not a good idea to use a static variable of type VALUE, unless you find a way to tell Ruby GC by marking it.

      posted in Developers' Forum
      O
      olilej
    • RE: Memory management in C++ Extension

      I finally found my silly mistake using static keyword here, it was getting in the way of the GC.

      %(#404080)[VALUE CRubyUtils::GetDAttribute(VALUE obj, VALUE att) { ~~static~~ VALUE getatt = rb_intern("get_attribute"); ~~static~~ VALUE dicatt = rb_str_new2("dynamic_attributes"); return rb_funcall(obj, getatt, 2, dicatt, att); }]

      👍 Thanks for your support, might see you at Basecamp.

      posted in Developers' Forum
      O
      olilej
    • RE: Memory management in C++ Extension

      I first typedefed VALUE and ID because of some include issues with ruby.h there. But it seems to be over now.

      I changed the code to allocate the wrapped C++ class using rb_define_alloc_func but that didn't solved the issue.

      I get the memory error whenever I call load_model a second time, and need to do before some cleaning in the Reset() method of dynamically allocated memory (EntityInfo) in the tree.

      posted in Developers' Forum
      O
      olilej
    • RE: Memory management in C++ Extension

      I'm trying to see if I can get some collision detection. I've only wrap one object to get access to the active_model. Visual Studio allows to go in debug mode, so I don't see any exception happening. I tried smart pointers but got back to regular pointers.

      Link Preview Image
      Home

      Geometry Analysis with SketchUp Ruby C/C++ Extension - Home · olilej/SkpColl Wiki

      favicon

      GitHub (github.com)

      posted in Developers' Forum
      O
      olilej
    • Memory management in C++ Extension

      Hello,

      I've been playing with C/C++ extension starting from the Simple Extension example and I'm currently facing some challenges dealing with memory.
      My goal is to build a tree in memory matching like the Outliner, and load the geometry to do some analysis.
      I've built a class with a tree structure named "Coll" of pointer type "Entity", who has a std::vector of pointer of "Points". I always got a memory corruption error whenever I want to reload and delete some allocated memory.
      What am I doing wrong ?

      Olivier

      posted in Developers' Forum
      O
      olilej
    • RE: Simple Extension for Mac

      Great, my goal is to make sure I'm dealing with a Entity in order to access its attributes.

      Here is the code I've come up with.

      VALUE result = rb_obj_is_kind_of(obj, rb_path2class("Sketchup;;Entity"));
      if (Qtrue == result){
      	VALUE rval = rb_funcall(obj, rb_intern("get_attribute"), 2, rb_str_new2("dynamic_attributes"), rb_str_new2("..."));
      	...
      }
      
      posted in Developers' Forum
      O
      olilej
    • RE: Simple Extension for Mac

      I've been playing around with C Extension recently and I would like to know how if there is an equivalent of is_a? ruby function in C level.

      I found rb_obj_is_instance_of but it seems to be only meant for native ruby types.

      posted in Developers' Forum
      O
      olilej
    • RE: Simple Extension for Mac

      I looked over that SimpleExtension example, it seems very promising.

      By the way, what exactly are the real benefit of using Ruby C Extension ? Does this have to do with performance ? As in SketchUp 2013, C++ SDK doesn't allow model interaction, it would be very interesting if we could improve the plugins efficiency with that possibility.

      Olivier

      posted in Developers' Forum
      O
      olilej
    • 1 / 1