static R_VAL WriteLine(IntPtr state, R_VAL context) { R_VAL[] args = RubyDLL.GetFunctionArgs(state); string str = args[0].ToString(state); Console.WriteLine(str); return(context); }
/// <summary> /// Invokes the callback function /// </summary> /// <param name="executionContext">The execution context.</param> /// <param name="args">The arguments.</param> /// <param name="isMethodCall">if set to <c>true</c> this is a method call.</param> /// <returns></returns> public R_VAL Invoke(RubyState state, R_VAL self) { #if DEBUG try { #endif return(ClrCallback(state, Target, new CallbackArguments(RubyDLL.GetFunctionArgs(state)))); #if DEBUG } catch (Exception e) { Console.WriteLine($"Exception on CallbackFunction::Invoke() {Name}\n{e.Message}"); throw; } #endif }
public static object[] RubyFunctionParamsToObjects(IntPtr mrb, IntPtr data_type_ptr) { R_VAL[] value = RubyDLL.GetFunctionArgs(mrb); object[] ret = new object[value.Length]; for (int i = 0; i < ret.Length; i++) { ref R_VAL val = ref value[i]; if (!R_VAL.IsData(val)) { ret[i] = ValueToObject(mrb, val); } else { IntPtr ptr = RubyDLL.mrb_data_get_ptr(mrb, val, data_type_ptr); ret[i] = (( GCHandle )ptr).Target; } }
public R_VAL Invoke(RubyState state, int argc, R_VAL[] argv, R_VAL self) { #if DEBUG try { #endif #if MRUBY return(ClrCallback(state, Target, new CallbackArguments(RubyDLL.GetFunctionArgs(state)))); #else return(ClrCallback(state, Target, new CallbackArguments(argv))); #endif #if DEBUG } catch (Exception e) { Console.WriteLine($"Exception on CallbackFunction::Invoke() {Name}"); throw; } #endif }