3. MS에서 .NET platform을 밀고 있음.
툴 작성이 더 편리해짐.
GUI 쪽이 많이 편함.
Windows Forms
WPF Windows Presentation Foundation
작성했던 C++ 코드를 다 버려야 하나?
C++/CLI
C++, .NET framework 징검다리 역할.
5. C++
/CLI
Compiler
http://en.wikipedia.org/wiki/Common_Language_Infrastructure
6. 가능한 애플리케이션
3D object visualization tools
Level editors
Conversion tools and plug-ins
7. 어떻게 달라졌나?
heap이 두 종류
pure c++ heap
garbage collected heap
pure c++ heap
control * ctrl = new button();
garbage collected heap
control ^ ctrl = gcnew button();
8. 어떻게 달라졌나?
소멸자에서 Dispose() 호출
키워드 추가
property, delegate, event
Language Features for Targeting the CLR
http://goo.gl/cPq7b
9. 장점
DLLImport 필요 없다.
Win32 바로 호출
C++ 컴파일러 최적화 젂략 여젂히 유효.
.NET, C++ 라이브러리를 사용 가능.
다른 .NET 언어에서 사용 가능
C++/CLI로 만든 컴포넌트를
10. 단점
컴파일러가 상대적으로 최근에 만들어짐
몇 가지 제한
DLLMain에서 .NET 코드를 호출하지 못함
managed 와 unmanaged
컨텍스트 스위칭에 비용이 크다.
16. Exchanging Data
heap이 두 종류
pure c++ heap
garbage collected heap
간단한 타입은 잘 동작
복잡한 타입인 경우 바로 접근은 불가능
arrays, strings
17. Exchanging Data
컴파일 성공
// native function call
int adaptersCount = pD3D->GetAdapterCount();
this->adaptersTextBox->Text = adaptersCount.ToString();
컴파일 실패
fwrite(
textBox->Text, sizeof(char), textbox->Text->Length,
pFile);
18. Pointers and Keeping References
ref class WorldEntity // A managed class
{
...
private:
CMesh* m_graphicalRep; // native pointer
};
가능
19. Pointers and Keeping References
class CMesh : public CPlacable3D
{
...
private:
WorldEntity^ m_properties // reference managed object
};
Marshal 클래스가 가능하게 해준다.
native VARIANT 구조체를 대신 사용
16 bytes