Einzelnen Beitrag anzeigen

wschrabi

Registriert seit: 16. Jan 2005
448 Beiträge
 
#6

AW: Übergabe von einem selbdef. Type in C++

  Alt 11. Apr 2017, 13:59
So also ich konnte compilieren, doch wenn ich was ändere und abspeichere dann ändert er automatisch immer mein Abstractclass.hpp file

so sieht es aus wo das kompilieren nicht mehr geht:
Delphi-Quellcode:
unit DelphiAbstractClass;


interface

uses
   UnitTyp;

type
  TAbstractClass = class
  protected
    function GetDummy : integer; virtual; abstract;
    procedure SetDummy(Value : integer); virtual; abstract;
    function GetMTCount : integer; virtual; abstract;
    procedure SetMTCount(Value : integer); virtual; abstract;
    function GetText : ansistring; virtual; abstract;
    procedure SetText(Value : ansistring); virtual; abstract;
    function GetTTT : ansistring; virtual; abstract;
    procedure SetTTT (Value : ansistring); virtual; abstract;
    function GetTTInput : Tinputvec; virtual; abstract;
    procedure SetTTInput (Value : tinputvec); virtual; abstract;
    
  public
    procedure DoSomething; virtual; abstract;
    procedure DoTTable; virtual; abstract;
    property Text : ansistring read GetText write SetText;
    property TTT : ansistring read GetTTT write SetTTT;
    property TTInput :tinputvec read GetTTInput write SetTTInput;
    property Dummy : integer read GetDummy write SetDummy;
    property MTCount : integer read GetMTCount write SetMTCount;
  end;

  function CreateCppDescendant : TAbstractClass; stdcall; external 'CPPPackage.bpl';

implementation

end.
Dieses File wird dann autmo. erstellt.
Code:
// CodeGear C++Builder
// Copyright (c) 1995, 2016 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'DelphiAbstractClass.pas' rev: 32.00 (Windows)

#ifndef DelphiabstractclassHPP
#define DelphiabstractclassHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx     // Zero-length empty class member
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <UnitTyp.hpp>

//-- user supplied -----------------------------------------------------------

namespace Delphiabstractclass
{
//-- forward type declarations -----------------------------------------------
class DELPHICLASS TAbstractClass;
//-- type declarations -------------------------------------------------------
#pragma pack(push,4)
class PASCALIMPLEMENTATION TAbstractClass : public System::TObject
{
   typedef System::TObject inherited;
   
protected:
   virtual int __fastcall GetDummy(void) = 0 ;
   virtual void __fastcall SetDummy(int Value) = 0 ;
   virtual int __fastcall GetMTCount(void) = 0 ;
   virtual void __fastcall SetMTCount(int Value) = 0 ;
   virtual System::AnsiString __fastcall GetText(void) = 0 ;
   virtual void __fastcall SetText(System::AnsiString Value) = 0 ;
   virtual System::AnsiString __fastcall GetTTT(void) = 0 ;
   virtual void __fastcall SetTTT(System::AnsiString Value) = 0 ;
   virtual Unittyp::Tinputvec __fastcall GetTTInput(void) = 0 ;
   [I]virtual void __fastcall SetTTInput(const Unittyp::Tinputvec Value) = 0 ;[/I]
   
public:
   virtual void __fastcall DoSomething(void) = 0 ;
   virtual void __fastcall DoTTable(void) = 0 ;
   __property System::AnsiString Text = {read=GetText, write=SetText};
   __property System::AnsiString TTT = {read=GetTTT, write=SetTTT};
   __property Unittyp::Tinputvec TTInput = {read=GetTTInput, write=SetTTInput};
   __property int Dummy = {read=GetDummy, write=SetDummy, nodefault};
   __property int MTCount = {read=GetMTCount, write=SetMTCount, nodefault};
public:
   /* TObject.Create */ inline __fastcall TAbstractClass(void) : System::TObject() { }
   /* TObject.Destroy */ inline __fastcall virtual ~TAbstractClass(void) { }
   
};

#pragma pack(pop)

//-- var, const, procedure ---------------------------------------------------
extern "C" TAbstractClass* __stdcall CreateCppDescendant(void);
}   /* namespace Delphiabstractclass */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_DELPHIABSTRACTCLASS)
using namespace Delphiabstractclass;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif   // DelphiabstractclassHPP
Wenn ich die Zeile dann manuale in das abändere kann ich wieder compilieren.

Code:
   virtual void __fastcall SetTTInput(const DynamicArray<int>& Value) = 0 ;
Gibts da eine Lösung, auch habe ich in dem File: CPPClass.cpp die INit von m_DVector drin, daher habe ich immer 5 Elemente in der Abrage:

Code:
__fastcall TCppClass::TCppClass() :
   TAbstractClass(),
   m_Dummy (0),
   m_MTCount (0),
   m_Text(L"Initialised in C++___________________________"),
   m_TTT (L"Initialised in C++___________________________"),
   //m_TTT(L"__;xy#"),
   m_Vector { 1, 2, 3, 4, 5 },
   m_DVector{ 1, 2, 3, 4, 5 } 
{

}
Abfrage:

Code:
void __fastcall TCppClass::DoSomething() {

   //System::AnsiString qmc_result;
   //qmc_result=calcmain(m_MTCount).c_str();
   if (GetDummy() == 1) {
     //   MessageBox(0, L"Now Dummy-String", L"Delphi/C++ interaction", 0);
      TCppClass::SetText(L"My DUMMY:RESULT");
      TCppClass::SetTTT(L"__ __;DUMMY#");
     
      }
   else
      {   
      TCppClass::SetText(calcmain(m_MTCount).c_str());    // does work
      }
   //TCppClass::SetText(L"myreslut:x");           // works fine
   
   std::wstringstream strMessage;
   strMessage << L"Hello from a C++ class. Result of QMC is: " << m_Text.c_str()
      << std::endl
      << L"InputVector contains " << std::to_wstring(m_DVector.Length) << " elements";

   MessageBox(0, strMessage.str().c_str(), L"Delphi/C++ interaction", 0);
   //TCppClass::SetText(qmc_result);           // works NOT fine
   
}
Danke für die TIPS.
Walter

Geändert von wschrabi (11. Apr 2017 um 14:04 Uhr)
  Mit Zitat antworten Zitat