Guest User

Untitled

a guest
Oct 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. // The 'rb_define_global_function' can be found in class.c
  2.  
  3. /*!
  4. * Defines a global function
  5. * \param name name of the function
  6. * \param func the method body
  7. * \param argc the number of parameters, or -1 or -2. see \ref defmethod.
  8. */
  9. void
  10. rb_define_global_function(const char *name, VALUE (*func)(ANYARGS), int argc)
  11. {
  12. rb_define_module_function(rb_mKernel, name, func, argc);
  13. }
  14.  
  15. // As you can see, this just defines a method on the "Kernel"-Module (which is defined in object.c)
  16.  
  17. /*!
  18. * Defines a module function for \a module.
  19. * \param module an module or a class.
  20. * \param name name of the function
  21. * \param func the method body
  22. * \param argc the number of parameters, or -1 or -2. see \ref defmethod.
  23. */
  24. void
  25. rb_define_module_function(VALUE module, const char *name, VALUE (*func)(ANYARGS), int argc)
  26. {
  27. rb_define_private_method(module, name, func, argc);
  28. rb_define_singleton_method(module, name, func, argc);
  29. }
Add Comment
Please, Sign In to add comment