狠狠撸

狠狠撸Share a Scribd company logo
? ?? ??? ?? ?? 
C++ - C# ?? ????? 
?? ???? ?? 
?????? 
Technical Director 
???
?? 
1. ?? 
2. C# (.NET) ???? 
3. ?? ? ????? ?? ??? 
4. ?? ? ?? ?? 
5. ?? 
6. ??
[KGC2014] ? ?? ??? ?? ?? C++ - C#  ?? ????? ?? ???? ??
[KGC2014] ? ?? ??? ?? ?? C++ - C#  ?? ????? ?? ???? ??
?? 
? ?? ?? 
? ??? ??? 
? ?? ??? 
? ??? ??? ??? 
? ?? ??? 
? ?? ??? (??, OOP …) 
? ??? ?? 
? C++? ??? ?? 
? ??? ?? ??? 
? ?? ??? ?? ???
[KGC2014] ? ?? ??? ?? ?? C++ - C#  ?? ????? ?? ???? ??
?? 
??? ?? ??? ?? ??? ??? 
??? ?? ??? ??? ?? 
? ??? ??? ?? 
? ??? ?? 
? ?? ????? ?? 
? ?? ??? ?? ??? ? 
?? ?? ??? ??? 
? ??? ???? ?? ??
[KGC2014] ? ?? ??? ?? ?? C++ - C#  ?? ????? ?? ???? ??
Native 
Code 
Script 
Lib
?? ?? 
C# ??? 
?? ? ???? 
? ??? 
?? ? ?? ??
C# (.NET) ????
Mono? = Microsoft .NET? ?? 
≈ ????, ?? ??
? ???? Mono ?? 
???? 
mono 
Runtime 
(.a .so .lib .dll) 
make 
make 
configure 
Compiler
App 
Embedded Mono 
Native Runtime 
.NET Assembly 
?? & JIT ??? 
? 
? 
? 
JIT / AOT Binary 
Mono Runtime 
?? 
.NET Compiler 
Objective-C 
Runtime 
Java VM
???? ?? C# ?? ?? 
.NET Compiler 
monolinker 
mono 
Reduced Assembly 
.NET Assembly 
Stripped Assembly 
mov … 
push … 
call … 
Assembly Code 
.NET Libraries 
AOT ???
Embedded Mono ???? 
Ahead-of-Time ??? 
– Just-in-Time ??? ???? ?? OS? ?? 
– ??? CPU/OS ?? ??? Mono ????? ??? ?? 
– ???? ?? ?? 
– ??? ????? C# ?? ???? ??? 
??? 
– Custom Command Soft Debugger ?? ?? 
– ??? ??? client, MonoDevelop? server? ?? 
– ????? Mono ??? ???? ??? ??? ?? ?? 
sgen GC ??? MonoObject* ?? gc_handle ? ?? 
mono_trace_set_level_string ?? ??
?? ? ????? ?? ???
??: ??? ??? ??? 
class Character 
{ 
void SetPosition( float ); 
float position; 
}; 
class Character 
{ 
void Touched() … 
void UpdateUI() … 
int health; 
}
??: ??? ??? ??? 
void Character::Touched() 
{ 
SetPosition( position + 1 ); 
} 
class Character 
{ 
void SetPosition( float ); 
float position; 
};
??: ??? ??? ??? 
void Character::SetPosition( float position ) 
{ 
… 
health = … 
UpdateUI(); 
} 
class Character 
{ 
void Touched() … 
void UpdateUI() … 
int health; 
}
??: ??? ??? ??? 
? ??? ??? ?? ??? ???? ?? 
? C# ??? C++ ??, C++ ??? C# ?? ?? 
? ?????? ?? ?? 
– ? ??? ?? ???? ?? ?? 
– ?? ??? ?? ??? ??(declaration) ?? 
? ?? ? ?????? ??? ????!
??? ????? ???? 
C++ ? 
??? 
(.h) 
C# ?? 
?? 
C++ ? 
???? 
C# ?? 
C# ?? 
??? 
C++ ? 
? 
2 
3 
4 
1 
CppSharp 
CXXI 
…
C#? ?? C++ ????? ???? 
CppSharp 
CXXI 
+ Clang 
1. C++ ?????? ??(!)?? ?????? ?? 
2. (C++ ?????? Mono? ???? C++ ??)? 
?? ??? ? ?? C# ?? ?? 
3. C# ???? ????? ??? ?? 
4. C# ?? ???? ????? ??? ?? ???
C++ ?? - Clang 
? LLVM ????? C/C++ ?? 
? ?? ?? ?? 
? Visual C++ ???? ?? 
? ???? ??? ?? ??? ???? ?? 
? libclang? ???? ???? ????? ?? ??, 
Python ?? ?? ?? – AST ?? 
? libclang? clang? ?? ??? ???? ???? 
? ???????? ??
C++ ????? ?? ?? (CppSharp) 
// C++ ???? 
class Foo 
{ 
int variable; 
int DoSomething ( int arg1, std::string arg2 ); 
}; 
// ?? ??? C#? ????? ?? 
class Foo 
{ 
// C++? ??? ???? ?? 
struct Internal { … } 
// ???? ?? ??? ????? 
int variable { 
get { return _Instance.ToPointer()->variable; } 
set { _Instance.ToPointer()->variable = value; } 
} 
int DoSomething( int arg1, string arg2 ) 
{ return Internal.DoSomething( _Instance, arg1, arg2 ); } 
}
C++ ????? ?? ?? (Embedded) 
// C++ ???? 
#define EXPORT __attribute__((annotate(“ExportToMono”))) 
class EXPORT Foo 
{ 
int variable; 
int DoSomething ( int arg1, std::string arg2 ); 
}; 
+ Clang 
// ?? ??? ??? ?? ?? 
RegisterNativeClass<Foo>(); 
RegisterNativeClassVariable<Foo,int>( “variable”, offsetof(Foo, variable) ); 
RegisterNativeClassMethod<Foo,int,int,std::string>( “DoSomething”, &Foo::DoSomething );
C++ ????? ?? ?? (Embedded) 
// ?? ??? ??? ?? ??? ?? ?? ?? ?? 
RegisterNativeClass<Foo>(); 
// Foo ??? ?? RTTI? ?? ?? ??? ?? 
RegisterNativeClassVariable<Foo,int>( “variable”, offsetof(Foo, variable) ); 
// C#?? ??? accessor ??? ?? 
int NativeGetInt( void* nativeObject, int offset ); 
mono_add_internal_call( “NativeGetInt”, &NativeGetInt ); 
void NativeSetInt( void* nativeObject, int offset, int value ); 
mono_add_internal_call( “NativeSetInt”, &NativeSetInt ); 
RegisterNativeClassMethod<Foo,int,int,std::string>( “DoSomething”, &Foo::DoSomething ); 
// C#?? ??? ??? ?? 
static int Foo_DoSomething( Foo* nativeObject, int arg1, std::string arg2 ) 
{ nativeObject->DoSomething( arg1, arg2 ); } 
mono_add_internal_call( “Foo.NativeCall_DoSomething”, &Foo_DoSomething );
C++ ????? ?? ?? (Embedded) 
// ?? ??? C#? ????? ?? 
class Foo 
{ 
// C++? ???? ?? 
[MethodImplAttribute(MethodImplOptions.InternalCall)] 
extern int NativeCall_DoSomething( IntPtr nativeObject, int arg1, string arg2 ); 
// ???? ?? ??? ????? 
int variable { 
get { return NativeGetInt( nativeObject, 4 ); } 
set { NativeSetInt( nativeObject, 4 ); } 
} 
int DoSomething( int arg1, string arg2 ) 
{ return NativeCall_DoSomething( nativeObject, arg1, arg2 ); } 
}
C++? ?? C# ????? ???? 
1. .NET reflection? ???? DLL ?? ????? 
? ?? 
2. DLL ?????? ??? ? ?? C++ ?? ?? 
3. C++ ?????? ????? ??? ?? DLL? 
??? C++ ?? ?? 
4. C++ ???? ???? ????? ??? ?? 
???
C# ????? ?? ?? (Delegate) 
// ?? ??? C# ????? ?? 
partial class Foo 
{ 
void ExposeToNative() { 
RegisterMonoMethod( 0, () => { return variable; } ); // Get_variable 
RegisterMonoMethod( 1, (int value) => { variable = value; } ); // Set_variable 
RegisterMonoMethod( 2, DoSomething ); // DoSomething 
} 
} 
// ?? ??? C++ ????? ?? 
class Foo 
{ 
int Get_variable() { monoMethods[0](); } 
void Set_variable( int value ) { return monoMethods[1]( value ); } 
int DoSomething( int arg1, std::string arg2 ) 
{ return monoMethods[2]( arg1, arg2 ); } 
}; 
delegate? native ?? ???? ?? 
RegisterMonoMethod? ?? ??? ?? ???
C# ????? ?? ?? (Embedded) 
// C# ???? 
[Export] 
class Foo 
{ 
// ?? ??? C++? ????? ?? 
class Foo 
{ 
int variable; 
int DoSomething( int arg1, string arg2 ) { … } 
} 
int Get_variable() { 
void* ret = mono_runtime_invoke( monoClass, monoObject, “get_variable” ); 
return *(int*)ret; 
} 
void Set_variable( int value ) { 
mono_runtime_invoke( monoClass, monoObject, “set_variable”, [&value] ); 
} 
int DoSomething( int arg1, std::string arg2 ) { 
void* ret = mono_runtime_invoke( monoClass, monoObject, “DoSomething”, 
[&arg1, mono_string_new_wrapper(arg2)] ); 
return *(int*)ret; 
} 
};
?? ? ?? ??
?? ? ??? ?? 
?? ? ?? ?? ?? ? ?? ?? ?? ?? 
C++ Class 
C++ variables 
C++ methods 
C# Class 
C# variables 
C# methods 
Hybrid Class 
C++ variables 
C# variables 
C++ methods 
C# methods 
???? ?? 
??? ? ?? 
C++ ?? ?? 
?? ?? 
?? ?? 
C# ?? ?? 
?? ???? ??
?? ?? ?? 
?? ???? ?? ?? 
? C# ??? ???? C++ ???? 
?? ?? ?? ?? 
? ??? ??? C#? ???? ? 
???? ? 
? C++ new/delete ?? ??
?? ?? ?? 
?? ??, ??? ?? 
? ???? C++??? C#?? 
? ??? ??? ???? ?? ? 
? 
? ????? ???? ??? ?? 
(partial class) 
? ?? ????? ??
Garbage Collection vs new/delete 
C++ ??? ??? 
mono_gchandle_new 
mono_gchandle_free 
C# ??? ??? ?? ?? 
new / delete 
gchandle refcount
?? ?? ???? ?? 
// ????? C++? ????? ?? 
class FooProxy 
{ 
FooProxy( Foo* nativeObject ) 
{ // C#?? Foo ??? ??? ?? } 
int DoInCS( int arg ) 
{ // C#?? Foo.DoInCS ?? } 
}; 
// C# ???? 
class Foo : public NativeBound 
{ 
int DoInCS( int arg ) { … } 
} 
// C++ ???? 
class Foo : public MonoBound 
{ 
int DoInCPP( int arg ) 
{ 
return FooProxy(this).DoInCS(arg); 
} 
}; 
?? ??
?? - Garbage Collector ?? 
???? ? GC ??? Native ?? 
GC handle 
3 1 
Mono GC? ? 
? ?? ?? 
Mono GC? ? 
? ?? ?? 
Mono 
GC 
Native 
GC 
0 
Mono GC? ?? 
??? 
??? 
?? ??? 
GC handle ??
?? ?? 
Data Engine 
?? ??? 
??? 
????
?? 
Roslyn 
.NET Native, IL2CPP 
CppSharp, Script# 
?? ?? ????? .NET? C# ?? ?? 
??? ??? ??? → ?? ?? ???? ??? 
.NET? C#? ??? ???
Q&A 
?????
??
???? 
.NET 
– Reflection: http://msdn.microsoft.com/en-us/library/f7ykdhsy(v=vs.110).aspx 
– Garbage Collection: http://msdn.microsoft.com/en-us/library/0xy59wtx(v=vs.110).aspx 
Mono 
– http://www.mono-project.com 
– Compiling Mono: http://www.mono-project.com/docs/compiling-mono/compiling-from-git/ 
– Embedding Mono: http://www.mono-project.com/docs/advanced/embedding/ 
– InterOp with Native: http://www.mono-project.com/docs/advanced/pinvoke/ 
– CppSharp: https://github.com/mono/CppSharp 
– CXXI: http://tirania.org/blog/archive/2011/Dec-19.html 
– Mono for Unreal Engine: http://mono-ue.github.io/ 
Clang 
– http://clang.llvm.org 
– Python with Clang: http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang
iOS ?????? Mono ??? configure 
? --build=i386-apple-darwin13.0.0 
? CC, CXX=<Xcode 
configure 
path>/Contents/Developer/Platforms/iPhoneSimulator.p 
latform/Developer/usr/bin ?? gcc? g++ 
? CFLAGS, CXXFLAGS 
– -arch i386 –miphoneos-version-min=<??????> 
– -isysroot=<Xcode 
path>/Contents/Developer/Platforms/iPhoneSimulator.platform/Deve 
loper/SDKs/iPhoneSimulator<??>.sdk 
? LD, AS, AR, LIBTOOL, STRIP, 
RANLIB=<iPhoneSimulator SDK>/usr/bin ?? ?? ?? 
??
iOS ??? Mono ??? configure 
? --host=arm-apple-darwin10 
? --target=arm-apple-darwin10 
? CC, CXX=<Xcode 
Mono 3.2? ?? XCode 4.x? configure 
???? ? 
path>/Contents/Developer/Toolchains/XcodeDefault.xctoolc 
hain/usr/bin ?? clang? clang++ 
? CFLAGS, CXXFLAGS 
– -arch armv7 
– -isysroot=<Xcode 
path>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SD 
Ks/iPhoneOS???.sdk 
? LD, AS, AR, LIBTOOL, STRIP, RANLIB=<Xcode 
path>/Contents/Developer/Platforms/iPhoneOS.platform/Dev 
eloper/usr/bin ?? ?? ?? ??
Android ??? Mono ??? configure 
? --host=arm-linux-androideabi 
? --target=arm-linux-androideabi 
? CC, CXX=<Xcode 
path>/Contents/Developer/Toolchains/XcodeDefault.xctoolc 
hain/usr/bin ?? clang? clang++ 
? CFLAGS, CXXFLAGS 
– -march=armv7-a 
– -mfloat-abi=softfp 
– -mfpu=neon 
– --sysroot=<NDK_ROOT>/platforms/android-<version>/arch-arm 
? LD, AS, AR, LIBTOOL, STRIP, RANLIB ?? ??? 
? --libdir <NDK_ROOT>/platforms/android-<version>/arch-arm/ 
usr/lib 
configure
C++ → Lua ?? 
// ?? ??? ??? ?? ??? ?? ?? ?? ?? 
RegisterNativeClass<Foo>(); 
// ???? lua table? ?? 
lua_createtable( “Foo” ); 
RegisterNativeClassVariable<Foo,int>( “variable”, offsetof(Foo, variable) ); 
// lua table? getter/setter ?? ??? ?? 
lua_pushcclosure( “Get_variable”, &NativeGetInt ); 
lua_pushcclosure( “Set_variable”, &NativeSetInt ); 
RegisterNativeClassMethod<Foo,int,int,std::string>( “DoSomething”, &Foo::DoSomething ); 
// lua table? ?? ?? ??? ?? 
lua_pushcclosure( “DoSomething”, &Foo_DoSomething ); 
// ?? ??? lua? ????? ?? - ?? ?? Lua Checker ?? ??? ?? ?? 
Foo = { 
Get_variable = function(), 
Set_variable = function( int_value ), 
DoSomething = function( int_arg1, string_arg2 ) 
} 
??? accessor ?? __index, 
__newindex? ?? ??
Lua → C++ ?? 
// lua ???? 
Foo = { 
variable = 0, 
int_DoSomething = function( int_arg1, string_arg2 ) 
… 
end 
// ?? ??? C++? ????? ?? 
} 
class Foo 
{ 
int Get_variable() { return lua_tointeger( “variable” ); } 
void Set_variable( int value ) { lua_pushinteger( “variable”, value ); } 
int DoSomething( int arg1, std::string arg2 ) 
{ 
lua_pushinteger( arg1 ); 
lua_pushstring( arg2 ); 
lua_pcall( “DoSomething” ); 
return lua_tointeger( STACK_TOP ); 
} 
};

More Related Content

What's hot (20)

猫でもわかるUnreal Engine4
猫でもわかるUnreal Engine4猫でもわかるUnreal Engine4
猫でもわかるUnreal Engine4
pafuhana 1213
?
20230207 高雄科技教育輔導團Onshape課程.pdf
20230207 高雄科技教育輔導團Onshape課程.pdf20230207 高雄科技教育輔導團Onshape課程.pdf
20230207 高雄科技教育輔導團Onshape課程.pdf
趙 亨利
?
わからないまま使っている?UE4 の AI の基本的なこと
わからないまま使っている?UE4 の AI の基本的なことわからないまま使っている?UE4 の AI の基本的なこと
わからないまま使っている?UE4 の AI の基本的なこと
rarihoma
?
??????? ???? GPGPU
??????? ???? GPGPU??????? ???? GPGPU
??????? ???? GPGPU
YEONG-CHEON YOU
?
C2 - Langage C - ISIMA 1 - Deuxieme partieC2 - Langage C - ISIMA 1 - Deuxieme partie
C2 - Langage C - ISIMA 1 - Deuxieme partie
Loic Yon
?
Boost.Spirit.QiとLLVM APIで遊ぼう
Boost.Spirit.QiとLLVM APIで遊ぼうBoost.Spirit.QiとLLVM APIで遊ぼう
Boost.Spirit.QiとLLVM APIで遊ぼう
nvsofts
?
C++20 Coroutine
C++20 CoroutineC++20 Coroutine
C++20 Coroutine
?? ?
?
最速C# 7.x
最速C# 7.x最速C# 7.x
最速C# 7.x
Yamamoto Reki
?
コンピュータシステムの理论と実装1
コンピュータシステムの理论と実装1コンピュータシステムの理论と実装1
コンピュータシステムの理论と実装1
H T
?
?? ??? ?? ??? (???, ???? Naver)
?? ??? ?? ??? (???, ???? Naver)?? ??? ?? ??? (???, ???? Naver)
?? ??? ?? ??? (???, ???? Naver)
Seungmo Koo
?
Cholecystite aigue lithiasiqueCholecystite aigue lithiasique
Cholecystite aigue lithiasique
Sarra OUBAHI
?
50分でわかるブループリントについて
50分でわかるブループリントについて50分でわかるブループリントについて
50分でわかるブループリントについて
Masahiko Nakamura
?
[C++ Korea] C++ ??? ??? atomic ?? ???
[C++ Korea] C++ ??? ??? atomic ?? ???[C++ Korea] C++ ??? ??? atomic ?? ???
[C++ Korea] C++ ??? ??? atomic ?? ???
DongMin Choi
?
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
Unity Technologies Japan K.K.
?
猫でも分かる UE4の新しいサンプル「Action RPG」について
猫でも分かる UE4の新しいサンプル「Action RPG」について猫でも分かる UE4の新しいサンプル「Action RPG」について
猫でも分かる UE4の新しいサンプル「Action RPG」について
エピック?ゲームズ?ジャパン Epic Games Japan
?
prc3a9sentation-de-scratch (1).pptprc3a9sentation-de-scratch (1).ppt
prc3a9sentation-de-scratch (1).ppt
PROFPROF11
?
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
DongMin Choi
?
猫でもわかるUnreal Engine4
猫でもわかるUnreal Engine4猫でもわかるUnreal Engine4
猫でもわかるUnreal Engine4
pafuhana 1213
?
20230207 高雄科技教育輔導團Onshape課程.pdf
20230207 高雄科技教育輔導團Onshape課程.pdf20230207 高雄科技教育輔導團Onshape課程.pdf
20230207 高雄科技教育輔導團Onshape課程.pdf
趙 亨利
?
わからないまま使っている?UE4 の AI の基本的なこと
わからないまま使っている?UE4 の AI の基本的なことわからないまま使っている?UE4 の AI の基本的なこと
わからないまま使っている?UE4 の AI の基本的なこと
rarihoma
?
C2 - Langage C - ISIMA 1 - Deuxieme partieC2 - Langage C - ISIMA 1 - Deuxieme partie
C2 - Langage C - ISIMA 1 - Deuxieme partie
Loic Yon
?
Boost.Spirit.QiとLLVM APIで遊ぼう
Boost.Spirit.QiとLLVM APIで遊ぼうBoost.Spirit.QiとLLVM APIで遊ぼう
Boost.Spirit.QiとLLVM APIで遊ぼう
nvsofts
?
C++20 Coroutine
C++20 CoroutineC++20 Coroutine
C++20 Coroutine
?? ?
?
コンピュータシステムの理论と実装1
コンピュータシステムの理论と実装1コンピュータシステムの理论と実装1
コンピュータシステムの理论と実装1
H T
?
?? ??? ?? ??? (???, ???? Naver)
?? ??? ?? ??? (???, ???? Naver)?? ??? ?? ??? (???, ???? Naver)
?? ??? ?? ??? (???, ???? Naver)
Seungmo Koo
?
Cholecystite aigue lithiasiqueCholecystite aigue lithiasique
Cholecystite aigue lithiasique
Sarra OUBAHI
?
50分でわかるブループリントについて
50分でわかるブループリントについて50分でわかるブループリントについて
50分でわかるブループリントについて
Masahiko Nakamura
?
[C++ Korea] C++ ??? ??? atomic ?? ???
[C++ Korea] C++ ??? ??? atomic ?? ???[C++ Korea] C++ ??? ??? atomic ?? ???
[C++ Korea] C++ ??? ??? atomic ?? ???
DongMin Choi
?
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
【Unite Tokyo 2018】さては非同期だなオメー!async/await完全に理解しよう
Unity Technologies Japan K.K.
?
prc3a9sentation-de-scratch (1).pptprc3a9sentation-de-scratch (1).ppt
prc3a9sentation-de-scratch (1).ppt
PROFPROF11
?
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
DongMin Choi
?

Similar to [KGC2014] ? ?? ??? ?? ?? C++ - C# ?? ????? ?? ???? ?? (20)

NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????
NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????
NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????
Jaeseung Ha
?
Google Protocol buffer
Google Protocol bufferGoogle Protocol buffer
Google Protocol buffer
knight1128
?
20201121 ?? ????
20201121 ?? ????20201121 ?? ????
20201121 ?? ????
Chiwon Song
?
[Td 2015]?? c++ ??? ?? c++? ?????(???)
[Td 2015]?? c++ ??? ?? c++? ?????(???)[Td 2015]?? c++ ??? ?? c++? ?????(???)
[Td 2015]?? c++ ??? ?? c++? ?????(???)
Sang Don Kim
?
[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????
[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????
[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????
Chris Ohk
?
kics2013-winter-biomp-slide-20130127-1340
kics2013-winter-biomp-slide-20130127-1340kics2013-winter-biomp-slide-20130127-1340
kics2013-winter-biomp-slide-20130127-1340
Samsung Electronics
?
Hoons ?? ?????
Hoons ?? ?????Hoons ?? ?????
Hoons ?? ?????
?? ?
?
[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli
?? ?
?
[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)
[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)
[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)
Sang Don Kim
?
?? ??? ??? ?? ?? ??? NDC2011
?? ??? ??? ?? ?? ??? NDC2011?? ??? ??? ?? ?? ??? NDC2011
?? ??? ??? ?? ?? ??? NDC2011
Esun Kim
?
Tech Update - The Future of .NET Framework (??? ??)
Tech Update - The Future of .NET Framework (??? ??)Tech Update - The Future of .NET Framework (??? ??)
Tech Update - The Future of .NET Framework (??? ??)
Eunbee Song
?
C#? ??? ?? ? ??
C#? ??? ?? ? ??C#? ??? ?? ? ??
C#? ??? ?? ? ??
?? ?
?
The Future of .NET and C#
The Future of .NET and C#The Future of .NET and C#
The Future of .NET and C#
?? ?
?
C# / .NET Framework? ?? ???? ???? (Basic)
C# / .NET Framework? ?? ???? ???? (Basic)C# / .NET Framework? ?? ???? ???? (Basic)
C# / .NET Framework? ?? ???? ???? (Basic)
Dong Chan Shin
?
Domain Specific Languages With Groovy
Domain Specific Languages With GroovyDomain Specific Languages With Groovy
Domain Specific Languages With Groovy
Tommy C. Kang
?
Effective c++ chapter1 2_dcshin
Effective c++ chapter1 2_dcshinEffective c++ chapter1 2_dcshin
Effective c++ chapter1 2_dcshin
Dong Chan Shin
?
Tech-days ?? ????? - 3? C#? PPT ??
Tech-days ?? ????? - 3? C#? PPT ??Tech-days ?? ????? - 3? C#? PPT ??
Tech-days ?? ????? - 3? C#? PPT ??
SeongTae Jeong
?
Ch09
Ch09Ch09
Ch09
Hankyo
?
????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~
????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~
????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~
YEONG-CHEON YOU
?
NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????
NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????
NDC 2017 ??? NEXON ZERO (?? ??) ???? ????? ?? ?? ? ?? ?? ????
Jaeseung Ha
?
Google Protocol buffer
Google Protocol bufferGoogle Protocol buffer
Google Protocol buffer
knight1128
?
[Td 2015]?? c++ ??? ?? c++? ?????(???)
[Td 2015]?? c++ ??? ?? c++? ?????(???)[Td 2015]?? c++ ??? ?? c++? ?????(???)
[Td 2015]?? c++ ??? ?? c++? ?????(???)
Sang Don Kim
?
[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????
[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????
[TechDays Korea 2015] ?? C++ ??? ?? C++? ?????
Chris Ohk
?
kics2013-winter-biomp-slide-20130127-1340
kics2013-winter-biomp-slide-20130127-1340kics2013-winter-biomp-slide-20130127-1340
kics2013-winter-biomp-slide-20130127-1340
Samsung Electronics
?
Hoons ?? ?????
Hoons ?? ?????Hoons ?? ?????
Hoons ?? ?????
?? ?
?
[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli
?? ?
?
[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)
[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)
[Td 2015]windows, linux, mac ?? ? ??. .net 2015? ?? ???? c# ?? ????(???)
Sang Don Kim
?
?? ??? ??? ?? ?? ??? NDC2011
?? ??? ??? ?? ?? ??? NDC2011?? ??? ??? ?? ?? ??? NDC2011
?? ??? ??? ?? ?? ??? NDC2011
Esun Kim
?
Tech Update - The Future of .NET Framework (??? ??)
Tech Update - The Future of .NET Framework (??? ??)Tech Update - The Future of .NET Framework (??? ??)
Tech Update - The Future of .NET Framework (??? ??)
Eunbee Song
?
C#? ??? ?? ? ??
C#? ??? ?? ? ??C#? ??? ?? ? ??
C#? ??? ?? ? ??
?? ?
?
The Future of .NET and C#
The Future of .NET and C#The Future of .NET and C#
The Future of .NET and C#
?? ?
?
C# / .NET Framework? ?? ???? ???? (Basic)
C# / .NET Framework? ?? ???? ???? (Basic)C# / .NET Framework? ?? ???? ???? (Basic)
C# / .NET Framework? ?? ???? ???? (Basic)
Dong Chan Shin
?
Domain Specific Languages With Groovy
Domain Specific Languages With GroovyDomain Specific Languages With Groovy
Domain Specific Languages With Groovy
Tommy C. Kang
?
Effective c++ chapter1 2_dcshin
Effective c++ chapter1 2_dcshinEffective c++ chapter1 2_dcshin
Effective c++ chapter1 2_dcshin
Dong Chan Shin
?
Tech-days ?? ????? - 3? C#? PPT ??
Tech-days ?? ????? - 3? C#? PPT ??Tech-days ?? ????? - 3? C#? PPT ??
Tech-days ?? ????? - 3? C#? PPT ??
SeongTae Jeong
?
????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~
????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~
????? ??? F1?? C++? ?? Windows 10 UWP ? ??? ???~
YEONG-CHEON YOU
?

[KGC2014] ? ?? ??? ?? ?? C++ - C# ?? ????? ?? ???? ??

  • 1. ? ?? ??? ?? ?? C++ - C# ?? ????? ?? ???? ?? ?????? Technical Director ???
  • 2. ?? 1. ?? 2. C# (.NET) ???? 3. ?? ? ????? ?? ??? 4. ?? ? ?? ?? 5. ?? 6. ??
  • 5. ?? ? ?? ?? ? ??? ??? ? ?? ??? ? ??? ??? ??? ? ?? ??? ? ?? ??? (??, OOP …) ? ??? ?? ? C++? ??? ?? ? ??? ?? ??? ? ?? ??? ?? ???
  • 7. ?? ??? ?? ??? ?? ??? ??? ??? ?? ??? ??? ?? ? ??? ??? ?? ? ??? ?? ? ?? ????? ?? ? ?? ??? ?? ??? ? ?? ?? ??? ??? ? ??? ???? ?? ??
  • 10. ?? ?? C# ??? ?? ? ???? ? ??? ?? ? ?? ??
  • 12. Mono? = Microsoft .NET? ?? ≈ ????, ?? ??
  • 13. ? ???? Mono ?? ???? mono Runtime (.a .so .lib .dll) make make configure Compiler
  • 14. App Embedded Mono Native Runtime .NET Assembly ?? & JIT ??? ? ? ? JIT / AOT Binary Mono Runtime ?? .NET Compiler Objective-C Runtime Java VM
  • 15. ???? ?? C# ?? ?? .NET Compiler monolinker mono Reduced Assembly .NET Assembly Stripped Assembly mov … push … call … Assembly Code .NET Libraries AOT ???
  • 16. Embedded Mono ???? Ahead-of-Time ??? – Just-in-Time ??? ???? ?? OS? ?? – ??? CPU/OS ?? ??? Mono ????? ??? ?? – ???? ?? ?? – ??? ????? C# ?? ???? ??? ??? – Custom Command Soft Debugger ?? ?? – ??? ??? client, MonoDevelop? server? ?? – ????? Mono ??? ???? ??? ??? ?? ?? sgen GC ??? MonoObject* ?? gc_handle ? ?? mono_trace_set_level_string ?? ??
  • 17. ?? ? ????? ?? ???
  • 18. ??: ??? ??? ??? class Character { void SetPosition( float ); float position; }; class Character { void Touched() … void UpdateUI() … int health; }
  • 19. ??: ??? ??? ??? void Character::Touched() { SetPosition( position + 1 ); } class Character { void SetPosition( float ); float position; };
  • 20. ??: ??? ??? ??? void Character::SetPosition( float position ) { … health = … UpdateUI(); } class Character { void Touched() … void UpdateUI() … int health; }
  • 21. ??: ??? ??? ??? ? ??? ??? ?? ??? ???? ?? ? C# ??? C++ ??, C++ ??? C# ?? ?? ? ?????? ?? ?? – ? ??? ?? ???? ?? ?? – ?? ??? ?? ??? ??(declaration) ?? ? ?? ? ?????? ??? ????!
  • 22. ??? ????? ???? C++ ? ??? (.h) C# ?? ?? C++ ? ???? C# ?? C# ?? ??? C++ ? ? 2 3 4 1 CppSharp CXXI …
  • 23. C#? ?? C++ ????? ???? CppSharp CXXI + Clang 1. C++ ?????? ??(!)?? ?????? ?? 2. (C++ ?????? Mono? ???? C++ ??)? ?? ??? ? ?? C# ?? ?? 3. C# ???? ????? ??? ?? 4. C# ?? ???? ????? ??? ?? ???
  • 24. C++ ?? - Clang ? LLVM ????? C/C++ ?? ? ?? ?? ?? ? Visual C++ ???? ?? ? ???? ??? ?? ??? ???? ?? ? libclang? ???? ???? ????? ?? ??, Python ?? ?? ?? – AST ?? ? libclang? clang? ?? ??? ???? ???? ? ???????? ??
  • 25. C++ ????? ?? ?? (CppSharp) // C++ ???? class Foo { int variable; int DoSomething ( int arg1, std::string arg2 ); }; // ?? ??? C#? ????? ?? class Foo { // C++? ??? ???? ?? struct Internal { … } // ???? ?? ??? ????? int variable { get { return _Instance.ToPointer()->variable; } set { _Instance.ToPointer()->variable = value; } } int DoSomething( int arg1, string arg2 ) { return Internal.DoSomething( _Instance, arg1, arg2 ); } }
  • 26. C++ ????? ?? ?? (Embedded) // C++ ???? #define EXPORT __attribute__((annotate(“ExportToMono”))) class EXPORT Foo { int variable; int DoSomething ( int arg1, std::string arg2 ); }; + Clang // ?? ??? ??? ?? ?? RegisterNativeClass<Foo>(); RegisterNativeClassVariable<Foo,int>( “variable”, offsetof(Foo, variable) ); RegisterNativeClassMethod<Foo,int,int,std::string>( “DoSomething”, &Foo::DoSomething );
  • 27. C++ ????? ?? ?? (Embedded) // ?? ??? ??? ?? ??? ?? ?? ?? ?? RegisterNativeClass<Foo>(); // Foo ??? ?? RTTI? ?? ?? ??? ?? RegisterNativeClassVariable<Foo,int>( “variable”, offsetof(Foo, variable) ); // C#?? ??? accessor ??? ?? int NativeGetInt( void* nativeObject, int offset ); mono_add_internal_call( “NativeGetInt”, &NativeGetInt ); void NativeSetInt( void* nativeObject, int offset, int value ); mono_add_internal_call( “NativeSetInt”, &NativeSetInt ); RegisterNativeClassMethod<Foo,int,int,std::string>( “DoSomething”, &Foo::DoSomething ); // C#?? ??? ??? ?? static int Foo_DoSomething( Foo* nativeObject, int arg1, std::string arg2 ) { nativeObject->DoSomething( arg1, arg2 ); } mono_add_internal_call( “Foo.NativeCall_DoSomething”, &Foo_DoSomething );
  • 28. C++ ????? ?? ?? (Embedded) // ?? ??? C#? ????? ?? class Foo { // C++? ???? ?? [MethodImplAttribute(MethodImplOptions.InternalCall)] extern int NativeCall_DoSomething( IntPtr nativeObject, int arg1, string arg2 ); // ???? ?? ??? ????? int variable { get { return NativeGetInt( nativeObject, 4 ); } set { NativeSetInt( nativeObject, 4 ); } } int DoSomething( int arg1, string arg2 ) { return NativeCall_DoSomething( nativeObject, arg1, arg2 ); } }
  • 29. C++? ?? C# ????? ???? 1. .NET reflection? ???? DLL ?? ????? ? ?? 2. DLL ?????? ??? ? ?? C++ ?? ?? 3. C++ ?????? ????? ??? ?? DLL? ??? C++ ?? ?? 4. C++ ???? ???? ????? ??? ?? ???
  • 30. C# ????? ?? ?? (Delegate) // ?? ??? C# ????? ?? partial class Foo { void ExposeToNative() { RegisterMonoMethod( 0, () => { return variable; } ); // Get_variable RegisterMonoMethod( 1, (int value) => { variable = value; } ); // Set_variable RegisterMonoMethod( 2, DoSomething ); // DoSomething } } // ?? ??? C++ ????? ?? class Foo { int Get_variable() { monoMethods[0](); } void Set_variable( int value ) { return monoMethods[1]( value ); } int DoSomething( int arg1, std::string arg2 ) { return monoMethods[2]( arg1, arg2 ); } }; delegate? native ?? ???? ?? RegisterMonoMethod? ?? ??? ?? ???
  • 31. C# ????? ?? ?? (Embedded) // C# ???? [Export] class Foo { // ?? ??? C++? ????? ?? class Foo { int variable; int DoSomething( int arg1, string arg2 ) { … } } int Get_variable() { void* ret = mono_runtime_invoke( monoClass, monoObject, “get_variable” ); return *(int*)ret; } void Set_variable( int value ) { mono_runtime_invoke( monoClass, monoObject, “set_variable”, [&value] ); } int DoSomething( int arg1, std::string arg2 ) { void* ret = mono_runtime_invoke( monoClass, monoObject, “DoSomething”, [&arg1, mono_string_new_wrapper(arg2)] ); return *(int*)ret; } };
  • 32. ?? ? ?? ??
  • 33. ?? ? ??? ?? ?? ? ?? ?? ?? ? ?? ?? ?? ?? C++ Class C++ variables C++ methods C# Class C# variables C# methods Hybrid Class C++ variables C# variables C++ methods C# methods ???? ?? ??? ? ?? C++ ?? ?? ?? ?? ?? ?? C# ?? ?? ?? ???? ??
  • 34. ?? ?? ?? ?? ???? ?? ?? ? C# ??? ???? C++ ???? ?? ?? ?? ?? ? ??? ??? C#? ???? ? ???? ? ? C++ new/delete ?? ??
  • 35. ?? ?? ?? ?? ??, ??? ?? ? ???? C++??? C#?? ? ??? ??? ???? ?? ? ? ? ????? ???? ??? ?? (partial class) ? ?? ????? ??
  • 36. Garbage Collection vs new/delete C++ ??? ??? mono_gchandle_new mono_gchandle_free C# ??? ??? ?? ?? new / delete gchandle refcount
  • 37. ?? ?? ???? ?? // ????? C++? ????? ?? class FooProxy { FooProxy( Foo* nativeObject ) { // C#?? Foo ??? ??? ?? } int DoInCS( int arg ) { // C#?? Foo.DoInCS ?? } }; // C# ???? class Foo : public NativeBound { int DoInCS( int arg ) { … } } // C++ ???? class Foo : public MonoBound { int DoInCPP( int arg ) { return FooProxy(this).DoInCS(arg); } }; ?? ??
  • 38. ?? - Garbage Collector ?? ???? ? GC ??? Native ?? GC handle 3 1 Mono GC? ? ? ?? ?? Mono GC? ? ? ?? ?? Mono GC Native GC 0 Mono GC? ?? ??? ??? ?? ??? GC handle ??
  • 39. ?? ?? Data Engine ?? ??? ??? ????
  • 40. ?? Roslyn .NET Native, IL2CPP CppSharp, Script# ?? ?? ????? .NET? C# ?? ?? ??? ??? ??? → ?? ?? ???? ??? .NET? C#? ??? ???
  • 42. ??
  • 43. ???? .NET – Reflection: http://msdn.microsoft.com/en-us/library/f7ykdhsy(v=vs.110).aspx – Garbage Collection: http://msdn.microsoft.com/en-us/library/0xy59wtx(v=vs.110).aspx Mono – http://www.mono-project.com – Compiling Mono: http://www.mono-project.com/docs/compiling-mono/compiling-from-git/ – Embedding Mono: http://www.mono-project.com/docs/advanced/embedding/ – InterOp with Native: http://www.mono-project.com/docs/advanced/pinvoke/ – CppSharp: https://github.com/mono/CppSharp – CXXI: http://tirania.org/blog/archive/2011/Dec-19.html – Mono for Unreal Engine: http://mono-ue.github.io/ Clang – http://clang.llvm.org – Python with Clang: http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang
  • 44. iOS ?????? Mono ??? configure ? --build=i386-apple-darwin13.0.0 ? CC, CXX=<Xcode configure path>/Contents/Developer/Platforms/iPhoneSimulator.p latform/Developer/usr/bin ?? gcc? g++ ? CFLAGS, CXXFLAGS – -arch i386 –miphoneos-version-min=<??????> – -isysroot=<Xcode path>/Contents/Developer/Platforms/iPhoneSimulator.platform/Deve loper/SDKs/iPhoneSimulator<??>.sdk ? LD, AS, AR, LIBTOOL, STRIP, RANLIB=<iPhoneSimulator SDK>/usr/bin ?? ?? ?? ??
  • 45. iOS ??? Mono ??? configure ? --host=arm-apple-darwin10 ? --target=arm-apple-darwin10 ? CC, CXX=<Xcode Mono 3.2? ?? XCode 4.x? configure ???? ? path>/Contents/Developer/Toolchains/XcodeDefault.xctoolc hain/usr/bin ?? clang? clang++ ? CFLAGS, CXXFLAGS – -arch armv7 – -isysroot=<Xcode path>/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SD Ks/iPhoneOS???.sdk ? LD, AS, AR, LIBTOOL, STRIP, RANLIB=<Xcode path>/Contents/Developer/Platforms/iPhoneOS.platform/Dev eloper/usr/bin ?? ?? ?? ??
  • 46. Android ??? Mono ??? configure ? --host=arm-linux-androideabi ? --target=arm-linux-androideabi ? CC, CXX=<Xcode path>/Contents/Developer/Toolchains/XcodeDefault.xctoolc hain/usr/bin ?? clang? clang++ ? CFLAGS, CXXFLAGS – -march=armv7-a – -mfloat-abi=softfp – -mfpu=neon – --sysroot=<NDK_ROOT>/platforms/android-<version>/arch-arm ? LD, AS, AR, LIBTOOL, STRIP, RANLIB ?? ??? ? --libdir <NDK_ROOT>/platforms/android-<version>/arch-arm/ usr/lib configure
  • 47. C++ → Lua ?? // ?? ??? ??? ?? ??? ?? ?? ?? ?? RegisterNativeClass<Foo>(); // ???? lua table? ?? lua_createtable( “Foo” ); RegisterNativeClassVariable<Foo,int>( “variable”, offsetof(Foo, variable) ); // lua table? getter/setter ?? ??? ?? lua_pushcclosure( “Get_variable”, &NativeGetInt ); lua_pushcclosure( “Set_variable”, &NativeSetInt ); RegisterNativeClassMethod<Foo,int,int,std::string>( “DoSomething”, &Foo::DoSomething ); // lua table? ?? ?? ??? ?? lua_pushcclosure( “DoSomething”, &Foo_DoSomething ); // ?? ??? lua? ????? ?? - ?? ?? Lua Checker ?? ??? ?? ?? Foo = { Get_variable = function(), Set_variable = function( int_value ), DoSomething = function( int_arg1, string_arg2 ) } ??? accessor ?? __index, __newindex? ?? ??
  • 48. Lua → C++ ?? // lua ???? Foo = { variable = 0, int_DoSomething = function( int_arg1, string_arg2 ) … end // ?? ??? C++? ????? ?? } class Foo { int Get_variable() { return lua_tointeger( “variable” ); } void Set_variable( int value ) { lua_pushinteger( “variable”, value ); } int DoSomething( int arg1, std::string arg2 ) { lua_pushinteger( arg1 ); lua_pushstring( arg2 ); lua_pcall( “DoSomething” ); return lua_tointeger( STACK_TOP ); } };