Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
C++Builder (bcc32), Use TFunc and __interface.
__interface INTERFACE_UUID("{CDD31E83-6E4E-4319-B2CA-98CCE8725E28}") IA : public IInterface
{
public:
virtual UnicodeString __fastcall a(DelphiInterface<TFunc__1<UnicodeString> > pro) = 0;
};
struct TA: public TCppInterfacedObject<IA, TFunc__1<UnicodeString> >
{
UnicodeString f_string1;
TObject* dummy_;
UnicodeString __fastcall Invoke(){ return f_string1;};
UnicodeString __fastcall a(DelphiInterface<TFunc__1<UnicodeString> > pro){
UnicodeString s = pro.operator ->()->Invoke();
return s;
}
__fastcall TA(UnicodeString s): TCppInterfacedObject<IA, TFunc__1<UnicodeString> >()
{ dummy_ = new TObject(); f_string1 = s;}
__fastcall ~TA(){
delete dummy_; }
};
typedef DelphiInterface<IA> _di_IA;
typedef DelphiInterface< TFunc__1<UnicodeString> > _di_TFunc__1;
//---------------------------------------------------------------------------
__fastcall Tfm_main1::Tfm_main1(TComponent* Owner)
: TForm(Owner)
{
_di_TFunc__1 func1 = new TA("bcc32-specific!");
_di_IA ifa1;
func1->Supports<IA>(ifa1);
UnicodeString s_ = ifa1->a(func1);
this->Caption = s_;
}
//---------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment