1 #include <nsIInterfaceInfoManager.h>
8 class WrappedCLR
: public nsXPTCStubBase
11 typedef int (*MethodInvoker
)(int, nsXPTCMiniVariant
*);
14 NS_IMETHOD
GetInterfaceInfo(nsIInterfaceInfo
**aInfo
);
15 NS_IMETHOD
CallMethod(PRUint16 methodIndex
,
16 const nsXPTMethodInfo
*info
,
17 nsXPTCMiniVariant
*params
);
18 WrappedCLR(MethodInvoker del
, const nsIID
&id
) :
19 mIID(id
), mDelegate(del
) { }
20 virtual ~WrappedCLR() { }
23 MethodInvoker mDelegate
;
26 NS_IMPL_ISUPPORTS1(WrappedCLR
, nsISupports
);
29 WrappedCLR::GetInterfaceInfo(nsIInterfaceInfo
**info
)
31 extern nsIInterfaceInfoManager
*infomgr
;
32 return infomgr
->GetInfoForIID(&mIID
, info
);
36 WrappedCLR::CallMethod(PRUint16 methodIndex
,
37 const nsXPTMethodInfo
*info
,
38 nsXPTCMiniVariant
*params
)
40 fprintf(stderr
, "Calling %s via %p\n", info
->GetName(), mDelegate
);
41 return mDelegate(methodIndex
, params
);
44 extern "C" WrappedCLR
*
45 WrapCLRObject(WrappedCLR::MethodInvoker del
, const nsIID
&id
)
47 char *idstr
= id
.ToString();
48 fprintf(stderr
, "Wrapping %p as %s\n", del
, idstr
);
50 return new WrappedCLR(del
, id
);