ÆĽºÄ® ¾ð¾î¿¡¼ °¢±âÀÇ À¯´ÖÀº ´ÙÀ½°ú °°ÀÌ initialization°ú finalization ¼½¼ÇÀ» °¡Áú ¼ö ÀÖ´Ù.
unit Unit1;
interface
implementation
var o: TObject;
initialization o := TObject.Create;
finalization o.Destroy; end.
°¢°¢ÀÇ À¯´Ö¿¡ Á¤ÀǵǾî ÀÖ´Â initialization°ú finalization ¼½¼ÇÀÇ ÄÚµå´Â Çѹø¾¿¸¸ ½ÇÇàµÈ´Ù. ÇÁ·Î±×·¥ ½ÃÀÛÇÒ ¶§ initialization ¼½¼Ç ÄÚµå ½ÇÇà. Á¾·á Àü¿¡ finalization ¼½¼Ç ÄÚµå ½ÇÇà.
½ÇÇàÆÄÀÏÀÌ ¸¸µé¾îÁú ¶§ ÇÁ·ÎÁ§Æ®¿¡ Æ÷ÇÔµÈ À¯´ÖµéÀÇ initialization°ú finalization ¼½¼ÇÀÇ Äڵ尡 One timeÀ¸·Î Çѹø¸¸ ½ÇÇàµÉ ¼ö ÀÖµµ·Ï ÇϱâÀ§ÇØ ÄÄÆÄÀÏ·¯°¡ ½ÇÇà ÆÄÀÏ ¹ÙÀ̳ʸ®¿¡ Unit Table ÀڷᱸÁ¶¸¦ »ý¼ºÇÏ°í »ç¿ëµÇ´Â À¯´ÖµéÀÇ initialization°ú finalization ¿£Æ®¸® ÁÖ¼ÒµéÀÌ ¿©±â¿¡ µé¾î °£´Ù. ±×¸®°í ÄÄÆÄÀÏ·¯¿¡ ÀÇÇؼ »ý¼ºµÈ Unit TableÀÇ initialization°ú finalization ¿£Æ®¸® ÁÖ¼Ò´Â À¯´Ö Å×ÀÌºí¿¡ ±â·ÏµÇ¾î ÀÖ´Â ¼ø¼´ë·Î RTLÀÇ ½ºÅ¸Æ® ¾÷ Äڵ忡 ÀÇÇؼ One timeÀ¸·Î ½ÇÇàµÈ´Ù. À¯´Ö¿¡¼ initialization ¶Ç´Â finalization ¼½¼ÇÀÌ Á¤ÀǵǾî ÀÖÁö ¾ÊÀ¸¸é ÇØ´ç ¿£Æ®¸®¿£ 0 °ªÀÌ ÄÄÆÄÀÏ·¯¿¡ ÀÇÇؼ ±â·ÏµÈ´Ù.
¹ÙÀ̳ʸ®¿¡¼ Unit TableÀ» ºÐ¼®ÇÏ¸é »ç¿ëµÇ´Â À¯´ÖÀÇ °¹¼ö, °¢±â À¯´ÖµéÀÇ initialization°ú finalization ¿£Æ®¸® ÁÖ¼Òµµ ¾Ë¾Æ³¾ ¼ö ÀÖ´Ù.
;; ÄÄÆÄÀÏµÈ ÇÁ·Î±×·¥ ¹ÙÀ̳ʸ®ÀÇ Unit TableÀÇ ÇÑ ºÎºÐ...
CODE:0045A218 30 B3 44 00 dd offset @Menus@initialization$qqrv ; Menus::initialization(void) CODE:0045A21C C0 B2 44 00 dd offset @Menus@Finalization$qqrv ; Menus::Finalization(void)
±×·¯³ª ÆÐÅ°ÁöÀÏ °æ¿ì¿¡´Â ´ÙÀ½°ú °°Àº ¹®Á¦°¡ ¹ß»ýÇÑ´Ù.
ÆÐÅ°Áö A¿Í B °¡ ÀÖ´Ù°í ÇØ º¸ÀÚ.
ÆÐÅ°Áö A¿Í B°¡ Contains¿¡ °°Àº À̸§ÀÇ Unit1À» Æ÷ÇÔÇÏ°í ÀÖÀ¸¸é ÄÄÆÄÀÏÀº ¼º°øÀûÀ¸·Î µÇ¾îµµ IDE ¿¡¼ ÆÐÅ°Áö A¸¦ Install ÇÑ ÈÄ¿¡, ÀÌ¾î¼ ÆÐÅ°Áö B¸¦ Install ÇÏ·Á°í ÇÏ¸é °°Àº À̸§ÀÇ À¯´ÖÀÌ Á¸ÀçÇÑ´Ù¸é¼ ¿¡·¯¸¦ ¹ß»ý½ÃŲ´Ù.
¿Ö ÀÌ·± Çö»óÀÌ ÀϾ±î?
¸¸¾à IDE°¡ ¿¡·¯¸¦ ¹ß»ý½ÃÅ°Áö ¾Ê°í Çã¿ëÀ» ÇÏ°ÔµÇ¸é ½É°¢ÇÑ ¹®Á¦°¡ ÀϾ±â ¶§¹®ÀÌ´Ù.
¾î¶² ¹®Á¦³Ä¸é ÆÐÅ°Áö A°¡ ·ÎµåµÉ ¶§ Unit1ÀÇ Initialization Äڵ尡 È£ÃâµÇ°í ÆÐÅ°Áö B°¡ ·ÎµåµÉ ¶§µµ °°Àº Unit1ÀÇ Initialization Äڵ尡 Áߺ¹ È£Ãâ.
Unit1ÀÇ Initialization Äڵ尡 One timeÀ¸·Î Çѹø¸¸ È£ÃâµÇ¾î¾ß Çϴµ¥ Áߺ¹Çؼ ½ÇÇàµÇ´Â ¹®Á¦°¡ ¹ß»ý.
¸¸¾à ÆÐÅ°Áö B¿¡¼ Unit1À» Contains ÇÏÁö ¾Ê°í, Unit1À» »ç¿ëÇÏ´Â(Contains) ÆÐÅ°Áö A¸¦ Requires·Î Æ÷ÇÔÇß´Ù¸é ±×¶§´Â ¹®Á¦°¡ ¹ß»ýÇÏÁö ¾Ê´Â´Ù.
Unit1ÀÇ Initialization ¼½¼ÇÀº ÆÐÅ°Áö A¿¡¼ Çѹø¸¸ ½ÇÇàµÇ±â ¶§¹®ÀÌ´Ù. ÆÐÅ°Áö´Â ±âÁ¸ÀÇ DLL ±¸Á¶¿¡ Package Info Table ÀÌ Ãß°¡µÇ¾î ÀÖ´Â ±¸Á¶¶ó¼ ÆÐÅ°Áö°¡ Áߺ¹ »ç¿ëµÇ´õ¶óµµ DLL Reference Ä«¿îÆ®¸¸ Áõ°¡µÇ°í ¸Þ¸ð¸®¿¡ Áߺ¹ÀûÀç µÇÁö¾Ê°í Initialization µµ Çѹø¸¸ ½ÇÇà µÊ.
µ¨ÆÄÀÌ´Â °°Àº À¯´ÖÀÇ Initialization ¼½¼ÇÀÌ Áߺ¹ ½ÇÇàµÇÁö ¸øÇϵµ·Ï ¸·±âÀ§ÇØ ±âÁ¸ÀÇ DLL ±¸Á¶ À§¿¡ »ç¿ëµÇ´Â À¯´ÖµéÀÇ ¸í¼¼°¡ Æ÷ÇԵǵµ·Ï ÆÐÅ°Áö¶õ Çü½ÄÀ» ¸¸µé¾î¼ »ç¿ëÇÏ°í ÀÖ´Ù. IDE¿¡ ÄÄÆ÷³ÍÆ®°¡ ¸¹ÀÌ ¼³Ä¡µÇ¾î ÀÖÀ» ¼ö·Ï IDE°¡ ó¸®ÇØ¾ß ÇÒ À¯´ÖµéÀÇ ¸í¼¼Á¤º¸µµ ´õ Ä¿Áö°Ô µÈ´Ù. ÆÐÅ°Áö¿¡ Æ÷ÇÔµÈ À¯´ÖµéÀÇ ¸í¼¼¸¦ ÀÌ¿ëÇؼ °°Àº À̸§ÀÇ À¯´ÖÀÌ »ç¿ëµÇÁö ¸øÇϵµ·Ï ¸·À½.
µ¨ÆÄÀÌ ÆĽºÄ® ¾ð¾î°¡ Initialization°ú FinalizationÀÇ Á¾¼ÓÀûÀÎ ±¸Á¶Á¦ÇÑÀ» °¡Áú ¼ö ¹Û¿¡ ¾ø´Â °ÍÀº ÆĽºÄ®Àº C++°ú ´Þ¸® Ŭ·¡½º ½º½º·Î constructor¸¦ È£ÃâÇؼ °´Ã¼¸¦ »ý¼ºÇÏ´Â ±â´ÉÀÌ ¾ø±â ¶§¹®ÀÌ´Ù.
CClassA a; // C++¿¡¼± Ŭ·¡½º ½º½º·Î »ý¼ºÀÚ¸¦ È£ÃâÇÏ¸é¼ ÀνºÅϽº°¡ È°¼ºÈ µÉ ¼ö ÀÖÁö¸¸
ÆĽºÄ®¿¡¼± ¸í½ÃÀûÀ¸·Î »ý¼ºÀÚ(Create)¸¦ È£ÃâÇؼ ¹«Á¶°Ç Èü¿¡ ¸Þ¸ð¸®¸¦ ÇÒ´çÇؼ ÀνºÅϽº°¡ ÇÒ´çµÇ¾î¾ß¸¸ ÇÔ.
ÄÄÆÄÀÏµÈ ¹ÙÀ̳ʸ®¿¡¼ Package Info Å×À̺íÀ» ºÐ¼®Çϸé ContainsµÈ À¯´Öµé°ú Requires·Î ÂüÁ¶µÇ´Â dcp ÆÄÀϵéÀÇ ¸ñ·Ïµµ ¾Ë¾Æ³¾ ¼ö ÀÖ´Ù. µ¨ÆÄÀÌ¿¡¼ dcp ÆÄÀÏÀº C++·Î ºñ±³Çϸé import ¶óÀ̺귯¸® ¿ªÇÒÀ» Çϱ⵵ ÇÏ°í, ÂüÁ¶µÇ´Â ÆÐÅ°ÁöÀÇ ÀÎÅͳΠTypeInfo¸¦ IDE¿¡ Á¦°øÇÏ´Â ¿ªÇÒÀ» Çϱ⵵ ÇÑ´Ù.
¼Ò½ºÄÚµå ¾øÀÌ ÆÐÅ°Áö ÆÄÀÏ°ú dcp ÆÄÀϸ¸ ¹èÆ÷µÇ´õ¶óµµ dcp ÆÄÀÏÀ» ÀÌ¿ëÇؼ ¿ªÀ¸·Î ÆÐÅ°Áö ÆÄÀÏÀ» ºÐ¼®ÇØ ³¾ ¼öµµ ÀÖ´Ù. dcp ´Â ÄÄÆÄÀÏµÈ dcu ÆÄÀϵéÀ» dcp Çì´õ¸¦ ºÙ¿©¼ Æ÷ÇÔÇÏ°í ÀÖ´Â ±¸Á¶À̹ǷÎ.
Object Inspector¿¡¼ÀÇ Reflection°ú Data Runtime BindingÀ» Áö¿øÇϱâ À§ÇØ µ¨ÆÄÀÌ ÄÄÆÄÀÏ·¯´Â ÇÊ¿¬ÀûÀ¸·Î ¸¹Àº ¾çÀÇ µðÅ×ÀÏÇÑ Extended RTTI Á¤º¸¸¦ »ý¼ºÇÒ ¼ö ¹Û¿¡ ¾ø´Ù. ÄÄÆÄÀÏ·¯¿¡ ÀÇÇØ ¹«Áö¸·ÁöÇÏ°Ô »ý¼ºµÇ´Â Extended RTTI ³»ºÎ±¸Á¶¸¦ ÀÌ¿ëÇؼ ¼Ò½º¿¡ ±ÙÁ¢ÇÏ´Â ¼öÁØÀ¸·ÎÀÇ ¸®¹ö½º ¿£Áö´Ï¾î¸µµµ °¡´ÉÇÏ´Ù.
Ŭ·¡½ºµéÀÇ ³×ÀÓ, Æз±Æ® Ŭ·¡½º, ÇÁ·ÎÆÛƼ, À̺¥Æ® Çڵ鷯, Ŭ·¡½º µ¥ÀÌŸ ¸â¹ö ¹× ÇÔ¼ö, set µîÀÇ element ÇÊµå µîÀÇ ±¸Ã¼ÀûÀÌ°í µðÅ×ÀÏÇÑ Extended RTTI Á¤º¸°¡ »ý¼ºµÇ±â ¶§¹®ÀÌ´Ù.
gcc °°Àº C++ ÄÄÆÄÀÏ·¯µµ RTTI Á¤º¸¸¦ »ý¼ºÇϱ⵵ ÇÏÁö¸¸ ¼Ò½ºÄڵ忡¼ ¸í½ÃÀûÀ¸·Î typeid¸¦ ¿ä±¸ÇÒ ¶§¸¸ ±× ºÎºÐ¿¡ ÇÑÁ¤µÇ¾î »ý¼ºµÇ°í, »ý¼ºµÇ´Â Á¤º¸µµ type name ¹Û¿¡ ¾ø¾î¼ µð¹ö±ë Á¤º¸°¡ ¾øÀ¸¸é »ç½Ç»ó ¼Ò½º ¼öÁØÀ¸·ÎÀÇ ¸®¹ö½º ¿£Áö´Ï¾î¸µÀÌ C++·Î ÄÄÆÄÀÏµÈ ¹ÙÀ̳ʸ®¿¡¼´Â ºÒ°¡´É ÇÏ´Ù.
µ¨ÆÄÀÌ ¹öÀüÀÌ ¿Ã¶ó°¥ ¼ö·Ï ´ã¾ßÇÒ Á¤º¸°¡ ¸¹¾ÆÁ®¼ Extended RTTI µ¥ÀÌŸ´Â ´õ Ä¿Áö°í, ½ÇÇàÆÄÀÏÀÇ Å©±â°¡ Ä¿Áöµµ·Ï ÇÏ´Â ¿äÀÎÀÌ µÇ±âµµ ÇÑ´Ù.
ÀÌ·± ±¸Á¶´Â ÇØÅ·¿¡ Ãë¾àÇÑ µ¨ÆÄÀÌÀÇ ¸ÍÁ¡À̱⵵ ÇÏ´Ù.
;; ÇØÅ·¿¡ Ãë¾àÇÑ µ¨ÆÄÀÌ Extended RTTI ³»ºÎ±¸Á¶ÀÇ ÇÑ ºÎºÐ...
CODE:0044C101 05 54 46 6F 72 6D db 5,'TForm' CODE:0044C107 00 C0 44 00 dd offset _cls_Forms_TForm CODE:0044C10B 90 BF 44 00 dd offset off_44BF90 CODE:0044C10F 5E 00 dw 94 CODE:0044C111 05 46 6F 72 6D 73 db 5,'Forms' CODE:0044C117 55 00 dw 85 ; PropCount CODE:0044C119 D4 35 41 00 3C 00 00 FE 54 0D+ dd offset off_4135D4 ; PropType CODE:0044C119 43 00 01 00 00 00 00 00 00 80+ dd 0FE00003Ch ; GetProc CODE:0044C119 00 00 00 80 0D 00 06 41 63 74+ dd offset sub_430D54 ; SetProc CODE:0044C119 69 6F 6E dd 1 ; StoredProc CODE:0044C119 dd 80000000h ; Index CODE:0044C119 dd 80000000h ; Default CODE:0044C119 dw 0Dh ; NameIndex CODE:0044C119 db 6,'Action' ; Name CODE:0044C13A 3C D9 42 00 20 02 00 FF 78 22+ dd offset off_42D93C ; PropType CODE:0044C13A 45 00 1C 11 45 00 00 00 00 80+ dd 0FF000220h ; GetProc CODE:0044C13A 00 00 00 80 0E 00 0D 41 63 74+ dd offset sub_452278 ; SetProc CODE:0044C13A 69 76 65 43 6F 6E 74 72 6F 6C dd offset sub_45111C ; StoredProc CODE:0044C13A dd 80000000h ; Index CODE:0044C13A dd 80000000h ; Default CODE:0044C13A dw 0Eh ; NameIndex CODE:0044C13A db 13,'ActiveControl' ; Name CODE:0044C162 88 C0 42 00 5B 00 00 FF 98 0F+ dd offset off_42C088 ; PropType CODE:0044C162 43 00 01 00 00 00 00 00 00 80+ dd 0FF00005Bh ; GetProc CODE:0044C162 00 00 00 00 0F 00 05 41 6C 69+ dd offset sub_430F98 ; SetProc CODE:0044C162 67 6E dd 1 ; StoredProc CODE:0044C162 dd 80000000h ; Index CODE:0044C162 dd 0 ; Default CODE:0044C162 dw 0Fh ; NameIndex CODE:0044C162 db 5,'Align' ; Name CODE:0044C182 00 10 40 00 E0 02 00 FF 7C 4E+ dd offset off_401000 ; PropType CODE:0044C182 45 00 01 00 00 00 00 00 00 80+ dd 0FF0002E0h ; GetProc CODE:0044C182 00 00 00 00 10 00 0A 41 6C 70+ dd offset sub_454E7C ; SetProc CODE:0044C182 68 61 42 6C 65 6E 64 dd 1 ; StoredProc
Initialization°ú Finalization ¼½¼ÇÀ» Á¤ÀÇÇÒÁö ¾ÈÇÒÁö´Â »ç¿ëÀÚ ¸¶À½´ë·Î À̹ǷΠ¾ÈÀüÀåÄ¡·Î °°Àº À̸§ÀÇ À¯´ÖÀÌ »ç¿ëµÇÁö(Contains) ¸øÇϵµ·Ï ÇÏ´Â °ÍÀÓ. ÆĽºÄ® ¾ð¾î°¡ °®°íÀÖ´Â ±¸Á¶ÀûÀÎ ¹®Á¦¸¦ ÇÇÇØ°¡±â À§ÇÑ ÀÏÁ¾ÀÇ Æí¹ý.
Áú¹®¶õ¿¡ ¿Ã¶ó¿Â ´ÙÀ½ ±ÛÀÇ ÇØ°á ¹æ¹ý.
https://www.delmadang.com/community/bbs_view.asp?bbsNo=17&bbsCat=0&indx=455962&page=1
IDE¿¡¼ ±âº» ¼³Á¤À¸·Î »ý¼ºµÇ´Â ÆÐÅ°Áö ÇÁ·ÎÁ§Æ®´Â µðÆúÆ®·Î ÆÐÅ°Áö ¼Ó¼ºÀÌ 'Designtime and runtime' ¼Ó¼ºÀ¸·Î »ý¼ºµÈ´Ù.
Designtime ¼Ó¼ºÀ» °®°í Àֱ⠶§¹®¿¡ IDE¿¡¼ InstallÀÌ °¡´ÉÇÑ °ÍÀÌ´Ù.
ÆÐÅ°Áö ÇÁ·ÎÁ§Æ® ¿É¼Ç¿¡¼ Description --> Usage options ¿¡¼ ÆÐÅ°Áö ¼Ó¼ºÀ» Runtime only ·Î ¹Ù²Ù¾î¼ »ç¿ëÇÏ¸é µÈ´Ù.
Runtime ÆÐÅ°Áö´Â Designtime ÆÐÅ°Áö¿Í ´Þ¸® IDE ¾îµå·¹½º °ø°£¿¡ ¸ÅÇÎ(Install)µÇÁö ¾Ê°í ÄÄÆÄÀϸ¸ Çؼ »ç¿ëÇÏ¸é µÈ´Ù.
Áú¹®¿¡ ÇØ´çÇÏ´Â ÆÐÅ°Áö A¿Í B´Â ÇϳªÀÇ ½ÇÇà ÇÁ·Î±×·¥¿¡¼ µ¿½Ã¿¡ »ç¿ëµÇÁö ¾Ê°í ¼·Î ´Ù¸¥ ÇÃÆêÆû¿¡¼ °³º°ÀûÀ¸·Î »ç¿ëµÇ´Â °æ¿ì¶ó¼ ÆÐÅ°Áö ¼Ó¼ºÀ» Runtime only·Î ÄÄÆÄÀÏ Çؼ »ç¿ëÇÏ¸é °°Àº À̸§ÀÇ À¯´ÖÀ» Contains¿¡ °¡Á®µµ »ó°ü ¾ø´Ù. º°°³ÀÇ Ç÷¿Æû¿¡¼ µ¶¸³ÀûÀÎ Runtime ÆÐÅ°Áö·Î »ç¿ëµÇ´Â °æ¿ìÀ̹ǷÎ.
|