-
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.
Change from storing method wrappers as hidden ivars on the appropriat…
…e Ruby class to storing them in a global C++ unordered_map. This has several advantages: * Removes some circular dependencies from lowel level detail code -> Data_Type/Data_Object -> low level details code * Avoids creating a new Data_Type<T> for each wrapped method_data * Avoids overhead of wrapping method_data in Ruby * Avoids the Ruby garbage collector
- Loading branch information
Showing
8 changed files
with
77 additions
and
107 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
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 |
---|---|---|
@@ -1,22 +1,30 @@ | ||
#ifndef Rice__detail__method_data__hpp | ||
#define Rice__detail__method_data__hpp | ||
|
||
#include <unordered_map> | ||
#include <any> | ||
|
||
#include "ruby.hpp" | ||
|
||
namespace Rice | ||
{ | ||
|
||
namespace detail | ||
{ | ||
|
||
VALUE define_method_with_data(VALUE klass, ID id, VALUE (*cfunc)(ANYARGS), int arity, VALUE data); | ||
|
||
VALUE method_data(); | ||
|
||
} // namespace detail | ||
|
||
} // namespace Rice | ||
|
||
namespace detail | ||
{ | ||
class MethodData | ||
{ | ||
public: | ||
// Defines a new Ruby method and stores the Rice metadata about it | ||
static void define_method(VALUE klass, ID id, VALUE(*cfunc)(ANYARGS), int arity, std::any data); | ||
|
||
// Returns the Rice data for the currently active Ruby method | ||
static std::any data(); | ||
|
||
private: | ||
static size_t key(VALUE klass, ID id); | ||
inline static std::unordered_map<size_t, std::any> methodWrappers_ = {}; | ||
}; | ||
} | ||
} | ||
#include "method_data.ipp" | ||
|
||
#endif // Rice__detail__method_data__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
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