Created
November 7, 2022 23:23
-
-
Save ParadoxV5/81dd242b9b0d346c9f6847a70f4674a5 to your computer and use it in GitHub Desktop.
[MRI only] Hello World in Ruby – the wrong way (Ruby Fiddle study with a brief touch on MRI C API)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'fiddle' | |
include Fiddle | |
GREETINGS = 'hello, world' | |
Handle.new.then do |lib| | |
Function.new( | |
lib['rb_eval_string'], | |
[TYPE_CONST_STRING], | |
TYPE_UINTPTR_T, # VALUE | |
need_gvl: true | |
).call("$><<'#{GREETINGS}'+?\\n") | |
ensure | |
lib.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment