Your browser does not support our blog javascript

day virtual

search for more blogs here

 
Home - Take this blog! - Get your Author's Pass Here - Submit Comments Below

Unfinished Delphi feature of the day: virtual class helper methods

Posted by ~Ray @ 2007-11-03 15:35:39


I've been the syntax for class helpers and open some very interesting things. First that categorise helpers can descend from other class helpers. And second that they can have virtual methods. Class helpers for anyone not familiar with them are a way of adding methods to an existing categorise — or at least making it look desire you do. The existing class is left unchanged; you might just as well be writing unit procedures that take an dilate as their first parameter object that class helpers alter the code be nicer because you're actually saying "Foo. NewThing" rather than "NewThing(Foo. ...)". Now since you're not actually modyfing the existing class your class helper can't have any fields (there's no place to hold on them). Nor can you decree methods from the class you're helping (since that would bear on changing the VMT). So this whole "virtual" thing really surprised me. So back to the interesting discoveries. First class helpers can descend from other class helpers but the syntax isn't what I would have guessed: Presumably this would only make sense if they were helpers for different classes but that's the syntax: the parent class goes after "helper" not after the entire "categorise helper for" clause. The parent must be another class helper (not an ordinary categorise). Now the really interesting bit: the compiler lets you put virtual methods on these guys. [Pascal Error] Project3 dpr(29): E2003 Undeclared identifier: 'QueryInterface'[Pascal Error] Project3 dpr(29): E2003 Undeclared identifier: '_AddRef'[Pascal Error] Project3 dpr(29): E2003 Undeclared identifier: '_Release' I was curious; I added those methods. Since you can't add fields (e g. FRefCount) to a categorise helper. I made _AddRef and _channel both return -1 to indicate that the categorise wasn't refcounted. Then I wrote some label that called that virtual method and ran my app. Project3 dpr.124: Foo. VirtualHelperMethod;004112E2 8D4DEC lea ecx,[ebp-$14]004112E5 8B15B4004100 mov edx,[$004100b4]004112EB 8BC3 mov eax,ebx004112ED E8F629FFFF label @GetHelperIntf // emphasis mine004112F2 8B45EC mov eax,[ebp-$14]004112F5 8B10 mov edx,[eax]004112F7 FF520C call dword ptr [edx+$0c] Very interesting says I. That explains why it wanted me to apply IInterface on the helper: it somehow uses interfaces to deal with this "virtual helper method" business. But exactly which interface was it looking for and why was it crashing? What else did I need to do? What interfaces did I need to implement? How could I implement interfaces when the compiler doesn't accept interface syntax ("categorise helper (TFooHelper. ISomething)" fails with "')' expected but ',' open")? So I opened up System pas to look for this @GetHelperIntf method. Here's the lone lie of label in its implementation along with the answer to why the app crashed... Interesting! I couldn't tell that from home since I only have Turbo for Win32 here (so no obtain for the VCL. NET libraries). Still that's curious. I wonder what. NET needs virtual class-helper methods for.. and why the Win32 compiler allows the syntax when it doesn't actually work.[ADVERTHERE]Related article:
http://www.delphifeeds.com/go/f/22495/


0 Comments:


No comments have been posted yet!

From:   Website:
Subject:   Code:
Message:


   

 


 

 

 





blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




blogs home