Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
e2375f48
Unverified
Commit
e2375f48
authored
May 21, 2019
by
Ignacio Roldán Etcheverry
Committed by
GitHub
May 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #29079 from neikeq/oopsie
Fix C# build error in MarshalUtils debug code
parents
00232b15
9b76c560
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
27 deletions
+84
-27
NodeExtensions.cs
modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
+2
-2
MarshalUtils.cs
modules/mono/glue/Managed/Files/MarshalUtils.cs
+39
-1
Node.cs
modules/mono/glue/Managed/IgnoredFiles/Node.cs
+3
-2
gd_mono_marshal.cpp
modules/mono/mono_gd/gd_mono_marshal.cpp
+8
-16
gd_mono_utils.cpp
modules/mono/mono_gd/gd_mono_utils.cpp
+24
-4
gd_mono_utils.h
modules/mono/mono_gd/gd_mono_utils.h
+8
-2
No files found.
modules/mono/glue/Managed/Files/Extensions/NodeExtensions.cs
View file @
e2375f48
...
...
@@ -24,12 +24,12 @@ namespace Godot
public
T
GetOwner
<
T
>()
where
T
:
class
{
return
(
T
)(
object
)
GetOwner
()
;
return
(
T
)(
object
)
Owner
;
}
public
T
GetOwnerOrNull
<
T
>()
where
T
:
class
{
return
GetOwner
()
as
T
;
return
Owner
as
T
;
}
public
T
GetParent
<
T
>()
where
T
:
class
...
...
modules/mono/glue/Managed/Files/MarshalUtils.cs
View file @
e2375f48
...
...
@@ -23,7 +23,7 @@ namespace Godot
/// <summary>
/// Returns <see langword="true"/> if the generic type definition of <paramref name="type"/>
/// is <see cref="Godot.Collections.Dictionary{T}"/>; otherwise returns <see langword="false"/>.
/// is <see cref="Godot.Collections.Dictionary{T
Key, TValue
}"/>; otherwise returns <see langword="false"/>.
/// </summary>
/// <exception cref="System.InvalidOperationException">
/// <paramref name="type"/> is not a generic type. That is, IsGenericType returns false.
...
...
@@ -45,6 +45,44 @@ namespace Godot
valueType
=
genericArgs
[
1
];
}
static
bool
GenericIEnumerableIsAssignableFromType
(
Type
type
)
{
if
(
type
.
IsGenericType
&&
type
.
GetGenericTypeDefinition
()
==
typeof
(
IEnumerable
<>))
return
true
;
foreach
(
var
interfaceType
in
type
.
GetInterfaces
())
{
if
(
interfaceType
.
IsGenericType
&&
interfaceType
.
GetGenericTypeDefinition
()
==
typeof
(
IEnumerable
<>))
return
true
;
}
Type
baseType
=
type
.
BaseType
;
if
(
baseType
==
null
)
return
false
;
return
GenericIEnumerableIsAssignableFromType
(
baseType
);
}
static
bool
GenericIDictionaryIsAssignableFromType
(
Type
type
)
{
if
(
type
.
IsGenericType
&&
type
.
GetGenericTypeDefinition
()
==
typeof
(
IDictionary
<,>))
return
true
;
foreach
(
var
interfaceType
in
type
.
GetInterfaces
())
{
if
(
interfaceType
.
IsGenericType
&&
interfaceType
.
GetGenericTypeDefinition
()
==
typeof
(
IDictionary
<,>))
return
true
;
}
Type
baseType
=
type
.
BaseType
;
if
(
baseType
==
null
)
return
false
;
return
GenericIDictionaryIsAssignableFromType
(
baseType
);
}
static
bool
GenericIEnumerableIsAssignableFromType
(
Type
type
,
out
Type
elementType
)
{
if
(
type
.
IsGenericType
&&
type
.
GetGenericTypeDefinition
()
==
typeof
(
IEnumerable
<>))
...
...
modules/mono/glue/Managed/IgnoredFiles/Node.cs
View file @
e2375f48
...
...
@@ -15,9 +15,10 @@ namespace Godot
throw
new
NotImplementedException
();
}
public
Node
GetOwner
()
public
Node
Owner
{
throw
new
NotImplementedException
();
get
=>
throw
new
NotImplementedException
();
set
=>
throw
new
NotImplementedException
();
}
public
Node
GetParent
()
...
...
modules/mono/mono_gd/gd_mono_marshal.cpp
View file @
e2375f48
...
...
@@ -161,8 +161,7 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
MonoReflectionType
*
reftype
=
mono_type_get_object
(
SCRIPTS_DOMAIN
,
type_class
->
get_mono_type
());
MonoReflectionType
*
key_reftype
,
*
value_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
,
&
key_reftype
,
&
value_reftype
))
{
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
))
{
return
Variant
::
DICTIONARY
;
}
...
...
@@ -170,8 +169,7 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
return
Variant
::
DICTIONARY
;
}
MonoReflectionType
*
elem_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
,
&
elem_reftype
))
{
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
))
{
return
Variant
::
ARRAY
;
}
...
...
@@ -193,16 +191,14 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
// The order in which we check the following interfaces is very important (dictionaries and generics first)
MonoReflectionType
*
key_reftype
,
*
value_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
,
&
key_reftype
,
&
value_reftype
))
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
))
return
Variant
::
DICTIONARY
;
if
(
p_type
.
type_class
->
implements_interface
(
CACHED_CLASS
(
System_Collections_IDictionary
)))
{
return
Variant
::
DICTIONARY
;
}
MonoReflectionType
*
elem_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
,
&
elem_reftype
))
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
))
return
Variant
::
ARRAY
;
if
(
p_type
.
type_class
->
implements_interface
(
CACHED_CLASS
(
System_Collections_IEnumerable
)))
{
...
...
@@ -850,8 +846,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
MonoReflectionType
*
reftype
=
mono_type_get_object
(
SCRIPTS_DOMAIN
,
type_class
->
get_mono_type
());
MonoReflectionType
*
key_reftype
,
*
value_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
,
&
key_reftype
,
&
value_reftype
))
{
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
))
{
return
GDMonoUtils
::
Marshal
::
generic_idictionary_to_dictionary
(
p_obj
);
}
...
...
@@ -859,8 +854,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
return
GDMonoUtils
::
Marshal
::
idictionary_to_dictionary
(
p_obj
);
}
MonoReflectionType
*
elem_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
,
&
elem_reftype
))
{
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
))
{
return
GDMonoUtils
::
Marshal
::
enumerable_to_array
(
p_obj
);
}
...
...
@@ -888,8 +882,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
// The order in which we check the following interfaces is very important (dictionaries and generics first)
MonoReflectionType
*
key_reftype
,
*
value_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
,
&
key_reftype
,
&
value_reftype
))
{
if
(
GDMonoUtils
::
Marshal
::
generic_idictionary_is_assignable_from
(
reftype
))
{
return
GDMonoUtils
::
Marshal
::
generic_idictionary_to_dictionary
(
p_obj
);
}
...
...
@@ -897,8 +890,7 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
return
GDMonoUtils
::
Marshal
::
idictionary_to_dictionary
(
p_obj
);
}
MonoReflectionType
*
elem_reftype
;
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
,
&
elem_reftype
))
{
if
(
GDMonoUtils
::
Marshal
::
generic_ienumerable_is_assignable_from
(
reftype
))
{
return
GDMonoUtils
::
Marshal
::
enumerable_to_array
(
p_obj
);
}
...
...
modules/mono/mono_gd/gd_mono_utils.cpp
View file @
e2375f48
...
...
@@ -161,6 +161,8 @@ void MonoCache::clear_members() {
methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType
=
NULL
;
methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType
=
NULL
;
methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType_with_info
=
NULL
;
methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType_with_info
=
NULL
;
methodthunk_MarshalUtils_MakeGenericArrayType
=
NULL
;
methodthunk_MarshalUtils_MakeGenericDictionaryType
=
NULL
;
...
...
@@ -282,8 +284,10 @@ void update_godot_api_cache() {
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
ArrayGetElementType
,
(
ArrayGetElementType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"ArrayGetElementType"
,
2
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
DictionaryGetKeyValueTypes
,
(
DictionaryGetKeyValueTypes
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"DictionaryGetKeyValueTypes"
,
3
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
GenericIEnumerableIsAssignableFromType
,
(
GenericIEnumerableIsAssignableFromType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"GenericIEnumerableIsAssignableFromType"
,
2
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
GenericIDictionaryIsAssignableFromType
,
(
GenericIDictionaryIsAssignableFromType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"GenericIDictionaryIsAssignableFromType"
,
3
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
GenericIEnumerableIsAssignableFromType
,
(
GenericIEnumerableIsAssignableFromType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"GenericIEnumerableIsAssignableFromType"
,
1
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
GenericIDictionaryIsAssignableFromType
,
(
GenericIDictionaryIsAssignableFromType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"GenericIDictionaryIsAssignableFromType"
,
1
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
GenericIEnumerableIsAssignableFromType_with_info
,
(
GenericIEnumerableIsAssignableFromType_with_info
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"GenericIEnumerableIsAssignableFromType"
,
2
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
GenericIEnumerableIsAssignableFromType_with_info
,
(
GenericIEnumerableIsAssignableFromType_with_info
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"GenericIDictionaryIsAssignableFromType"
,
3
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
MakeGenericArrayType
,
(
MakeGenericArrayType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"MakeGenericArrayType"
,
1
));
CACHE_METHOD_THUNK_AND_CHECK
(
MarshalUtils
,
MakeGenericDictionaryType
,
(
MakeGenericDictionaryType
)
GODOT_API_CLASS
(
MarshalUtils
)
->
get_method_thunk
(
"MakeGenericDictionaryType"
,
2
));
...
...
@@ -787,16 +791,32 @@ void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoRefl
UNLIKELY_UNHANDLED_EXCEPTION
(
exc
);
}
MonoBoolean
generic_ienumerable_is_assignable_from
(
MonoReflectionType
*
p_reftype
,
MonoReflectionType
**
r_elem_reftype
)
{
MonoBoolean
generic_ienumerable_is_assignable_from
(
MonoReflectionType
*
p_reftype
)
{
GenericIEnumerableIsAssignableFromType
thunk
=
CACHED_METHOD_THUNK
(
MarshalUtils
,
GenericIEnumerableIsAssignableFromType
);
MonoException
*
exc
=
NULL
;
MonoBoolean
res
=
invoke_method_thunk
(
thunk
,
p_reftype
,
&
exc
);
UNLIKELY_UNHANDLED_EXCEPTION
(
exc
);
return
res
;
}
MonoBoolean
generic_idictionary_is_assignable_from
(
MonoReflectionType
*
p_reftype
)
{
GenericIDictionaryIsAssignableFromType
thunk
=
CACHED_METHOD_THUNK
(
MarshalUtils
,
GenericIDictionaryIsAssignableFromType
);
MonoException
*
exc
=
NULL
;
MonoBoolean
res
=
invoke_method_thunk
(
thunk
,
p_reftype
,
&
exc
);
UNLIKELY_UNHANDLED_EXCEPTION
(
exc
);
return
res
;
}
MonoBoolean
generic_ienumerable_is_assignable_from
(
MonoReflectionType
*
p_reftype
,
MonoReflectionType
**
r_elem_reftype
)
{
GenericIEnumerableIsAssignableFromType_with_info
thunk
=
CACHED_METHOD_THUNK
(
MarshalUtils
,
GenericIEnumerableIsAssignableFromType_with_info
);
MonoException
*
exc
=
NULL
;
MonoBoolean
res
=
invoke_method_thunk
(
thunk
,
p_reftype
,
r_elem_reftype
,
&
exc
);
UNLIKELY_UNHANDLED_EXCEPTION
(
exc
);
return
res
;
}
MonoBoolean
generic_idictionary_is_assignable_from
(
MonoReflectionType
*
p_reftype
,
MonoReflectionType
**
r_key_reftype
,
MonoReflectionType
**
r_value_reftype
)
{
GenericIDictionaryIsAssignableFromType
thunk
=
CACHED_METHOD_THUNK
(
MarshalUtils
,
GenericIDictionaryIsAssignableFromType
);
GenericIDictionaryIsAssignableFromType
_with_info
thunk
=
CACHED_METHOD_THUNK
(
MarshalUtils
,
GenericIDictionaryIsAssignableFromType_with_info
);
MonoException
*
exc
=
NULL
;
MonoBoolean
res
=
invoke_method_thunk
(
thunk
,
p_reftype
,
r_key_reftype
,
r_value_reftype
,
&
exc
);
UNLIKELY_UNHANDLED_EXCEPTION
(
exc
);
...
...
modules/mono/mono_gd/gd_mono_utils.h
View file @
e2375f48
...
...
@@ -64,8 +64,10 @@ typedef MonoBoolean (*TypeIsGenericDictionary)(MonoReflectionType *, MonoExcepti
typedef
void
(
*
ArrayGetElementType
)(
MonoReflectionType
*
,
MonoReflectionType
**
,
MonoException
**
);
typedef
void
(
*
DictionaryGetKeyValueTypes
)(
MonoReflectionType
*
,
MonoReflectionType
**
,
MonoReflectionType
**
,
MonoException
**
);
typedef
MonoBoolean
(
*
GenericIEnumerableIsAssignableFromType
)(
MonoReflectionType
*
,
MonoReflectionType
**
,
MonoException
**
);
typedef
MonoBoolean
(
*
GenericIDictionaryIsAssignableFromType
)(
MonoReflectionType
*
,
MonoReflectionType
**
,
MonoReflectionType
**
,
MonoException
**
);
typedef
MonoBoolean
(
*
GenericIEnumerableIsAssignableFromType
)(
MonoReflectionType
*
,
MonoException
**
);
typedef
MonoBoolean
(
*
GenericIDictionaryIsAssignableFromType
)(
MonoReflectionType
*
,
MonoException
**
);
typedef
MonoBoolean
(
*
GenericIEnumerableIsAssignableFromType_with_info
)(
MonoReflectionType
*
,
MonoReflectionType
**
,
MonoException
**
);
typedef
MonoBoolean
(
*
GenericIDictionaryIsAssignableFromType_with_info
)(
MonoReflectionType
*
,
MonoReflectionType
**
,
MonoReflectionType
**
,
MonoException
**
);
typedef
MonoReflectionType
*
(
*
MakeGenericArrayType
)(
MonoReflectionType
*
,
MonoException
**
);
typedef
MonoReflectionType
*
(
*
MakeGenericDictionaryType
)(
MonoReflectionType
*
,
MonoReflectionType
*
,
MonoException
**
);
...
...
@@ -82,6 +84,8 @@ MonoBoolean type_is_generic_dictionary(MonoReflectionType *p_reftype);
void
array_get_element_type
(
MonoReflectionType
*
p_array_reftype
,
MonoReflectionType
**
r_elem_reftype
);
void
dictionary_get_key_value_types
(
MonoReflectionType
*
p_dict_reftype
,
MonoReflectionType
**
r_key_reftype
,
MonoReflectionType
**
r_value_reftype
);
MonoBoolean
generic_ienumerable_is_assignable_from
(
MonoReflectionType
*
p_reftype
);
MonoBoolean
generic_idictionary_is_assignable_from
(
MonoReflectionType
*
p_reftype
);
MonoBoolean
generic_ienumerable_is_assignable_from
(
MonoReflectionType
*
p_reftype
,
MonoReflectionType
**
r_elem_reftype
);
MonoBoolean
generic_idictionary_is_assignable_from
(
MonoReflectionType
*
p_reftype
,
MonoReflectionType
**
r_key_reftype
,
MonoReflectionType
**
r_value_reftype
);
...
...
@@ -197,6 +201,8 @@ struct MonoCache {
GenericIEnumerableIsAssignableFromType
methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType
;
GenericIDictionaryIsAssignableFromType
methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType
;
GenericIEnumerableIsAssignableFromType_with_info
methodthunk_MarshalUtils_GenericIEnumerableIsAssignableFromType_with_info
;
GenericIDictionaryIsAssignableFromType_with_info
methodthunk_MarshalUtils_GenericIDictionaryIsAssignableFromType_with_info
;
MakeGenericArrayType
methodthunk_MarshalUtils_MakeGenericArrayType
;
MakeGenericDictionaryType
methodthunk_MarshalUtils_MakeGenericDictionaryType
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment