home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-075 < prev    next >
Encoding:
Internet Message Format  |  1995-06-07  |  73.9 KB  |  [TEXT/R*ch]

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