home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-075 < prev    next >
Text File  |  2010-09-21  |  75KB  |  2,013 lines

  1. Received-Date: Mon, 12 Dec 1994 16:17:01 +0100
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-075
  4. To: csmp-digest@ens.fr
  5. Date: Mon, 12 Dec 1994 16:16:53 +0100 (MET)
  6. X-Mailer: ELM [version 2.4 PL23]
  7. Mime-Version: 1.0
  8. Content-Type: text/plain; charset=ISO-8859-1
  9. Content-Transfer-Encoding: 8bit
  10. Errors-To: listman@ens.fr
  11. Reply-To: pottier@clipper.ens.fr
  12. X-Sequence: 81
  13.  
  14. C.S.M.P. Digest             Mon, 12 Dec 94       Volume 3 : Issue 75
  15.  
  16. Today's Topics:
  17.  
  18.         AppleScript FTP-site?
  19.         C++ and handles
  20.         Finding out whether text is selected in a dialog
  21.         How to get default 'aeut' resource?
  22.         MacsBug - what is it and why?
  23.         how to get PB in PPC completion routine?
  24.         oops..
  25.  
  26.  
  27.  
  28. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  29. (pottier@clipper.ens.fr).
  30.  
  31. The digest is a collection of article threads from the internet newsgroup
  32. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  33. regularly and want an archive of the discussions.  If you don't know what a
  34. newsgroup is, you probably don't have access to it.  Ask your systems
  35. administrator(s) for details.  If you don't have access to news, you may
  36. still be able to post messages to the group by using a mail server like
  37. anon.penet.fi (mail help@anon.penet.fi for more information).
  38.  
  39. Each issue of the digest contains one or more sets of articles (called
  40. threads), with each set corresponding to a 'discussion' of a particular
  41. subject.  The articles are not edited; all articles included in this digest
  42. are in their original posted form (as received by our news server at
  43. nef.ens.fr).  Article threads are not added to the digest until the last
  44. article added to the thread is at least two weeks old (this is to ensure that
  45. the thread is dead before adding it to the digest).  Article threads that
  46. consist of only one message are generally not included in the digest.
  47.  
  48. The digest is officially distributed by two means, by email and ftp.
  49.  
  50. If you want to receive the digest by mail, send email to listserv@ens.fr
  51. with no subject and one of the following commands as body:
  52.     help                        Sends you a summary of commands
  53.     subscribe csmp-digest Your Name    Adds you to the mailing list
  54.     signoff csmp-digest            Removes you from the list
  55. Once you have subscribed, you will automatically receive each new
  56. issue as it is created.
  57.  
  58. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  59. Questions related to the ftp site should be directed to
  60. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  61. digest are available there.
  62.  
  63. Also, the digests are available to WAIS users.  To search back issues
  64. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  65. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  66.  
  67.  
  68. -------------------------------------------------------
  69.  
  70. >From bafutsel@knoware.nl (Anton Futselaar)
  71. Subject: AppleScript FTP-site?
  72. Date: Mon, 21 Nov 1994 22:43:42 GMT
  73. Organization: Dieren / The Netherlands
  74.  
  75. Hi,
  76.  
  77. Is there somewhere out there an FTP-site for AppleScript.
  78.  
  79. Thanks, Anton.
  80.  
  81. +++++++++++++++++++++++++++
  82.  
  83. >From decartwr@newstand.syr.edu (Dana Cartwright 3rd)
  84. Date: 22 Nov 1994 02:36:16 GMT
  85. Organization: Syracuse University, Syracuse NY, USA
  86.  
  87. Anton Futselaar (bafutsel@knoware.nl) wrote:
  88. : Is there somewhere out there an FTP-site for AppleScript.
  89.  
  90. gaea.kgs.ukans.edu    
  91.  
  92.  
  93. +++++++++++++++++++++++++++
  94.  
  95. >From drk00@cas.org ()
  96. Date: Wed, 23 Nov 1994 17:02:14 GMT
  97. Organization: Chemical Abstracts Service, Columbus, Ohio
  98.  
  99. In article <bafutsel-211194224107@mac-4.knoware.nl> bafutsel@knoware.nl (Anton Futselaar) writes:
  100. >Hi,
  101. >
  102. >Is there somewhere out there an FTP-site for AppleScript.
  103. >
  104. >Thanks, Anton.
  105.  
  106. Try ftp://gaea.kgs.ukans.edu/applescript
  107.  
  108. Dan Kelsey
  109. (drk00@cas.org)
  110.  
  111. ---------------------------
  112.  
  113. >From Richard Kennaway <jrk@sys.uea.ac.uk>
  114. Subject: C++ and handles
  115. Date: 3 Nov 1994 13:52:44 GMT
  116. Organization: SYS, University of East Anglia
  117.  
  118. I recently ported a C program to C++, which wasn't too difficult, but
  119. when I tried to convert some of the data structures to classes, I ran
  120. into a problem which seems so simple, everyone using C++ on a Mac must
  121. have encountered it.  However, I don't see any nice solution.
  122.  
  123. How do I use a relocatable block for storing a class object?  Suppose I
  124. define a class xclass containing a member function foo(), and declare an
  125. object x of type **xclass, initialised by a call of NewHandle(
  126. sizeof(xclass) ).  I can't safely call (*x)->foo(), since the implicit
  127. "this" argument to foo() is a dereferenced handle.  If foo() is capable
  128. of allocating memory, then x may get relocated, invalidating the value of
  129. "this".
  130.  
  131. Possible workarounds:
  132.  
  133. (1) Don't use relocatable memory to allocate class objects.  (Leads to
  134. memory fragmentation.)
  135.  
  136. (2) Lock handles before calling member functions and restore their state
  137. afterwards.  (Error-prone and tedious.)
  138.  
  139. (3) Have each member function first locate the parent handle of "this"
  140. and then either lock it, or always use the handle to access components. 
  141. (Memory fragmentation, error-prone, tedious, and how expensive is a call
  142. to RecoverHandle()?)
  143.  
  144. (4) Abandon C++ on the Mac.
  145.  
  146. Any other ideas?  I'm using CodeWarrior, but the manual doesn't mention
  147. this problem.
  148.  
  149. ___
  150. \X/ Richard Kennaway, jrk@sys.uea.ac.uk, Univ. of East Anglia, Norwich
  151.  
  152. +++++++++++++++++++++++++++
  153.  
  154. >From amasson@ensem.u-nancy.fr (Arnaud MASSON)
  155. Date: 3 Nov 1994 18:27:22 GMT
  156. Organization: Ensem, Nancy, France
  157.  
  158. In article <39apvc$h98@cpca3.uea.ac.uk>, Richard Kennaway <jrk@sys.uea.ac.uk> writes:
  159. |> I recently ported a C program to C++, which wasn't too difficult, but
  160. |> when I tried to convert some of the data structures to classes, I ran
  161. |> into a problem which seems so simple, everyone using C++ on a Mac must
  162. |> have encountered it.  However, I don't see any nice solution.
  163. |> 
  164. |> How do I use a relocatable block for storing a class object?  Suppose I
  165. |> define a class xclass containing a member function foo(), and declare an
  166. |> object x of type **xclass, initialised by a call of NewHandle(
  167. |> sizeof(xclass) ).  I can't safely call (*x)->foo(), since the implicit
  168. |> "this" argument to foo() is a dereferenced handle.  If foo() is capable
  169. |> of allocating memory, then x may get relocated, invalidating the value of
  170. |> "this".
  171. |> 
  172. |> Possible workarounds:
  173. |> 
  174. |> (1) Don't use relocatable memory to allocate class objects.  (Leads to
  175. |> memory fragmentation.)
  176. |> 
  177. |> (2) Lock handles before calling member functions and restore their state
  178. |> afterwards.  (Error-prone and tedious.)
  179. |> 
  180. |> (3) Have each member function first locate the parent handle of "this"
  181. |> and then either lock it, or always use the handle to access components. 
  182. |> (Memory fragmentation, error-prone, tedious, and how expensive is a call
  183. |> to RecoverHandle()?)
  184. |> 
  185. |> (4) Abandon C++ on the Mac.
  186. |> 
  187. |> Any other ideas?  I'm using CodeWarrior, but the manual doesn't mention
  188. |> this problem.
  189. |> 
  190. |> ___
  191. |> \X/ Richard Kennaway, jrk@sys.uea.ac.uk, Univ. of East Anglia, Norwich
  192.  
  193.  
  194. Hello, this is my first experience of answering something on the Internet!
  195.  
  196. About the C++ and handles, I would say that handles are an old system of memory
  197. managment. Now there is virtual memory (and many more RAM of course) than in 1984,
  198. so handles are not needed anymore for small blocks like usual objects of user interface.
  199. On powerPC, it seems that the segment loader (= handles of code)
  200. is not really necessary anymore(I'm not sure, new Inside Mac cost too much).
  201. I think also that multiple inheritance require pointers since it's impossible to have
  202. handle to something inside handle, if you see what I mean.
  203.  
  204. So, there is today no reason to have C++ objects as handles.
  205.  
  206. PS: sorry for my bad English. Please, could someone answer me by email ?
  207. I'm student and I would like to know who is on the Internet.
  208.  
  209. +++++++++++++++++++++++++++
  210.  
  211. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  212. Date: Thu,  3 Nov 1994 14:48:03 -0500
  213. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  214.  
  215. It is impossible to have a C++ object class as a handle.  Highly
  216. developped classes may create a whole slew of pointers to themselves and
  217. the bitwise copies that the Memory Manager uses would tear C++ objects
  218. to shreds.  
  219.  
  220. Nathaniel
  221.  
  222. +++++++++++++++++++++++++++
  223.  
  224. >From howardb@enlil.premenos.com (Howard Berkey)
  225. Date: 3 Nov 1994 20:42:04 GMT
  226. Organization: Weyland-Yutani thinking machines division
  227.  
  228. In article <kiiHtni00iV986gVhT@andrew.cmu.edu>,
  229. Nathaniel P Woods  <nw2d+@andrew.cmu.edu> wrote:
  230. >It is impossible to have a C++ object class as a handle.  Highly
  231. >developped classes may create a whole slew of pointers to themselves and
  232. >the bitwise copies that the Memory Manager uses would tear C++ objects
  233. >to shreds.  
  234. >
  235. >Nathaniel
  236.  
  237.  
  238. Really?  You are sure about this?  :-)
  239.  
  240. -H-
  241.  
  242. (note that I'm NOT arguing in favor of handle based objects)
  243.  
  244.  
  245. +++++++++++++++++++++++++++
  246.  
  247. >From brett@process.oz.au (Brett Powley)
  248. Date: 4 Nov 1994 14:37:47 +1100
  249. Organization: Telecom Australia - CSSC
  250.  
  251. Nathaniel P Woods <nw2d+@andrew.cmu.edu> writes:
  252.  
  253. >It is impossible to have a C++ object class as a handle.  Highly
  254. >developped classes may create a whole slew of pointers to themselves and
  255. >the bitwise copies that the Memory Manager uses would tear C++ objects
  256. >to shreds.  
  257.  
  258. I'm not sure what this somewhat confused ramble follows on from but...
  259.  
  260. C++ allows you to use any allocation mechanism you like, by overriding the
  261. new operator.  You may notice that THINK C with object extensions has
  262. "indirect" classes (i.e. handle-based) while Symantec C++ allows a
  263. __machdl attribute on a class to specify that it is to be handle- rather
  264. than pointer- based.  I haven't found any equivalent mechanism built
  265. into CodeWarrior (yet).
  266.  
  267. Brett Powley
  268. brett@process.oz.au
  269. Process Software
  270. Wollongong, Australia
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279. +++++++++++++++++++++++++++
  280.  
  281. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  282. Date: Fri,  4 Nov 1994 08:57:39 -0500
  283. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  284.  
  285. >Really?  You are sure about this?  :-)
  286.  
  287. Well not all will do this.  But when you make objects loaded with
  288. virtual inheritance, other complex classes inside of it, you will see
  289. that effect.  That is why you should override operator = to do an assign
  290. for your class when you do stuff that would cause a bitwise copy to
  291. invalidate your class.
  292.  
  293. Nathaniel
  294.  
  295. +++++++++++++++++++++++++++
  296.  
  297. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  298. Date: Fri,  4 Nov 1994 09:00:33 -0500
  299. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  300.  
  301. >C++ allows you to use any allocation mechanism you like, by overriding the
  302. >new operator.
  303.  
  304. Thats true, but lets say one of your member classes puts a pointer to
  305. itself somewhere else.  If the class was derived from some type of
  306. handle, there would be no way to update that other pointer.
  307.  
  308. Im not saying it isnt possible to have Handle classes, but when you get
  309. heavy into C++ they will become unusable.
  310.  
  311. Nathaniel
  312.  
  313. +++++++++++++++++++++++++++
  314.  
  315. >From pcastine@prz.tu-berlin.de (Peter Castine)
  316. Date: Fri, 4 Nov 1994 17:08:25 GMT
  317. Organization: Process Control Center
  318.  
  319. In article <39ba2a$r8l@arcturus.ciril.fr>, amasson@ensem.u-nancy.fr
  320. (Arnaud MASSON) wrote (regarding classes as handles):
  321.  
  322. > About the C++ and handles, I would say that handles are an old system of
  323. memory
  324. > managment. Now there is virtual memory (and many more RAM of course)
  325. than in 1984,
  326. > so handles are not needed anymore for small blocks like usual objects of
  327. user interface.
  328. > On powerPC, it seems that the segment loader (= handles of code)
  329. > is not really necessary anymore(I'm not sure, new Inside Mac cost too much).
  330. > I think also that multiple inheritance require pointers since it's
  331. impossible to have
  332. > handle to something inside handle, if you see what I mean.
  333. > So, there is today no reason to have C++ objects as handles.
  334.  
  335. As has been discussed extensively in c.s.m.p, handles still have a place
  336. within the Macintosh memory model, despite the relative inexpense of
  337. memory nowadays. However, C++ objects is not one of them.
  338.  
  339. Arnaud is correct in stating that multiple inheritance is incompatible
  340. with handle-based C++ objects. This has been documented in _develop_ (and,
  341. presumably other places). If you have a class that inherits from
  342. superclasses A and B,
  343. the object will look something like this on the heap:
  344.  
  345.     +-------------------+
  346.     | Data members      |
  347.     | inherited from    |
  348.     | Class A           |
  349.     +-------------------+
  350.     | Data members      |
  351.     | inherited from    |
  352.     | Class B           |
  353.     +-------------------+
  354.     | more members      |
  355.     +-------------------+
  356.  
  357. If you need to execute a method inherited from B, the compiler passes a
  358. pointer to where the data members from class B are. With pointer-based
  359. classes, this is just an offset. If you have any experience with handles,
  360. you know that you can't just calculate an offset and pass it to any old
  361. function... memory may get moved somewhere along the line, the pointer is
  362. no longer valid, and general bad kharma.
  363.  
  364. You will notice that both Smalltalk and THINK C with objects used handles
  365. and implement single-inheritance only . This is no coincidence. Since
  366. Richard is using CW, reverting to THINK C w/objects is not an option.
  367.  
  368. (Footnote: I'm only 90% sure about Smalltalk & handles. With THINK I know)
  369.  
  370. The short answer is to use pointers with C++. Your library classes will
  371. use standard handle-based data structures for accessing the Toolbox. If
  372. your class library's hot, it will have lots of tweaks to minimize heap
  373. fragmentation when using objects (I don't think any of the available class
  374. libraries is particularly hot :-\ )
  375.  
  376.  
  377. > PS: sorry for my bad English. Please, could someone answer me by email ?
  378. > I'm student and I would like to know who is on the Internet.
  379.  
  380. Arnaud--hey, your English is better than my French. And, I've seen native
  381. speakers use worse English on the net.
  382.  
  383. -- 
  384. Peter Castine               | Useful approximations:
  385. pcastine@prz.tu-berlin.de   |  Pi seconds is a nanocentury.
  386. Process Control Center      |  Electricity travels a foot per nanosecond.
  387. Technical University Berlin |  One ostrich egg will feed 24 people for brunch.
  388.  
  389. +++++++++++++++++++++++++++
  390.  
  391. >From rbar@starbase.neosoft.com (Richard Bartel)
  392. Date: 5 Nov 1994 08:21:09 GMT
  393. Organization: NeoSoft Internet Services   +1 713 684 5969
  394.  
  395. Nathaniel P Woods (nw2d+@andrew.cmu.edu) wrote:
  396. : >C++ allows you to use any allocation mechanism you like, by overriding the
  397. : >new operator.
  398.  
  399. : Thats true, but lets say one of your member classes puts a pointer to
  400. : itself somewhere else.  If the class was derived from some type of
  401. : handle, there would be no way to update that other pointer.
  402.  
  403. : Im not saying it isnt possible to have Handle classes, but when you get
  404. : heavy into C++ they will become unusable.
  405.  
  406. : Nathaniel
  407.  
  408. I'm new to C++ but I have programmed extensively in Consular 68000
  409. assembler.  So please excuse me for discussing C++ objects as purely data 
  410. structures and for any ignorance of C++ specifics. 
  411.  
  412. If a data structure is created via NewHandle (i.e. is a relocatable
  413. block), then it is unadvisable to store "a pointer to itself" except as a
  414. temporary variable while the handle is locked via HLock.  A Mac handle is
  415. not a pointer to a pointer but is a pointer to a "master pointer".  If a
  416. relocatable block relocates, the master pointer is updated to point to the
  417. block's new address.  Therefore, if you need to maintain self-reference
  418. within a relocatable block, then you must store a copy of its handle. 
  419.  
  420. There may be further restrictions that C++ may require that render handles
  421. and relocatable blocks "unusable" as data structures for objects.  I don't
  422. know of any restrictions but then again I am not qualified to comment on
  423. that. If they are unusable, then I am disappointed.  While pointers are
  424. generally preferred over handles (due to speed and simplicity), there are
  425. times when it is nice to have the ability to increase the size of an
  426. object or to allow the object to move so another block may grow.  And
  427. while machines today typically have more RAM than earlier Macs, there's
  428. never too much RAM and virtual memory is not without its costs.  Also, new
  429. apps are getting bigger and lots of older Macs are still out there and
  430. still being used.  
  431.  
  432. As an example, we had to bump up my 8100/80 from 24 to 40Mb of RAM because
  433. Illustrator ran out of memory on some of the larger GIS documents we are
  434. producing, and even still the limitation has not been eliminated. 
  435.  
  436. R.L. Bartel
  437.  
  438.  
  439. +++++++++++++++++++++++++++
  440.  
  441. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  442. Date: Sat,  5 Nov 1994 09:58:28 -0500
  443. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  444.  
  445. >I'm new to C++ but I have programmed extensively in Consular 68000
  446. >assembler.  So please excuse me for discussing C++ objects as purely data 
  447. >structures and for any ignorance of C++ specifics. 
  448.  
  449. No prob
  450.  
  451. >If a data structure is created via NewHandle (i.e. is a relocatable
  452. >block), then it is unadvisable to store "a pointer to itself" except as a
  453. >temporary variable while the handle is locked via HLock.  A Mac handle is
  454. >not a pointer to a pointer but is a pointer to a "master pointer".  If a
  455. >relocatable block relocates, the master pointer is updated to point to the
  456. >block's new address.  Therefore, if you need to maintain self-reference
  457. >within a relocatable block, then you must store a copy of its handle. 
  458.  
  459. Thats exactly the point Ive been making - why C++ classes cant work with
  460. handles.  Classes often have member classes.  With a pointer, these can
  461. be stored as offsets from the beginning of the block, but this wont work
  462. with Handles because as soon as the object gets relocated these other
  463. pointers become invalid.
  464.  
  465. This is not to say that Handles are not possible with C++.  One can
  466. still reference data with Handles the way one could always, just that
  467. you cant just make C++ classes based from Handles
  468.  
  469. Nathaniel
  470.  
  471.  
  472. +++++++++++++++++++++++++++
  473.  
  474. >From Jaeger@fquest.com (Brian Stern)
  475. Date: 5 Nov 1994 16:59:20 GMT
  476. Organization: The University of Texas at Austin, Austin, Texas
  477.  
  478. In article <39apvc$h98@cpca3.uea.ac.uk>, Richard Kennaway
  479. <jrk@sys.uea.ac.uk> wrote:
  480.  
  481. < I recently ported a C program to C++, which wasn't too difficult, but
  482. < when I tried to convert some of the data structures to classes, I ran
  483. < into a problem which seems so simple, everyone using C++ on a Mac must
  484. < have encountered it.  However, I don't see any nice solution.
  485. < How do I use a relocatable block for storing a class object?  Suppose I
  486. < define a class xclass containing a member function foo(), and declare an
  487. < object x of type **xclass, initialised by a call of NewHandle(
  488. < sizeof(xclass) ).  I can't safely call (*x)->foo(), since the implicit
  489. < "this" argument to foo() is a dereferenced handle.  If foo() is capable
  490. < of allocating memory, then x may get relocated, invalidating the value of
  491. < "this".
  492. < Possible workarounds:
  493. < (1) Don't use relocatable memory to allocate class objects.  (Leads to
  494. < memory fragmentation.)
  495. < (2) Lock handles before calling member functions and restore their state
  496. < afterwards.  (Error-prone and tedious.)
  497. < (3) Have each member function first locate the parent handle of "this"
  498. < and then either lock it, or always use the handle to access components. 
  499. < (Memory fragmentation, error-prone, tedious, and how expensive is a call
  500. < to RecoverHandle()?)
  501. < (4) Abandon C++ on the Mac.
  502. < Any other ideas?  I'm using CodeWarrior, but the manual doesn't mention
  503. < this problem.
  504. < ___
  505. < \X/ Richard Kennaway, jrk@sys.uea.ac.uk, Univ. of East Anglia, Norwich
  506.  
  507. If you're using CodeWarrior then your classes are pointers, not handles. 
  508. If you have data structures that are handles, they should become data
  509. members of your new classes.  You create your classes in the usual way by
  510. calling operator new.  In the constructor you call NewHandle() to allocate
  511. the data member.  You access the data member as you would any handle from
  512. the methods of the class.  Something like this:
  513.  
  514. class foo {
  515.    foo::foo() { itsData = NewHandle( kASize); }
  516.    foo::~foo() { if (itsData) DisposeHandle( itsData ); }
  517.    Handle   itsData;
  518. };
  519.  
  520. -- 
  521. Brian  Stern  :-{)}
  522. Toolbox commando and Menu bard
  523. Jaeger@fquest.com
  524.  
  525. +++++++++++++++++++++++++++
  526.  
  527. >From jbennett@umich.edu (Jeremy Ford Bennett)
  528. Date: 4 Nov 1994 20:21:02 GMT
  529. Organization: University of Michigan
  530.  
  531. In article <39caab$le@slug.cssc-syd.tansu.com.au>,
  532. Brett Powley <brett@process.oz.au> wrote:
  533. >Nathaniel P Woods <nw2d+@andrew.cmu.edu> writes:
  534. >
  535. [snip]
  536. >
  537. >I'm not sure what this somewhat confused ramble follows on from but...
  538. >
  539. >C++ allows you to use any allocation mechanism you like, by overriding the
  540. >new operator.  You may notice that THINK C with object extensions has
  541. >"indirect" classes (i.e. handle-based) while Symantec C++ allows a
  542. >__machdl attribute on a class to specify that it is to be handle- rather
  543. >than pointer- based.  I haven't found any equivalent mechanism built
  544. >into CodeWarrior (yet).
  545. >
  546. >Brett Powley
  547. >brett@process.oz.au
  548. >Process Software
  549. >Wollongong, Australia
  550.  
  551. Would you mind going into more detail on the _machdl attribute? I'm currently
  552. working on a small project where I will have an array of class objects
  553. in SC++ that will end up in a global structure that is a handle.
  554. I'm writing a small AfterDark module for a class so the handle is not my idea.
  555. Any info provided would be appreciated.
  556.  
  557. Jeremy
  558.  
  559. -- 
  560. jbennett@umich.edu 
  561. Student of Computer Science, University of Michigan
  562. For PGP key finger jbennett@ttl.engin.umich.edu
  563. In the end, there can be only one.
  564.  
  565. +++++++++++++++++++++++++++
  566.  
  567. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  568. Date: Mon, 7 Nov 1994 21:02:56 GMT
  569. Organization: Apple Computer
  570.  
  571. Nathaniel P Woods, nw2d+@andrew.cmu.edu writes:
  572. > It is impossible to have a C++ object class as a handle.  Highly
  573. > developped classes may create a whole slew of pointers to themselves and
  574. > the bitwise copies that the Memory Manager uses would tear C++ objects
  575. > to shreds.  
  576.  
  577. Nope. You can have objects in handles, as long as the compiler knows they are
  578. in handles -- both cfront and Symantec C++ have extensions to the language
  579. that do this. There is of course additional overhead for all the
  580. double-dereferencing, and you have to be careful to lock the handle when
  581. necessary.
  582.  
  583. What _is_ impossible is to use multiple inheritance with handle-based
  584. objects, because MI requires multiple objects inside an object, and you can't
  585. put a relocatable block inside another relocatable block.
  586.  
  587. --Jens Alfke                           jens_alfke@powertalk.apple.com
  588.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  589.  
  590. +++++++++++++++++++++++++++
  591.  
  592. >From Jaeger@fquest.com (Brian Stern)
  593. Date: 8 Nov 1994 20:57:24 GMT
  594. Organization: The University of Texas at Austin, Austin, Texas
  595.  
  596. In article <39ff9l$s0g@uuneo.neosoft.com>, rbar@starbase.neosoft.com
  597. (Richard Bartel) wrote:
  598.  
  599. < While pointers are
  600. < generally preferred over handles (due to speed and simplicity), there are
  601. < times when it is nice to have the ability to increase the size of an
  602. < object or to allow the object to move so another block may grow.
  603. < R.L. Bartel
  604.  
  605. You might resize a handle used as a data member, but resizing the actual
  606. object is very unlikely.
  607.  
  608. -- 
  609. Brian  Stern  :-{)}
  610. Toolbox commando and Menu bard
  611. Jaeger@fquest.com
  612.  
  613. +++++++++++++++++++++++++++
  614.  
  615. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  616. Date: Wed, 9 Nov 1994 01:00:56 GMT
  617. Organization: Apple Computer
  618.  
  619. Nathaniel P Woods, nw2d+@andrew.cmu.edu writes:
  620. > Im not saying it isnt possible to have Handle classes, but when you get
  621. > heavy into C++ they will become unusable.
  622.  
  623. This is untrue. Before you keep trying to insist on this, please read the
  624. Symantec or MPW documentation about "HandleObject" or the "__machdl"
  625. attribute. Both of these allow you to have full C++ objects in handles. The
  626. only limitation is no multiple inheritance. Very large systems like MacApp
  627. and MacApp-based applications have been built using this type of object.
  628.  
  629. --Jens Alfke                           jens_alfke@powertalk.apple.com
  630.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  631.  
  632. +++++++++++++++++++++++++++
  633.  
  634. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  635. Date: Wed,  9 Nov 1994 02:37:58 -0500
  636. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  637.  
  638. >This is untrue. Before you keep trying to insist on this, please read the
  639. >Symantec or MPW documentation about "HandleObject" or the "__machdl"
  640. >attribute. Both of these allow you to have full C++ objects in handles. The
  641. >only limitation is no multiple inheritance. Very large systems like MacApp
  642. >and MacApp-based applications have been built using this type of object.
  643.  
  644. Does MacApp use full C++ extensions in ways like PowerPlant does with
  645. multiple inheritance, objects declared in the global scope or anything
  646. else?  Or are handle-classes only possible with second-rate OOP
  647. implementations that dont use constructors/destructors?  If they managed
  648. to make a compiler that used handles with multiple inheritance etc it
  649. would make the most awkward looking classes imaginable.
  650.  
  651. Nathaniel
  652.  
  653. +++++++++++++++++++++++++++
  654.  
  655. >From isi@panix.com (Atman Jacob Binstock)
  656. Date: 9 Nov 1994 12:34:56 -0500
  657. Organization: Integrated Software Inc.
  658.  
  659. In article <1994Nov9.010056.26498@gallant.apple.com>,
  660. Jens Alfke  <jens_alfke@powertalk.apple.com> wrote:
  661. >This is untrue. Before you keep trying to insist on this, please read the
  662. >Symantec or MPW documentation about "HandleObject" or the "__machdl"
  663. >attribute. Both of these allow you to have full C++ objects in handles. The
  664. >only limitation is no multiple inheritance. Very large systems like MacApp
  665.  
  666. I don't have any experience with HandleObjects, so my comments will only 
  667. be about Symantec's __machdl classes.  I found __machdl classes to pose 
  668. significant problems.  First, there is no safe and simple way to use 
  669. access functions for a member M of a __machdl class E (i.e. return a 
  670. reference or pointer to a member).  You have several choices: return a normal 
  671. reference and hope the object doesn't move (fine for short term, bad for 
  672. extended references), or cook up a reference class template Href that 
  673. contains a __machdl pointer to E and an offset to M.  However, the second 
  674. solution is not recursive - it fails for M's access functions.  Which means M 
  675. needs to know whether it is IN a normal object or a __machdl object.  Which 
  676. means that it has to return an envelope object that can either be a normal 
  677. reference or an Href.  Sound like a pain?  If M is to return an Href, how 
  678. does it get the __machdl pointer to E that it needs?  Well, M will have to be 
  679. "parented" - aware of the particular object that it is contained in.  This is 
  680. a terrible bother for perhaps a simple class that sometimes won't even be 
  681. used inside a __machdl class, and this problem  occurs every time you 
  682. need to use a pointer or reference to a member of a __machdl object.
  683.  
  684. The solutions I outlined are doable if you really really want C++ 
  685. objects in movable memory.  However, I found Symantec C++ 7.0.3's 
  686. __machdl's much too buggy to make a simple class work correctly.  
  687. Classes mixing __machdl's and templates would rarely compile, and those 
  688. that did would often had faulty code generated.  I would strongly 
  689. suggest avoiding __machdl classes, unless you have very simple classes 
  690. and you are very tight on memory.
  691.  
  692. -- 
  693. Atman Binstock                                       Integrated Software Inc.
  694. isi@panix.com                                        speaking only for myself
  695.  
  696. +++++++++++++++++++++++++++
  697.  
  698. >From pgontier@novell.com (Pete Gontier)
  699. Date: Wed, 09 Nov 1994 14:12:01 -0800
  700. Organization: Novell, Inc., Walnut Creek/Macintosh Site
  701.  
  702. In article <1994Nov9.010056.26498@gallant.apple.com>,
  703. Jens Alfke <jens_alfke@powertalk.apple.com> wrote:
  704.  
  705. > ...please read the
  706. > Symantec or MPW documentation about "HandleObject" or the "__machdl"
  707. > attribute. Both of these allow you to have full C++ objects in handles. The
  708. > only limitation is no multiple inheritance...
  709.  
  710. The only limitation is that you must remove the '=' key from your
  711. keyboard... :-)
  712.  
  713. -- 
  714.  The views expressed here do not necessarily reflect those of my employer.
  715.  
  716. +++++++++++++++++++++++++++
  717.  
  718. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  719. Date: Thu, 10 Nov 1994 00:07:03 GMT
  720. Organization: Apple Computer
  721.  
  722. Nathaniel P Woods, nw2d+@andrew.cmu.edu writes:
  723. > Thats exactly the point Ive been making - why C++ classes cant work with
  724. > handles.  Classes often have member classes.  With a pointer, these can
  725. > be stored as offsets from the beginning of the block, but this wont work
  726. > with Handles because as soon as the object gets relocated these other
  727. > pointers become invalid.
  728.  
  729. I think you mean "member objects" -- instance variables of an object which
  730. themselves are C++ objects. You can use these (and I have) with handle-based
  731. objects, provided that the member object is not a handle (obvious, since you
  732. can't put a handle inside a handle) and that pointers to the member object
  733. are not kept around for a long time -- you can keep pointers to the member
  734. object around as long as you are not calling any Toolbox routines or as long
  735. as the owning handle object is locked down, but not longer than that.
  736. Provided you obey those rules (which are very much like any other
  737. handle-based Mac techniques) you can use handle-based C++ objects just fine.
  738.  
  739. You may want to say that this is bad programming practice -- I disagree with
  740. you on that, but it's better than saying "it's impossible", which is flat out
  741. wrong.
  742.  
  743. --Jens Alfke                           jens_alfke@powertalk.apple.com
  744.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  745.  
  746. +++++++++++++++++++++++++++
  747.  
  748. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  749. Date: Thu, 10 Nov 1994 08:12:43 -0500
  750. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  751.  
  752. >I think you mean "member objects" -- instance variables of an object which
  753. >themselves are C++ objects. You can use these (and I have) with handle-based
  754. >objects, provided that the member object is not a handle (obvious, since you
  755. >can't put a handle inside a handle) and that pointers to the member object
  756. >are not kept around for a long time -- you can keep pointers to the member
  757. >object around as long as you are not calling any Toolbox routines or as long
  758. >as the owning handle object is locked down, but not longer than that.
  759. >Provided you obey those rules (which are very much like any other
  760. >handle-based Mac techniques) you can use handle-based C++ objects just fine.
  761.  
  762. I do _not_ mean member objects.  I mean superclasses of objects.  Watch
  763. this code:
  764.  
  765. class A {
  766. public:
  767.   short a;
  768.   short z;
  769. };
  770.  
  771. class B {
  772. public:
  773.   short b;
  774.   short x;
  775. };
  776.  
  777. class C : public A, public B {
  778. public:
  779.   short c;
  780. };
  781.  
  782. C is now an object that contains five shorts, the offset values will be
  783. something like this:
  784.  
  785. +0 a
  786. +2 z
  787. +4 b
  788. +6 x
  789. +8 c
  790.  
  791. There are two inherited classes, and none use handles.  You cant
  792. reference the 'B' superclass with a handle because they are inside the
  793. block of memory itself.
  794.  
  795. Nathaniel
  796.  
  797. +++++++++++++++++++++++++++
  798.  
  799. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  800. Date: Thu, 10 Nov 1994 19:43:16 GMT
  801. Organization: Apple Computer
  802.  
  803. Nathaniel P Woods, nw2d+@andrew.cmu.edu writes:
  804. > Does MacApp use full C++ extensions in ways like PowerPlant does with
  805. > multiple inheritance, objects declared in the global scope or anything
  806. > else?  Or are handle-classes only possible with second-rate OOP
  807. > implementations that dont use constructors/destructors?
  808.  
  809. MacApp doesn't use MI, which I keep pointing out is impossible with handle
  810. based objects. Handle-based objects cannot also be used as global variables
  811. since they don't live in the global data space.
  812. However, I would not call these restrictions "second-rate OOP". HandleObjects
  813. support the full C++ constructor/destructor notion. And I know several OOP
  814. experts who consider MI to be too dangerous and complex to use.
  815.  
  816. As I said before, I am not arguing with you that HandleObjects are more
  817. restricted than C++ objects. I'm just peeved that you keep saying it's
  818. impossible to put objects in handles, when it is not only possible but common.
  819.  
  820. --Jens Alfke                           jens_alfke@powertalk.apple.com
  821.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  822.  
  823. +++++++++++++++++++++++++++
  824.  
  825. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  826. Date: Thu, 10 Nov 1994 21:59:13 GMT
  827. Organization: Apple Computer
  828.  
  829. Brian Stern, Jaeger@fquest.com writes:
  830. > You might resize a handle used as a data member, but resizing the actual
  831. > object is very unlikely.
  832.  
  833. No, you can resize the object. I've used dynamic-array classes like:
  834.  
  835. class Stack :HandleObject {
  836. public:
  837.   void  Push( long );
  838.   long Pop( );
  839.  
  840. private:
  841.   long nItems;
  842.   long item[];
  843. };
  844.  
  845. The implementation of Push uses PtrAndHand to append the new item to the end
  846. of the handle. It's just like regular use of handles to store dynamic data
  847. types, except that the handle happens to be treated as an object by the
  848. compiler.
  849.  
  850. --Jens Alfke                           jens_alfke@powertalk.apple.com
  851.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  852.  
  853. +++++++++++++++++++++++++++
  854.  
  855. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  856. Date: Thu, 10 Nov 1994 22:22:08 -0500
  857. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  858.  
  859. >MacApp doesn't use MI, which I keep pointing out is impossible with handle
  860. >based objects. Handle-based objects cannot also be used as global variables
  861. >since they don't live in the global data space.
  862. >However, I would not call these restrictions "second-rate OOP". HandleObjects
  863. >support the full C++ constructor/destructor notion. And I know several OOP
  864. >experts who consider MI to be too dangerous and complex to use.
  865.  
  866. ...which is exactly what I keep pointing out.  Second-rate is merely a
  867. term that I am using for objects that are limited in their power.  MI is
  868. not dangerous and complex to use, no more than your automobile is.  You
  869. have to know how it works or else it becomes a killing machine.  Some of
  870. C++'s greatest strengths is being able to have multiple inheritance
  871. which increases the power of modularity.  C++'s main reason for its wide
  872. acceptance is the fact it can be used on a function-based language,
  873. OOP-based language or what have you.
  874.  
  875. >As I said before, I am not arguing with you that HandleObjects are more
  876. >restricted than C++ objects. I'm just peeved that you keep saying it's
  877. >impossible to put objects in handles, when it is not only possible but common.
  878.  
  879. I _never_ said it was impossible to put some types of C++ objects in
  880. Handles, only the ones that lose all of the features that seperate C++
  881. from OOP extensions like the one in THINK C.  Handles as objects are
  882. less common everyday, because OOP implementations are being switched
  883. over to full C++.
  884.  
  885. Nathaniel
  886.  
  887. +++++++++++++++++++++++++++
  888.  
  889. >From Nathaniel P Woods <nw2d+@andrew.cmu.edu>
  890. Date: Fri, 11 Nov 1994 10:32:32 -0500
  891. Organization: Freshman, CIT Undeclared, Carnegie Mellon, Pittsburgh, PA
  892.  
  893. >class Stack :HandleObject {
  894. >public:
  895. >  void  Push( long );
  896. >  long Pop( );
  897. >
  898. >private:
  899. >  long nItems;
  900. >  long item[];
  901. >};
  902.  
  903. What this means is that you cannot define a subclass of this class.
  904.  
  905. +++++++++++++++++++++++++++
  906.  
  907. >From mnc@netcom.com (Miguel Cruz)
  908. Date: Sun, 13 Nov 1994 04:08:49 GMT
  909. Organization: Unaffiliated
  910.  
  911. I sure wish more of this thread were still hanging around here. Anyway, 
  912. here's a dopey question:
  913.  
  914. I understand how to do C++ in a more normal memory environment, and I
  915. understand how to do C on the Mac. What I don't understand is the way to
  916. create C++ objects into memory I got as a handle from the Memory Manager
  917. (without copying them there "by hand"). I'm sure it's obvious, but I can't
  918. find any information about it on the CodeWarrior CD (or any particularly
  919. germane code samples). 
  920.  
  921. Any pointers to a code snippet or so to get me started?
  922.  
  923. Thanks,
  924.  
  925. miguel
  926.  
  927. +++++++++++++++++++++++++++
  928.  
  929. >From mnc@netcom.com (Miguel Cruz)
  930. Date: Sun, 13 Nov 1994 05:21:39 GMT
  931. Organization: Unaffiliated
  932.  
  933. In article <mncCz6u6p.6vE@netcom.com>, Miguel Cruz <mnc@netcom.com> wrote:
  934. >understand how to do C on the Mac. What I don't understand is the way to
  935. >create C++ objects into memory I got as a handle from the Memory Manager
  936.  
  937. Okay, I downloaded TECplusSample from ftp.apple.com and they used some 
  938. mysterious class HandleObject. I tried that and it appears to work just 
  939. fine. However, I'd really like to find the documentation of this. In 
  940. desperation, I searched my entire hard disk for the text 'HandleObject' 
  941. and it was nowhere (except in TECPlusSample).
  942.  
  943. Furthermore, in my mad haste to switch CDs, I dragged the Inside Mac CD-ROM 
  944. icon to the trash and when the Mac ejected it, the tray pushed a glass of 
  945. grape juice off my desk and into my lap. Let that be a lesson to 
  946. development tool vendors: all this would have been avoided with better 
  947. documentation.
  948.  
  949. miguel
  950.  
  951. +++++++++++++++++++++++++++
  952.  
  953. >From rmah@panix.com (Robert Mah)
  954. Date: Sun, 13 Nov 1994 02:44:46 -0500
  955. Organization: One Step Beyond
  956.  
  957. mnc@netcom.com (Miguel Cruz) wrote:
  958.  
  959. ) > understand how to do C on the Mac. What I don't understand is the
  960. ) > way to create C++ objects into memory I got as a handle from the
  961. ) > Memory Manager
  962. ) Okay, I downloaded TECplusSample from ftp.apple.com and they used some 
  963. ) mysterious class HandleObject. I tried that and it appears to work just 
  964. ) fine. However, I'd really like to find the documentation of this. In 
  965. ) desperation, I searched my entire hard disk for the text 'HandleObject' 
  966. ) and it was nowhere (except in TECPlusSample).
  967.  
  968. HandleObject was a hack used by Apple and Symantec to provide Handle
  969. based objects in C++ (and the Think "object C") before multiple inheritance
  970. became an issue in the C++ world.
  971.  
  972. "Real" C++ can't use handle based objects because of thorney issues with
  973. vtables, invisible pointers used in multiple inheritance and other such
  974. C++ compiler minutia.  Can someone who knows more about the theoretical
  975. reasons behind this prohibition chime in with more detailed info.
  976.  
  977. Basically, forget about it.  One of the few benefits handle based objects
  978. would provide is dynamically resizable objects, but since C++ objects can
  979. be stack based, you can simply add a handle field to it and get the same
  980. result and be safer to boot.
  981.  
  982. Cheers,
  983. Rob
  984. _____________________________________________________________________
  985. Robert S. Mah           Software Development          +1.212.947.6507
  986. One Step Beyond        and Network Consulting          rmah@panix.com
  987.  
  988. +++++++++++++++++++++++++++
  989.  
  990. >From jwbaxter@olympus.net (John W. Baxter)
  991. Date: Sun, 13 Nov 1994 10:49:30 -0800
  992. Organization: Internet for the Olympic Peninsula
  993.  
  994. In article <rmah-1311940244460001@rmah.dialup.access.net>, rmah@panix.com
  995. (Robert Mah) wrote:
  996.  
  997. > "Real" C++ can't use handle based objects because of thorney issues with
  998. > vtables, invisible pointers used in multiple inheritance and other such
  999. > C++ compiler minutia.  Can someone who knows more about the theoretical
  1000. > reasons behind this prohibition chime in with more detailed info.
  1001.  
  1002. Multiple inheritance causes requirements for pointers into the middle of
  1003. objects.  Pointers into the middle of [unlocked] handles are (for
  1004. practical purposes) impossible.  Hence no MI in HandleObject.
  1005.  
  1006. Apple went further:  since no MI, no need for the double-sized vtables
  1007. which were used in CFront-like C++ implementations to support MI.  So
  1008. HandleObject used the older vtables.  So did SingleObject.  And of course
  1009. PascalObject used Apple Object Pascal style method lookup (no vtables in
  1010. the CFront sense).
  1011.  
  1012.    [Verb tense is strange above:  Apple's CFront-based C++ is still
  1013. around, but they say phase out of using it.  So I used past tense.]
  1014.  
  1015.    --John
  1016.  
  1017. -- 
  1018. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  1019.    Sorry...clever signatures require cleverness, not found here.
  1020.    jwbaxter@pt.olympus.net
  1021.  
  1022. +++++++++++++++++++++++++++
  1023.  
  1024. >From Richard Kennaway <jrk@sys.uea.ac.uk>
  1025. Date: 14 Nov 1994 09:43:04 GMT
  1026. Organization: SYS, University of East Anglia
  1027.  
  1028. In article <jwbaxter-1311941049300001@ptpm005.olympus.net> John W.
  1029. Baxter, jwbaxter@olympus.net writes:
  1030. > Multiple inheritance causes requirements for pointers into the middle of
  1031. > objects.  Pointers into the middle of [unlocked] handles are (for
  1032. > practical purposes) impossible.  Hence no MI in HandleObject.
  1033.  
  1034. In discussions with colleagues here, someone suggested that the problem
  1035. of pointers into unlocked handles might be solved by representing such
  1036. "pointers" as a pair consisting of a handle and an offset.  This would be
  1037. at the implementation level, the user would still write *p and the code
  1038. generated would do a double dereference + offset.  
  1039.  
  1040. I'll leave to the experts the question of whether this would work or be
  1041. practical.
  1042.  
  1043. ___
  1044. \X/ Richard Kennaway, jrk@sys.uea.ac.uk, Univ. of East Anglia, Norwich
  1045.  
  1046. +++++++++++++++++++++++++++
  1047.  
  1048. >From nagle@netcom.com (John Nagle)
  1049. Date: Mon, 14 Nov 1994 17:29:48 GMT
  1050. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1051.  
  1052. isi@panix.com (Atman Jacob Binstock) writes:
  1053. >The solutions I outlined are doable if you really really want C++ 
  1054. >objects in movable memory.  However, I found Symantec C++ 7.0.3's 
  1055. >__machdl's much too buggy to make a simple class work correctly.  
  1056. >Classes mixing __machdl's and templates would rarely compile, and those 
  1057. >that did would often had faulty code generated.  I would strongly 
  1058. >suggest avoiding __machdl classes, unless you have very simple classes 
  1059. >and you are very tight on memory.
  1060.  
  1061.       Yes.  I reported many bugs in this area to Symantec back in 
  1062. late 1993, as long-time readers of this group may remember.  In general,
  1063. trying to do anything with a "Pascal object" or "handle object" in SC++
  1064. that isn't required for Think C compatibility probably won't work.
  1065.  
  1066.                     John Nagle
  1067.  
  1068. +++++++++++++++++++++++++++
  1069.  
  1070. >From nagle@netcom.com (John Nagle)
  1071. Date: Mon, 14 Nov 1994 17:38:39 GMT
  1072. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1073.  
  1074. Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  1075. >I think you mean "member objects" -- instance variables of an object which
  1076. >themselves are C++ objects. You can use these (and I have) with handle-based
  1077. >objects, provided that the member object is not a handle (obvious, since you
  1078. >can't put a handle inside a handle) and that pointers to the member object
  1079. >are not kept around for a long time -- you can keep pointers to the member
  1080. >object around as long as you are not calling any Toolbox routines or as long
  1081. >as the owning handle object is locked down, but not longer than that.
  1082. >Provided you obey those rules (which are very much like any other
  1083. >handle-based Mac techniques) you can use handle-based C++ objects just fine.
  1084.  
  1085.      Doesn't work for member objects with constructors.  The member's
  1086. constructor gets called with the owning handle object not locked down.
  1087. If the member's constructor does an allocation, the owning handle object
  1088. may move.  The user can't program around this, because there's no place
  1089. where user code has control that the locking could be performed.  The
  1090. owning handle object's constructor doesn't get called until it's too late,
  1091. and the member's constructor doesn't know it's inside a handle.
  1092.  
  1093.      If C++ is to be used with handles, the compiler is going to have
  1094. to generate HLock/HUnlock calls in some situations.  There's too much
  1095. automatic object behavior in C++ for manual locking to work.
  1096.  
  1097.                     John Nagle
  1098.  
  1099. +++++++++++++++++++++++++++
  1100.  
  1101. >From greg@cosc.canterbury.ac.nz (Greg Ewing)
  1102. Date: 15 Nov 1994 00:44:15 GMT
  1103. Organization: University of Canterbury, Christchurch, New Zealand
  1104.  
  1105.  
  1106. In article <3a7bf8$1vm@cpca3.uea.ac.uk>, Richard Kennaway <jrk@sys.uea.ac.uk> writes:
  1107. |> representing such
  1108. |> "pointers" as a pair consisting of a handle and an offset.
  1109. |> 
  1110. |> I'll leave to the experts the question of whether this would work or be
  1111. |> practical.
  1112.  
  1113. I have no doubt that it could be made to work; whether it
  1114. would be worth the effort is another matter.
  1115.  
  1116. This scheme would have to be used consistently for every
  1117. single pointer of any kind whatsoever. Every pointer
  1118. dereference would involve doing something quite complicated,
  1119. since it would have to take account of the case where
  1120. it's really just an ordinary pointer, and if not,
  1121. do a double-dereference-and-add.
  1122.  
  1123. C++ programmers might not be very impressed when they find
  1124. that an innocent-looking piece of code like
  1125.  
  1126.     *p++ = *q++;
  1127.  
  1128. generates about a dozen instructions!
  1129.  
  1130. Some optimisations may be possible if the compiler can
  1131. prove that a given pointer is referencing something that
  1132. won't move during some region of code. How often the
  1133. compiler could prove this I don't know.
  1134.  
  1135. Also, some provision would need to be made for interfacing
  1136. with the toolbox and other pieces of code that don't
  1137. know about all of this.
  1138.  
  1139. So, it could be done, but it would have far-reaching
  1140. consequences. Probably it's much better to forget about
  1141. handles and hope that Apple comes up with a decent
  1142. virtual-address-space OS.
  1143.  
  1144. |> \X/ Richard Kennaway, jrk@sys.uea.ac.uk, Univ. of East Anglia, Norwich
  1145.  
  1146. Greg Ewing, Computer Science Dept, +--------------------------------------+
  1147. University of Canterbury,       | A citizen of NewZealandCorp, a      |
  1148. Christchurch, New Zealand       | wholly-owned subsidiary of Japan Inc.|
  1149. greg@cosc.canterbury.ac.nz       +--------------------------------------+
  1150.  
  1151. +++++++++++++++++++++++++++
  1152.  
  1153. >From pgontier@novell.com (Pete Gontier)
  1154. Date: Mon, 14 Nov 1994 19:39:21 -0800
  1155. Organization: Novell, Inc., Walnut Creek/Macintosh Site
  1156.  
  1157. In article <2867511363@hoult.actrix.gen.nz>,
  1158. Bruce@hoult.actrix.gen.nz (Bruce Hoult) wrote:
  1159.  
  1160. > Nathaniel P Woods <nw2d+@andrew.cmu.edu> writes:
  1161. > > Jens wrote:
  1162. > > > I've used dynamic-array classes...
  1163. > > What this means is that you cannot define a subclass of this class. 
  1164. > You can subclass it fine, as long as you don't add any data mambers.
  1165.  
  1166. This holds true until you try to compile such classes with a compiler
  1167. which wants to put the hidden data members (the ones that point into the
  1168. various tables, including but not limited to the virtual function
  1169. dispatcher) at the *end* of the object instead of at the beginning. Since
  1170. ARM says compilers can put these members anywhere it's convenient, it's
  1171. likely some compiler somewhere does or will do this.
  1172.  
  1173. Personally, I find that it's easier to put dynamically sized structures in
  1174. their own allocated block, with only a pointer or handle in the object,
  1175. since it's easier and less expensive to do reference counting for copies
  1176. that way. 
  1177.  
  1178. However, I do think it would be nice for ANSI to specify that the hidden
  1179. members be placed at the beginning of an object *and* specify rules the
  1180. compiler could enforce for unbounded array declarations within classes.
  1181. Perhaps there are implementation restrictions of which I am not aware.
  1182.  
  1183. -- 
  1184.  The views expressed here do not necessarily reflect those of my employer.
  1185.  
  1186. +++++++++++++++++++++++++++
  1187.  
  1188. >From pgontier@novell.com (Pete Gontier)
  1189. Date: Mon, 14 Nov 1994 19:45:23 -0800
  1190. Organization: Novell, Inc., Walnut Creek/Macintosh Site
  1191.  
  1192. In article <rmah-1311940244460001@rmah.dialup.access.net>,
  1193. rmah@panix.com (Robert Mah) wrote:
  1194.  
  1195. > One of the few benefits handle based objects
  1196. > would provide is dynamically resizable objects, but since C++ objects can
  1197. > be stack based...
  1198.  
  1199. ...you need to make the constructor protected and provide a static member
  1200. function which calls it in the right way.
  1201.  
  1202. There's always a smart-ass ready to step in and snipe, eh? :-)
  1203.  
  1204. -- 
  1205.  The views expressed here do not necessarily reflect those of my employer.
  1206.  
  1207.  "Furthermore, in my mad haste to switch CDs, I dragged the Inside Mac CD-ROM 
  1208.  icon to the trash and when the Mac ejected it, the tray pushed a glass of 
  1209.  grape juice off my desk and into my lap. Let that be a lesson to 
  1210.  development tool vendors: all this would have been avoided with better 
  1211.  documentation." -- Miguel Cruz <mnc@netcom.com>
  1212.  
  1213. +++++++++++++++++++++++++++
  1214.  
  1215. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  1216. Date: Wed, 16 Nov 1994 21:55:24 +1300 (NZDT)
  1217. Organization: (none)
  1218.  
  1219. pgontier@novell.com (Pete Gontier) writes:
  1220. > However, I do think it would be nice for ANSI to specify that the hidden
  1221. > members be placed at the beginning of an object *and* specify rules the
  1222. > compiler could enforce for unbounded array declarations within classes.
  1223. > Perhaps there are implementation restrictions of which I am not aware.
  1224.  
  1225. Well, yeah, there are good reasons that they can't always go at the
  1226. front.  Consider:
  1227.  
  1228. class a {
  1229.     void dosomething();
  1230.     int calculatethis();
  1231.     
  1232.     int i;
  1233.     char c;
  1234. };
  1235.  
  1236. class b: public a {
  1237.     virtual void dosomethingelse();
  1238. };
  1239.  
  1240.  
  1241. Now, class "a" dosn't have any virtual functions, and therefore
  1242. doesn't have a vptr.  Class "b" has a virtual function, and needs a
  1243. vptr, and so it has to go after class "a"'s data members, unless you
  1244. want to break lots of programs.
  1245.  
  1246. It *would* be possible to make use of the mechanism provided for multiple
  1247. inheritence to put the vptr at the front, and have a cast from a* to b*
  1248. (or the revers) add a constant.  But I don't think people would expect that.
  1249.  
  1250. -- Bruce
  1251.  
  1252. +++++++++++++++++++++++++++
  1253.  
  1254. >From shahid@mail.utexas.edu (Shahid M. Alam)
  1255. Date: Wed, 16 Nov 1994 08:19:12 -0600
  1256. Organization: The University of Texas at Austin
  1257.  
  1258. In article <pgontier-1411941945230001@avail.wc.novell.com>,
  1259. pgontier@novell.com (Pete Gontier) wrote:
  1260. > ...you need to make the constructor protected and provide a static member
  1261. > function which calls it in the right way.
  1262.  
  1263. or an argument-taking ctor to do the same (while protecting the default ctor).
  1264.  
  1265. ______________________
  1266. Shahid M. Alam
  1267. shahid@mail.utexas.edu
  1268.  
  1269. +++++++++++++++++++++++++++
  1270.  
  1271. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  1272. Date: Wed, 16 Nov 1994 21:55:24 +1300 (NZDT)
  1273. Organization: (none)
  1274.  
  1275. pgontier@novell.com (Pete Gontier) writes:
  1276. > However, I do think it would be nice for ANSI to specify that the hidden
  1277. > members be placed at the beginning of an object *and* specify rules the
  1278. > compiler could enforce for unbounded array declarations within classes.
  1279. > Perhaps there are implementation restrictions of which I am not aware.
  1280.  
  1281. Well, yeah, there are good reasons that they can't always go at the
  1282. front.  Consider:
  1283.  
  1284. class a {
  1285.     void dosomething();
  1286.     int calculatethis();
  1287.     
  1288.     int i;
  1289.     char c;
  1290. };
  1291.  
  1292. class b: public a {
  1293.     virtual void dosomethingelse();
  1294. };
  1295.  
  1296.  
  1297. Now, class "a" dosn't have any virtual functions, and therefore
  1298. doesn't have a vptr.  Class "b" has a virtual function, and needs a
  1299. vptr, and so it has to go after class "a"'s data members, unless you
  1300. want to break lots of programs.
  1301.  
  1302. It *would* be possible to make use of the mechanism provided for multiple
  1303. inheritence to put the vptr at the front, and have a cast from a* to b*
  1304. (or the revers) add a constant.  But I don't think people would expect that.
  1305.  
  1306. -- Bruce
  1307.  
  1308. +++++++++++++++++++++++++++
  1309.  
  1310. >From shahid@mail.utexas.edu (Shahid M. Alam)
  1311. Date: Wed, 16 Nov 1994 08:19:12 -0600
  1312. Organization: The University of Texas at Austin
  1313.  
  1314. In article <pgontier-1411941945230001@avail.wc.novell.com>,
  1315. pgontier@novell.com (Pete Gontier) wrote:
  1316. > ...you need to make the constructor protected and provide a static member
  1317. > function which calls it in the right way.
  1318.  
  1319. or an argument-taking ctor to do the same (while protecting the default ctor).
  1320.  
  1321. ______________________
  1322. Shahid M. Alam
  1323. shahid@mail.utexas.edu
  1324.  
  1325. +++++++++++++++++++++++++++
  1326.  
  1327. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  1328. Date: Wed, 16 Nov 1994 21:55:24 +1300 (NZDT)
  1329. Organization: (none)
  1330.  
  1331. pgontier@novell.com (Pete Gontier) writes:
  1332. > However, I do think it would be nice for ANSI to specify that the hidden
  1333. > members be placed at the beginning of an object *and* specify rules the
  1334. > compiler could enforce for unbounded array declarations within classes.
  1335. > Perhaps there are implementation restrictions of which I am not aware.
  1336.  
  1337. Well, yeah, there are good reasons that they can't always go at the
  1338. front.  Consider:
  1339.  
  1340. class a {
  1341.     void dosomething();
  1342.     int calculatethis();
  1343.     
  1344.     int i;
  1345.     char c;
  1346. };
  1347.  
  1348. class b: public a {
  1349.     virtual void dosomethingelse();
  1350. };
  1351.  
  1352.  
  1353. Now, class "a" dosn't have any virtual functions, and therefore
  1354. doesn't have a vptr.  Class "b" has a virtual function, and needs a
  1355. vptr, and so it has to go after class "a"'s data members, unless you
  1356. want to break lots of programs.
  1357.  
  1358. It *would* be possible to make use of the mechanism provided for multiple
  1359. inheritence to put the vptr at the front, and have a cast from a* to b*
  1360. (or the revers) add a constant.  But I don't think people would expect that.
  1361.  
  1362. -- Bruce
  1363.  
  1364. +++++++++++++++++++++++++++
  1365.  
  1366. >From shahid@mail.utexas.edu (Shahid M. Alam)
  1367. Date: Wed, 16 Nov 1994 08:19:12 -0600
  1368. Organization: The University of Texas at Austin
  1369.  
  1370. In article <pgontier-1411941945230001@avail.wc.novell.com>,
  1371. pgontier@novell.com (Pete Gontier) wrote:
  1372. > ...you need to make the constructor protected and provide a static member
  1373. > function which calls it in the right way.
  1374.  
  1375. or an argument-taking ctor to do the same (while protecting the default ctor).
  1376.  
  1377. ______________________
  1378. Shahid M. Alam
  1379. shahid@mail.utexas.edu
  1380.  
  1381. +++++++++++++++++++++++++++
  1382.  
  1383. >From sandvik@apple.com (Kent Sandvik)
  1384. Date: Fri, 25 Nov 1994 15:19:01 -0800
  1385. Organization: Apple Computer, Inc. Developer Technical Support
  1386.  
  1387. In article <mncCz6xK4.A7J@netcom.com>, mnc@netcom.com (Miguel Cruz) wrote:
  1388.  
  1389. > In article <mncCz6u6p.6vE@netcom.com>, Miguel Cruz <mnc@netcom.com> wrote:
  1390. > >understand how to do C on the Mac. What I don't understand is the way to
  1391. > >create C++ objects into memory I got as a handle from the Memory Manager
  1392. > Okay, I downloaded TECplusSample from ftp.apple.com and they used some 
  1393. > mysterious class HandleObject. I tried that and it appears to work just 
  1394. > fine. However, I'd really like to find the documentation of this. In 
  1395. > desperation, I searched my entire hard disk for the text 'HandleObject' 
  1396. > and it was nowhere (except in TECPlusSample).
  1397.  
  1398. HandleObject (and PascalObject) were and are documented int the MPW C++
  1399. documentation.
  1400.  
  1401. --Kent
  1402.  
  1403. -- 
  1404. Kent Sandvik   sandvik@apple.com   New Media Analyst/Programmer
  1405. Private activities on Internet.
  1406.  
  1407. ---------------------------
  1408.  
  1409. >From kurisuto@babel.ling.upenn.edu (Sean Crist)
  1410. Subject: Finding out whether text is selected in a dialog
  1411. Date: 11 Nov 1994 18:33:16 GMT
  1412. Organization: University of Pennsylvania, Linguistics Department
  1413.  
  1414. My application has modeless dialogs containing editable text items, and I
  1415. want to tell whether some text is actually selected so that I can
  1416. enable/disable the Cut and Copy commands appropriately.  There's lots of
  1417. handy routines going back as far as OldIM Vol. I to handle the actual
  1418. cutting and pasting, but I don't see any prescribed way to tell whether
  1419. some text is selected.
  1420.  
  1421. The solution appears to be to look at the TextH field of the dialog record
  1422. to get the currently active TEHandle, and then look in that TEHandle to see
  1423. whether any text is selected.  What I want to know is whether this is
  1424. kosher; mucking around in the Toolbox's data structures like this seems to
  1425. be discouraged, but I don't see any other way to do this.
  1426.  
  1427.   \/ __ __    _\_     --Kurisuto  (kurisuto@unagi.cis.upenn.edu)
  1428.  ---  |  |    \ /     
  1429.   _| ,| ,|   -----    For a free copy of the Bill of Rights, finger
  1430.   _| ,| ,|    [_]     this account.
  1431.    |  |  |    [_]     
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437. +++++++++++++++++++++++++++
  1438.  
  1439. >From bjaques@wimsey.com (Barton Jaques)
  1440. Date: Tue, 15 Nov 1994 12:21:44 -0700
  1441. Organization: Wimsey Information Services
  1442.  
  1443. The solution appears to be to look at the TextH field of the dialog record
  1444. to get the currently active TEHandle, and then look in that TEHandle to see
  1445. whether any text is selected.
  1446.  
  1447.   Yes, that's exactly what you should do. Check TERec.selStart and
  1448. TERec.selEnd to see if any characters are selected, then find them in
  1449. TERec.hText (handle to text).
  1450.  
  1451.   You're not actually mucking with Apple's precious data structures,
  1452. you're just spying on them. Anyway, in my ModalDialogs I quite freely
  1453. discard Apple's hTexts and replace them with my own. Just call TECalText
  1454. (and maybe TESetSelect) and TEUpdate afterward to make sure everything
  1455. still displays right.
  1456. -- 
  1457. bjaques@wimsey.com
  1458.  
  1459. +++++++++++++++++++++++++++
  1460.  
  1461. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  1462. Date: Thu, 24 Nov 1994 10:37:29 +0800
  1463. Organization: Department of Computer Science, University of Western Australia
  1464.  
  1465. In article <3a0ddc$e14@netnews.upenn.edu>, kurisuto@babel.ling.upenn.edu
  1466. (Sean Crist) wrote:
  1467.  
  1468. >The solution appears to be to look at the TextH field of the dialog record
  1469. >to get the currently active TEHandle, and then look in that TEHandle to see
  1470. >whether any text is selected.  What I want to know is whether this is
  1471. >kosher; mucking around in the Toolbox's data structures like this seems to
  1472. >be discouraged, but I don't see any other way to do this.
  1473.  
  1474. Welcome to the world of the Dialog Manager, where lots of things just
  1475. can't be done nicely.  You have to either accept that and do them horribly
  1476. or eschew the Dialog Manager and do it all yourself.  For an official DTS
  1477. line on this, take at look at the following TechNote...
  1478.  
  1479.   M.TB.ToolboxKarma M.TB39 TN227 
  1480.   "Toolbox Karma"
  1481.   This Technical Note discusses Macintosh Toolbox compatibility and what you
  1482.   can do to help the Macintosh continue evolving in the future.
  1483.  
  1484. Share and Enjoy.
  1485. --
  1486. Quinn "The Eskimo!"  "Some-kind-of-secret-weapon-came-out-of-nowhere-
  1487.                       and-took-Captain-Bipto-to-his-dooooooooom!"
  1488.   May the Force be with you!
  1489.  
  1490. ---------------------------
  1491.  
  1492. >From gmcgath@condes.mv.com (Gary McGath)
  1493. Subject: How to get default 'aeut' resource?
  1494. Date: Fri, 18 Nov 1994 15:52:29 GMT
  1495. Organization: Conceptual Design
  1496.  
  1497.   I'm trying to figure out the right way to access the 'aeut' resource of
  1498. the default scripting component. OpenComponentResFile() looks as if it
  1499. might provide a key portion of the answer, but the documentation implies
  1500. it can only be called from within a component. Either general advice or
  1501. pointers to sample source code would be welcome. If convenient, please
  1502. copy to me by E-mail.
  1503.  
  1504. -- 
  1505.           Gary McGath
  1506.           gmcgath@condes.mv.com
  1507.  
  1508. +++++++++++++++++++++++++++
  1509.  
  1510. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1511. Date: Wed, 23 Nov 1994 00:32:20 GMT
  1512. Organization: Apple Computer
  1513.  
  1514. Gary McGath, gmcgath@condes.mv.com writes:
  1515. >   I'm trying to figure out the right way to access the 'aeut' resource of
  1516. > the default scripting component. OpenComponentResFile() looks as if it
  1517. > might provide a key portion of the answer, but the documentation implies
  1518. > it can only be called from within a component.
  1519.  
  1520. There is an undocumented OSAGetSysTerminology call that AppleScript
  1521. implements (this is what the Script Editor calls) but it appears to have been
  1522. sanitized out of the shipping OSA.h and AppleScript.h headers.
  1523. However, it is safe to call OpenComponentResFile on another component, so you
  1524. can do it that way. Just remember to detach the resource and make it
  1525. unpurgeable, of course.
  1526.  
  1527. --Jens Alfke                           jens_alfke@powertalk.apple.com
  1528.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  1529.  
  1530. +++++++++++++++++++++++++++
  1531.  
  1532. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1533. Date: 25 Nov 94 11:25:56 +1300
  1534. Organization: University of Waikato, Hamilton, New Zealand
  1535.  
  1536. In article <1994Nov23.003220.3519@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  1537. >
  1538. > There is an undocumented OSAGetSysTerminology call that AppleScript
  1539. > implements (this is what the Script Editor calls) but it appears to have been
  1540. > sanitized out of the shipping OSA.h and AppleScript.h headers.
  1541.  
  1542. I believe you'll find this call in ASDebugging.h/.p. It looks like this:
  1543.  
  1544.     CONST
  1545.     kASSelectGetSysTerminology = 0110BH;
  1546.  
  1547.  
  1548.     PROCEDURE OSAGetSysTerminology
  1549.       (
  1550.     scriptingComponent : ComponentInstance;
  1551.     modeFlags : AESendMode;
  1552.     terminologyID : ShortInt;
  1553.     VAR terminologyList : AEDesc
  1554.       ) : OSAError;
  1555.  
  1556.     CODE
  1557.         02F3CH, 10, kASSelectGetSysTerminology,
  1558.         07000H,
  1559.         0A82AH;
  1560.  
  1561. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1562. Computer Services Dept                     fax: +64-7-838-4066
  1563. University of Waikato            electric mail: ldo@waikato.ac.nz
  1564. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  1565.  
  1566. ---------------------------
  1567.  
  1568. >From sjm@mole.bio.cam.ac.uk (Steven J. Mcclue)
  1569. Subject: MacsBug - what is it and why?
  1570. Date: Mon, 21 Nov 1994 10:19:23 +0000
  1571. Organization: Dept of Genetics, University of Cambridge
  1572.  
  1573. Apologies if this is the wrong place for this, but could someone tell me what programmers use MacsBug for? I'm a real newbie at programming (ie, I'm about half way through Dave Mark's book "Learn C on the Mac" and not finding it easy!!), and I've often seen mention of MacsBug. I used to have a copy, but on the rare occasions it popped up, it seemed full of unintelligible stuff. Now that I'm deling with lots of unintelligible stuff, maybe some kind soul could enlighten me as to what it all means?
  1574.  
  1575. Thanks!
  1576. Steve McClue
  1577. sjm@mole.bio.cam.ac.uk
  1578.  
  1579. +++++++++++++++++++++++++++
  1580.  
  1581. >From jaks@netcom.com (Eric Jackson)
  1582. Date: Mon, 21 Nov 1994 16:27:23 GMT
  1583. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1584.  
  1585. In article <sjm-2111941019230001@131.111.46.92>,
  1586. Steven J. Mcclue <sjm@mole.bio.cam.ac.uk> wrote:
  1587. >Apologies if this is the wrong place for this, but could someone tell me what programmers use MacsBug for? I'm a real newbie at programming (ie, I'm about half way through Dave Mark's book "Learn C on the Mac" and not finding it easy!!), and I've often seen mention of MacsBug. I used to have a copy, but on the rare occasions it popped up, it seemed full of unintelligible stuff. Now that I'm deling with lots of unintelligible stuff, maybe some kind soul could enlighten me as to what it all means?
  1588. >
  1589. >Thanks!
  1590. >Steve McClue
  1591. >sjm@mole.bio.cam.ac.uk
  1592.  
  1593. Yes this is exactly the place to post questions like this.  The idea
  1594. behind this news group was to provide a place for newbies to post questions
  1595. with out having to feel embarassed about it.  What is MacsBug,
  1596. that would take a while to explain in detail.  In one sentince
  1597. its a LowLever debugger, and a good one.  This means that it takes
  1598. you down into the assemble language lever.  I have never writen any
  1599. assemble language code but I still like to look at it.  After a
  1600. while you will start to learn more and more about it.
  1601.  
  1602. Here are a couple of basic tips.  You can get into MacsBug by
  1603. calling: DebugStr("\p your debugger comment goes here");
  1604. with the think Use Debugger option turned of.  Once your in the
  1605. debugger you can go again assuming things are not messed up by
  1606. typing g, to step one step at a time type s, to get out of your
  1607. application type ea for exit application, if your application is
  1608. already messed up type rb for reboot.  You can also type es for 
  1609. exit shell.  Type h for help and get a list of all the commands,
  1610. type il for instruction list and get an assembly language list of
  1611. your code.  If you look at it you might be able to see some tool
  1612. box routines that you recognise to get an idea of where you are.
  1613.  
  1614. Normally you use a lowlever debugger when your high level debugger
  1615. is not working correctly in finding a bug.  There is quite a lot
  1616. more to know about MacsBug, but this will give you a really short
  1617. overview.
  1618.  
  1619. Eric Jackson
  1620. jaks@netcom.com
  1621.  
  1622.  
  1623. +++++++++++++++++++++++++++
  1624.  
  1625. >From coopem@panix.com (Marc Cooperman)
  1626. Date: Tue, 22 Nov 1994 10:07:55 -0500
  1627. Organization: Jumpstart Technologies
  1628.  
  1629. I don't claim to be a MacsBug expert.
  1630.  
  1631. It's a low-level debugger - which means, generally, you don't see source
  1632. code in it, but you can look directly at the Macs memory, registers, and
  1633. program counter, which describe its state, at a level below such higher
  1634. level languages like C.
  1635.  
  1636. You enter MacsBug in 2 situations - the machine encounters a heinous
  1637. processing error in a particular program from which it can't recover, so
  1638. it gives up, and
  1639. deposits you into the aesthetically pleasing MacsBug screen, in the vain
  1640. hope the you too speak hexdecimal and will be able to diagnose the
  1641. problem. In this case you can type es [Return] to try and cleanly exit the
  1642. program and recover to the finder, or ea [Return] to try restarting the
  1643. offending program from scratch.
  1644. If you're feeling brave, you can try the sc or sc7 commands to do a "stack
  1645. crawl" which basically shows you a heirarchy of function calls leading up
  1646. to the crash. If the program was compiled with debugging info, you may
  1647. actually see readable function names, and if this a development project of
  1648. your own, it may give you a clue where to look for a bug in your code.
  1649.  
  1650. The other situation is a forced MacsBug entry where you either hit the
  1651. interrupt switch on your Mac (I think this causes an "NMI" Non Maskable
  1652. Interrupt? on the processor) which puts you immediately in MacsBug with
  1653. the "NMI" message, or by calling DebugStr() from your code, which can
  1654. print a message of your choice, say if you detect an error condition like
  1655. a NULL pointer BEFORE it actually hoses your machine.
  1656.  
  1657. In article <sjm-2111941019230001@131.111.46.92>, sjm@mole.bio.cam.ac.uk
  1658. (Steven J. Mcclue) wrote:
  1659.  
  1660. > Apologies if this is the wrong place for this, but could someone tell me
  1661. what programmers use MacsBug for? I'm a real newbie at programming (ie,
  1662. I'm about half way through Dave Mark's book "Learn C on the Mac" and not
  1663. finding it easy!!), and I've often seen mention of MacsBug. I used to have
  1664. a copy, but on the rare occasions it popped up, it seemed full of
  1665. unintelligible stuff. Now that I'm deling with lots of unintelligible
  1666. stuff, maybe some kind soul could enlighten me as to what it all means?
  1667. > Thanks!
  1668. > Steve McClue
  1669. > sjm@mole.bio.cam.ac.uk
  1670.  
  1671. +++++++++++++++++++++++++++
  1672.  
  1673. >From nick+@pitt.edu ( nick.c )
  1674. Date: Mon, 28 Nov 1994 15:56:13 -0500
  1675. Organization: The Pitt, Chemistry
  1676.  
  1677. In article <jaksCzMLpn.4vM@netcom.com>, jaks@netcom.com (Eric Jackson) wrote:
  1678.  
  1679. > Normally you use a lowlever debugger when your high level debugger
  1680. > is not working correctly in finding a bug.  There is quite a lot
  1681. > more to know about MacsBug, but this will give you a really short
  1682. > overview.
  1683.  
  1684.    [tips omitted]
  1685.  
  1686.    If you [original poster] are interested in getting a handle on 
  1687.      more info, consider buying a copy of:
  1688.  
  1689.         _MacsBug Reference and Debugging Guide_
  1690.           by Apple Computer  $35
  1691.                  Addison Wesley, 1990, ISBN: 0-201-56768-7
  1692.  
  1693.      just started chewing on it myself.  But it seems to be the only
  1694.      reference for MacsBug.
  1695.  
  1696.    BTW, anyone know if there is a chance that this will eventually
  1697.      wind up in DocViewer format on a _develop_ bookmark or Developer
  1698.      reference CD?  I'm kind of surprised it hasn't, maybe Apple is
  1699.      waiting for version 6.5 final release before doing it...?
  1700.  
  1701.  
  1702.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  1703.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  1704.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  1705.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  1706.                     
  1707.  
  1708. ---------------------------
  1709.  
  1710. >From telesis@ecf.toronto.edu (Telesis North)
  1711. Subject: how to get PB in PPC completion routine?
  1712. Date: Thu, 24 Nov 1994 23:53:56 GMT
  1713. Organization: sparodic
  1714.  
  1715. Does anyone out there have a good strategy for writing completion routines 
  1716. that compile for both PPC and 68K?
  1717.  
  1718. My problem is that I have to write a completion routine for the serial 
  1719. driver. I would _really_ like to get access to the parameter block; 
  1720. unfortunately, it's not passed as a parameter. (That would be too 
  1721. sensible.)
  1722.  
  1723. For 68K, A0 comes in pointing to the PB, and a bit of assembly will put it 
  1724. into a local variable. Clearly this isn't going to work on a PowerMac.
  1725.  
  1726. (I realize that I could leave the completion routine as 68K without a 
  1727. significant performance hit - at least until Copland - but I'd prefer not 
  1728. to complicate my build process with mixed code.)
  1729.  
  1730. Anyone have any ideas? (What does DTS think?)
  1731.  
  1732. --
  1733. Roger Pantos                 Telesis North, Inc.           telesisnorth
  1734. Mac Software Guy             telesis@ecf.toronto.edu       (AppleLink)
  1735. "They want better products for free."  -- from "Dilbert"
  1736.  
  1737. +++++++++++++++++++++++++++
  1738.  
  1739. >From jumplong@aol.com (Jump Long)
  1740. Date: 24 Nov 1994 23:55:12 -0500
  1741. Organization: America Online, Inc. (1-800-827-6364)
  1742.  
  1743. In article <CzsqDw.2rq@ecf.toronto.edu>, telesis@ecf.toronto.edu (Telesis
  1744. North) writes:
  1745.  
  1746. >My problem is that I have to write a completion routine for the serial 
  1747. >driver. I would _really_ like to get access to the parameter block; 
  1748. >unfortunately, it's not passed as a parameter. (That would be too 
  1749. >sensible.)
  1750. >
  1751. > (a bunch ommitted )
  1752. >
  1753. > Anyone have any ideas? (What does DTS think?)
  1754.  
  1755. Look in Files.h and you'll find what you need for IOCompletion routines.
  1756. If you're compiling native, the parameter block pointer is passed to your
  1757. completion routine as a parameter.
  1758.  
  1759. However, for the time being I'd leave completion routines in 68K code
  1760. because the Device Manager is still emulated 68K code.  You'd have the
  1761. overhead of a couple of mixed mode switches if your completion routine was
  1762. written in PowerPC code.  Since you shouldn't be doing processor intensive
  1763. processing at completion time anyway, writing PowerPC completion routines
  1764. shouldn't help your performance (and quite possibly will hurt it under
  1765. System 7).
  1766.  
  1767. - Jim Luther
  1768.  
  1769. +++++++++++++++++++++++++++
  1770.  
  1771. >From paul@architecture.mcgill.ca (Paul Lalonde)
  1772. Date: Fri, 25 Nov 1994 07:46:39 -0400
  1773. Organization: McGill University School of Architecture
  1774.  
  1775. In article <CzsqDw.2rq@ecf.toronto.edu>, telesis@ecf.toronto.edu (Telesis
  1776. North) wrote:
  1777.  
  1778. > Does anyone out there have a good strategy for writing completion routines 
  1779. > that compile for both PPC and 68K?
  1780. > My problem is that I have to write a completion routine for the serial 
  1781. > driver. I would _really_ like to get access to the parameter block; 
  1782. > unfortunately, it's not passed as a parameter. (That would be too 
  1783. > sensible.)
  1784.  
  1785.  
  1786. If you're using CodeWarrior, you can declare a function argument as residing 
  1787. in a register (68K only). You would then have a slightly different function 
  1788. declaration for your completion proc, depending if you're compiling for the 
  1789. PPC or not:
  1790.  
  1791. #if USESCODEFRAGMENTS
  1792. extern void  MyCompletionProc(ParmBlkPtr pbPtr);
  1793. #else
  1794. extern void MyCompletionProc(ParmBlkPtr pbPtr : __A0);
  1795. #endif
  1796.  
  1797.  
  1798. And the code would look like this:
  1799.  
  1800.  
  1801. #if USESCODEFRAGMENTS
  1802. void  MyCompletionProc(ParmBlkPtr pbPtr)
  1803. #else
  1804. void MyCompletionProc(ParmBlkPtr pbPtr : __A0)
  1805. #endif
  1806. {
  1807.    ParmBlkPtr   pb  = pbPtr;
  1808.    
  1809.    // do stuff here -- don't forget to set up A5!
  1810. }
  1811.  
  1812.  
  1813. Hope this helps
  1814.  
  1815. Paul Lalonde
  1816. lalonde@metrowerks.ca
  1817.  
  1818. +++++++++++++++++++++++++++
  1819.  
  1820. >From h+@metrowerks.com (Jon W{tte)
  1821. Date: Sat, 26 Nov 1994 15:59:48 +0100
  1822. Organization: The Conspiracy
  1823.  
  1824. In article <CzsqDw.2rq@ecf.toronto.edu>,
  1825. telesis@ecf.toronto.edu (Telesis North) wrote:
  1826.  
  1827. >My problem is that I have to write a completion routine for the serial 
  1828. >driver. I would _really_ like to get access to the parameter block; 
  1829. >unfortunately, it's not passed as a parameter. (That would be too 
  1830. >sensible.)
  1831.  
  1832. Oh, but on the PowerPC runtime architecture, it IS passed as a 
  1833. parameter. And you can force the compiler to use a parameter in 
  1834. A0 under 68K by using #pragma parameter. So your callback can 
  1835. have a declaration like any function, with a 
  1836. pointer-to-param-block argument.
  1837.  
  1838. >For 68K, A0 comes in pointing to the PB, and a bit of assembly will put it 
  1839. >into a local variable. Clearly this isn't going to work on a PowerMac.
  1840.  
  1841. The PowerMacs have one, well-defined calling convention, used 
  1842. *everywhere*
  1843.  
  1844. >(I realize that I could leave the completion routine as 68K without a 
  1845. >significant performance hit - at least until Copland - but I'd prefer not 
  1846. >to complicate my build process with mixed code.)
  1847.  
  1848. Not only that, but you'll SEE a large performance hit for the 
  1849. NATIVE callback, because the serial drivers are 68K code.
  1850.  
  1851. You can of course build a routine descriptor that describes the 
  1852. calling convention of the callback and use that.
  1853.  
  1854. Cheers,
  1855.  
  1856.                     / h+
  1857.  
  1858.  
  1859. --
  1860.   Jon W‰tte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
  1861.  ~r ~/.signature
  1862.  
  1863.  
  1864. ---------------------------
  1865.  
  1866. >From chopps@water.emich.edu (Christian E. Hopps)
  1867. Subject: oops..
  1868. Date: 20 Nov 1994 09:27:55 GMT
  1869. Organization: University of Michigan EECS Dept.
  1870.  
  1871. I caught myself (luckily) making a big mistake today.
  1872.  
  1873. void
  1874. func(SomeHandle joe)
  1875. {
  1876.     (**joe).j_rgn = NewRgn();    /* bug */
  1877.  
  1878. I think this should be in the FAQ regarding handles.  Not many
  1879. programmers (I think) deal with Order of Evaluation issues like
  1880. this one.  At least for me, handles are something new and so
  1881. the above code didn't seem bad.
  1882.  
  1883. Incase you haven't caught the bug (its probably patently obviuos
  1884. to long time mac people).  NewRgn() will move memory (or so
  1885. you should assume) and C (most languages?), except in the case of
  1886. &&, ||, comma, and ?:, does not specify order of evaluation.
  1887. Therefore assuming worst case, the compiler evaluates the handle,
  1888. i.e. locates the memory to store to and then calls NewRgn().  Finally
  1889. it stores the result in the afore mentioned memory.  Oops except
  1890. NewRgn() moved memory so the result is stored in bogusville.
  1891.  
  1892. Thus the proper thing to do is:
  1893.     RgnHandle rh;
  1894.  
  1895.     rh = NewRgn();
  1896.     (**joe).j_rgn = rh;
  1897.  
  1898. Things like ap[i] = i++; are obvious to me.  Being new to handles
  1899. however hid the order of evaluation issue from me.  Maybe this should
  1900. go in the FAQ?
  1901.  
  1902. Chris.
  1903.  
  1904. +++++++++++++++++++++++++++
  1905.  
  1906. >From stk@dobag.in-berlin.de (Stefan Kurth)
  1907. Date: 21 Nov 1994 00:34:28 +0100
  1908. Organization: none
  1909.  
  1910. In article <3an4qr$q7s@zip.eecs.umich.edu>, chopps@water.emich.edu
  1911. (Christian E. Hopps) wrote:
  1912.  
  1913. > void
  1914. > func(SomeHandle joe)
  1915. > {
  1916. >       (**joe).j_rgn = NewRgn();       /* bug */
  1917. >
  1918. > I think this should be in the FAQ regarding handles.
  1919.  
  1920. There's an explicit warning about this in Inside Macintosh (both the old
  1921. IM Vol I and NIM:Memory).
  1922.  
  1923. BTW, I'd strongly suggest to get yourself a copy of QC; it does a
  1924. terrific job at finding such bugs for you (and many others too).  A demo
  1925. is available at the common Mac archives, the full version is something
  1926. like $99.  Well worth the money.
  1927.  
  1928. ________________________________________________________________________
  1929. Stefan Kurth             Berlin, Germany          stk@dobag.in-berlin.de
  1930.  
  1931. +++++++++++++++++++++++++++
  1932.  
  1933. >From asunta@convex.csc.FI (Miika Asunta)
  1934. Date: 24 Nov 1994 23:15:23 GMT
  1935. Organization: Sibelius Academy, Helsinki
  1936.  
  1937. In <3an4qr$q7s@zip.eecs.umich.edu> chopps@water.emich.edu (Christian E. Hopps) writes:
  1938.  
  1939. >I caught myself (luckily) making a big mistake today.
  1940.  
  1941. >void
  1942. >func(SomeHandle joe)
  1943. >{
  1944. >    (**joe).j_rgn = NewRgn();    /* bug */
  1945.  
  1946. >Thus the proper thing to do is:
  1947. >    RgnHandle rh;
  1948.  
  1949. >    rh = NewRgn();
  1950. >    (**joe).j_rgn = rh;
  1951.  
  1952. Or as well:
  1953.  
  1954. MoveHHi(joe); HLock(joe);
  1955. (**joe).j_rgn = NewRgn();
  1956. HUnlock(joe);
  1957. --
  1958. Miika Asunta
  1959. asunta@convex.csc.fi            Double Bass Player
  1960. tel. +358-31-255 9461            Macintosh Programmer
  1961.  
  1962. +++++++++++++++++++++++++++
  1963.  
  1964. >From chopps@water.emich.edu (Christian E. Hopps)
  1965. Date: 25 Nov 1994 05:40:49 GMT
  1966. Organization: University of Michigan EECS Dept.
  1967.  
  1968. Miika Asunta (asunta@convex.csc.FI) wrote:
  1969. : In <3an4qr$q7s@zip.eecs.umich.edu> chopps@water.emich.edu (Christian E. Hopps) writes:
  1970.  
  1971. : >I caught myself (luckily) making a big mistake today.
  1972.  
  1973. : >void
  1974. : >func(SomeHandle joe)
  1975. : >{
  1976. : >    (**joe).j_rgn = NewRgn();    /* bug */
  1977.  
  1978. : >Thus the proper thing to do is:
  1979. : >    RgnHandle rh;
  1980.  
  1981. : >    rh = NewRgn();
  1982. : >    (**joe).j_rgn = rh;
  1983.  
  1984. : Or as well:
  1985.  
  1986. : MoveHHi(joe); HLock(joe);
  1987. : (**joe).j_rgn = NewRgn();
  1988. : HUnlock(joe);
  1989.  
  1990. Have you profiled that?  I recommend highly that you do it my way. :)
  1991.  
  1992. Chris.
  1993.  
  1994. ---------------------------
  1995.  
  1996. End of C.S.M.P. Digest
  1997. **********************
  1998.  
  1999.  
  2000.