-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #239 from ruby-rice/dev
Improved Callback Support
- Loading branch information
Showing
28 changed files
with
623 additions
and
187 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef Rice__Callback__hpp_ | ||
#define Rice__Callback__hpp_ | ||
|
||
namespace Rice | ||
{ | ||
//! Define a callback. | ||
/*! When C++ invokes a C style callback, Rice automatically converts the C++ arguments | ||
* to Ruby. However, there may be cases where you need to specify how individual arguments | ||
* should be handled. For example, callbacks often have a user data parameter which is | ||
* defined as a void pointer (void*). In this case, you need to tell Ruby that the parameter | ||
* is opaque and should not be convered. For example: | ||
* | ||
* define_callback<void(*)(void*)>(Arg("user_data").setOpaque()); | ||
* | ||
* \param args a list of Arg instance used to define default parameters (optional) | ||
* \return nothing | ||
*/ | ||
template<typename Callback_T, typename...Arg_Ts> | ||
void define_callback(const Arg_Ts&...args); | ||
} | ||
#endif // Rice__Callback__hpp_ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Rice | ||
{ | ||
template<typename Callback_T, typename...Arg_Ts> | ||
void define_callback(const Arg_Ts&...args) | ||
{ | ||
MethodInfo* methodInfo = new MethodInfo(detail::function_traits<Callback_T>::arity, args...); | ||
#ifdef HAVE_LIBFFI | ||
detail::NativeCallbackFFI<Callback_T>::setMethodInfo(methodInfo); | ||
#else | ||
detail::NativeCallbackSimple<Callback_T>::setMethodInfo(methodInfo); | ||
#endif | ||
} | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.