Re: Not Flowstone related - Ruby code question
Posted: Thu Apr 23, 2020 9:28 am
trog, thank you very much for explaining the background, which is important! You are right that it makes sense, as you explain it. Unfortunately this brings up another question: Does this code read C-functions and replaces setters with Ruby code? You see, I seem to have not quite figured it out yet.trogluddite wrote:The method is used within the C-extension which wraps the Cairo library (required as "cairo.so" in the Ruby code, and defined in the "ext/cairo" sub-folder of the Git repo). Since C++ code can't use "=" in member-function names, the "set_..." naming convention is used internally, and then the method in question is called to convert these into Ruby attr_writers when the extension is 'required'. Once the extension is loaded, the conversion method isn't needed any more and is undefined.TheOm wrote:I haven't found any actual use of __add_one_arg_setter in the code though, just an undef, so not sure why they need it.
So the method does serve a useful purpose; though I agree with tulamide that it's coded in a pretty clumsy way - and there's even part of it that does nothing useful at all (presumably a silly oversight)...This will always be false, as the Array of method names will contain Symbols, not Strings!Code: Select all
include? "#{$1}="
PS) The use of the C-extension implies that some Visual Studio C++ compilation would be required to get the library working in FlowStone.