home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / bob / !ArmBob / progs / h / draw / object < prev   
Encoding:
Text File  |  1994-12-29  |  1.2 KB  |  67 lines

  1. /*******************************************************
  2.  *                                                     *
  3.  *  draw.object Library        GCW  27/12/94           *
  4.  *                                                     *
  5.  *******************************************************/
  6.  
  7. /* ------------ object class -------------------- */
  8.  
  9. /* Base class for storing data in string arrays   */
  10.  
  11. class object
  12. {
  13.  obj_end, obj_start,obj_string, p;
  14. }
  15.  
  16. /* ----------- Object methods ----------------- */
  17.  
  18. object::object(size)
  19. {
  20.  if (!typeof(p))
  21.  {
  22.     p = obj_start = @(obj_string = newstring(size));     // first object
  23.     obj_end = obj_start + size;
  24.  }
  25.  return this;
  26. }
  27.  
  28. object::start()
  29. { return obj_start; }
  30.  
  31. object::str()
  32. { return obj_string; }
  33.  
  34. object::here()
  35. { return p; }
  36.  
  37. object::push_word(w)
  38.  ££(p,w);
  39.  p += 4;
  40.  if (p >= obj_end)
  41.     quit("overflow\n");
  42. }
  43.  
  44. object::push_byte(c)
  45. {
  46.  ``(p++,c);
  47.  if (p >= obj_end)
  48.     quit("overflow\n");
  49. }
  50.  
  51. object::push_string(s)
  52. {
  53.  local len;
  54.  if (p + (len = sizeof(s)) >= obj_end)
  55.     quit("overflow\n");
  56.  $$(p,s); p += len;    
  57. }
  58.  
  59. object::read(offset)
  60. { return £(obj_start+offset); }
  61.  
  62. object::write(offset,data)
  63. { ££(obj_start+offset,data); }
  64.  
  65. /* ------------ end of object definitions ------------- */
  66.