Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetInvocationList to System.Delegate #1400

Merged
merged 3 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/CLR/CorLib/corlib_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
NULL,
Library_corlib_native_System_Array::TrySzIndexOf___STATIC__BOOLEAN__SystemArray__I4__I4__OBJECT__BYREF_I4,
Library_corlib_native_System_Delegate::Equals___BOOLEAN__OBJECT,
Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_SystemDelegate,
Library_corlib_native_System_Delegate::get_Method___SystemReflectionMethodInfo,
Library_corlib_native_System_Delegate::get_Target___OBJECT,
NULL,
Expand Down Expand Up @@ -903,7 +904,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_mscorlib =
{
"mscorlib",
0x17723A6B,
0x6AC9143D,
method_lookup,
{ 100, 2, 1, 0 }
{ 100, 2, 2, 0 }
};
1 change: 1 addition & 0 deletions src/CLR/CorLib/corlib_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ struct Library_corlib_native_System_Array
struct Library_corlib_native_System_Delegate
{
NANOCLR_NATIVE_DECLARE(Equals___BOOLEAN__OBJECT);
NANOCLR_NATIVE_DECLARE(GetInvocationList___SZARRAY_SystemDelegate);
NANOCLR_NATIVE_DECLARE(get_Method___SystemReflectionMethodInfo);
NANOCLR_NATIVE_DECLARE(get_Target___OBJECT);
NANOCLR_NATIVE_DECLARE(Combine___STATIC__SystemDelegate__SystemDelegate__SystemDelegate);
Expand Down
56 changes: 56 additions & 0 deletions src/CLR/CorLib/corlib_native_System_Delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,62 @@ HRESULT Library_corlib_native_System_Delegate::Equals___BOOLEAN__OBJECT( CLR_RT_
NANOCLR_NOCLEANUP_NOLABEL();
}

HRESULT Library_corlib_native_System_Delegate::GetInvocationList___SZARRAY_SystemDelegate( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

CLR_RT_HeapBlock_Delegate *dlg = stack.Arg0().DereferenceDelegate();
CLR_RT_HeapBlock_Delegate_List *lst = (CLR_RT_HeapBlock_Delegate_List *)dlg;

int delegatesCount = 0;
CLR_RT_HeapBlock *returnArray = NULL;

// put the return array on the stack
CLR_RT_HeapBlock &top = stack.PushValueAndClear();

if (dlg) {
if (dlg->DataType() == DATATYPE_DELEGATELIST_HEAD) {
delegatesCount = lst->m_length;
} else {
delegatesCount = 1;
}
}

// create the result array
NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_Array::CreateInstance(top, delegatesCount, g_CLR_RT_WellKnownTypes.m_Delegate));

if (delegatesCount > 0) {

// get the pointer to the first element
returnArray = (CLR_RT_HeapBlock *)top.DereferenceArray()->GetFirstElement();

if (delegatesCount > 1) {
CLR_RT_HeapBlock *ptr = lst->GetDelegates();
// fill the array with the delegates
for (int i = 0; i < delegatesCount; i++) {

// create an instance of delegate
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*returnArray, g_CLR_RT_WellKnownTypes.m_Delegate));

//fetch delegate from list
dlg = ptr[i].DereferenceDelegate();
//set delegate reference to return element
returnArray->SetObjectReference(dlg);

returnArray++;
}
} else {
// create an instance of delegate
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*returnArray, g_CLR_RT_WellKnownTypes.m_Delegate));
//set delegate reference to return element
returnArray->SetObjectReference(dlg);
}
}

NANOCLR_NOCLEANUP();
}

HRESULT Library_corlib_native_System_Delegate::get_Method___SystemReflectionMethodInfo( CLR_RT_StackFrame& stack )
{
NATIVE_PROFILE_CLR_CORE();
Expand Down