Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Include DataConverter in StructByReference in Ruby code to simplify ordering.
- Loading branch information
Showing
7 changed files
with
44 additions
and
103 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module FFI | ||
# This module is used to extend somes classes and give then a common API. | ||
# | ||
# Most of methods defined here must be overriden. | ||
module DataConverter | ||
# Get native type. | ||
# | ||
# @overload native_type(type) | ||
# @param [String, Symbol, Type] type | ||
# @return [Type] | ||
# Get native type from +type+. | ||
# | ||
# @overload native_type | ||
# @raise {NotImplementedError} This method must be overriden. | ||
def native_type(type = nil) | ||
if type | ||
@native_type = FFI.find_type(type) | ||
else | ||
native_type = @native_type | ||
unless native_type | ||
raise NotImplementedError, 'native_type method not overridden and no native_type set' | ||
end | ||
native_type | ||
end | ||
end | ||
|
||
# Convert to a native type. | ||
def to_native(value, ctx) | ||
value | ||
end | ||
|
||
# Convert from a native type. | ||
def from_native(value, ctx) | ||
value | ||
end | ||
end | ||
end |
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