ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/modobject.c
(Generate patch)

Comparing ray/src/common/modobject.c (file contents):
Revision 1.1 by greg, Wed Jul 24 12:04:52 1991 UTC vs.
Revision 2.3 by greg, Mon Feb 12 17:14:59 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  "object.h"
14  
15 + #include  "otypes.h"
16  
17 +
18   extern int  (*addobjnotify[])();        /* people to notify of new objects */
19  
20   static struct ohtab {
# Line 20 | Line 22 | static struct ohtab {
22          OBJECT  *htab;                  /* table, if allocated */
23   }  modtab = {100, NULL}, objtab = {1000, NULL}; /* modifiers and objects */
24  
25 + static int  otndx();
26  
27 < #ifdef  GETOBJ
27 >
28   int
29 < object(oname)                   /* get an object number from its name */
30 < char  *oname;
29 > objndx(op)                      /* get object number from pointer */
30 > register OBJREC  *op;
31   {
32 <        register int  ndx;
32 >        register int  i, j;
33  
34 <        ndx = otndx(oname, &objtab);
35 <        return(objtab.htab[ndx]);
34 >        for (i = nobjects>>6; i >= 0; i--) {
35 >                j = op - objblock[i];
36 >                if (j >= 0 && j < 077)
37 >                        return((i<<6) + j);
38 >        }
39 >        return(OVOID);
40   }
34 #endif
41  
42  
43   int
44 + lastmod(obj, mname)             /* find modifier definition before obj */
45 + OBJECT  obj;
46 + char  *mname;
47 + {
48 +        register OBJREC  *op;
49 +        register int  i;
50 +
51 +        for (i = obj; i-- > 0; ) {
52 +                op = objptr(i);
53 +                if (ismodifier(op->otype) && !strcmp(op->oname, mname))
54 +                        return(i);
55 +        }
56 +        return(OVOID);
57 + }
58 +
59 +
60 + int
61   modifier(mname)                 /* get a modifier number from its name */
62   char  *mname;
63   {
# Line 45 | Line 68 | char  *mname;
68   }
69  
70  
71 + #ifdef  GETOBJ
72 + int
73 + object(oname)                   /* get an object number from its name */
74 + char  *oname;
75 + {
76 +        register int  ndx;
77 +
78 +        ndx = otndx(oname, &objtab);
79 +        return(objtab.htab[ndx]);
80 + }
81 + #endif
82 +
83 +
84   insertobject(obj)               /* insert new object into our list */
85   register OBJECT  obj;
86   {
87          register int  i;
88  
53 #ifdef  GETOBJ
54        i = otndx(objptr(obj)->oname, &objtab);
55        objtab.htab[i] = obj;
56 #endif
89          if (ismodifier(objptr(obj)->otype)) {
90                  i = otndx(objptr(obj)->oname, &modtab);
91                  modtab.htab[i] = obj;
92          }
93 + #ifdef  GETOBJ
94 +        else {
95 +                i = otndx(objptr(obj)->oname, &objtab);
96 +                objtab.htab[i] = obj;
97 +        }
98 + #endif
99          for (i = 0; addobjnotify[i] != NULL; i++)
100                  (*addobjnotify[i])(obj);
101   }
# Line 76 | Line 114 | int  oldsiz;
114                  if (*hsp > oldsiz)
115                          return(*hsp);
116          return(oldsiz*2 + 1);           /* not always prime */
79 }
80
81
82 static int
83 shash(s)                        /* hash a string */
84 register char  *s;
85 {
86        register int  h = 0;
87
88        while (*s)
89                h = (h<<1 & 0x7fff) ^ *s++;
90        return(h);
117   }
118  
119  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines