Kaydet (Commit) c4f169cc authored tarafından Sjoerd Mullender's avatar Sjoerd Mullender

rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.

	Does not need any SGI-specific libraries.
cgen.py, cstubs, Makefile: Generate glmodule.c differently so that it
	can be compiled using an ANSI compiler.
üst 7030b1ff
...@@ -59,7 +59,7 @@ return_types = ['void', 'short', 'long'] ...@@ -59,7 +59,7 @@ return_types = ['void', 'short', 'long']
# Allowed function argument types # Allowed function argument types
# #
arg_types = ['char', 'string', 'short', 'float', 'long', 'double'] arg_types = ['char', 'string', 'short', 'u_short', 'float', 'long', 'double']
# Need to classify arguments as follows # Need to classify arguments as follows
...@@ -111,6 +111,8 @@ def checkarg(type, arg): ...@@ -111,6 +111,8 @@ def checkarg(type, arg):
# #
if type not in arg_types: if type not in arg_types:
raise arg_error, ('bad type', type) raise arg_error, ('bad type', type)
if type[:2] == 'u_':
type = 'unsigned ' + type[2:]
# #
# Split it in the mode (first character) and the rest. # Split it in the mode (first character) and the rest.
# #
...@@ -157,7 +159,7 @@ def checkarg(type, arg): ...@@ -157,7 +159,7 @@ def checkarg(type, arg):
# size is retval -- must be a reply argument # size is retval -- must be a reply argument
if mode <> 'r': if mode <> 'r':
raise arg_error, ('non-r mode with [retval]', mode) raise arg_error, ('non-r mode with [retval]', mode)
elif sub[:3] <> 'arg' or not isnum(sub[3:]): elif not isnum(sub) and (sub[:3] <> 'arg' or not isnum(sub[3:])):
raise arg_error, ('bad subscript', sub) raise arg_error, ('bad subscript', sub)
# #
return type, mode, num, sub return type, mode, num, sub
...@@ -214,10 +216,16 @@ def generate(type, func, database): ...@@ -214,10 +216,16 @@ def generate(type, func, database):
for i in range(len(database)): for i in range(len(database)):
a_type, a_mode, a_factor, a_sub = database[i] a_type, a_mode, a_factor, a_sub = database[i]
print '\t' + a_type, print '\t' + a_type,
if a_sub: brac = ket = ''
print '*', if a_sub and not isnum(a_sub):
print 'arg' + `i+1`, if a_factor:
if a_factor and not a_sub: brac = '('
ket = ')'
print brac + '*',
print 'arg' + `i+1` + ket,
if a_sub and isnum(a_sub):
print '[', a_sub, ']',
if a_factor:
print '[', a_factor, ']', print '[', a_factor, ']',
print ';' print ';'
# #
...@@ -250,6 +258,10 @@ def generate(type, func, database): ...@@ -250,6 +258,10 @@ def generate(type, func, database):
# #
for i in range(len(database)): for i in range(len(database)):
a_type, a_mode, a_factor, a_sub = database[i] a_type, a_mode, a_factor, a_sub = database[i]
if a_type[:9] == 'unsigned ':
xtype = a_type[9:]
else:
xtype = a_type
if a_mode == 'i': if a_mode == 'i':
# #
# Implicit argument; # Implicit argument;
...@@ -258,9 +270,11 @@ def generate(type, func, database): ...@@ -258,9 +270,11 @@ def generate(type, func, database):
# #
j = eval(a_sub) j = eval(a_sub)
print '\tif', print '\tif',
print '(!geti' + a_type + 'arraysize(args,', print '(!geti' + xtype + 'arraysize(args,',
print `n_in_args` + ',', print `n_in_args` + ',',
print `in_pos[j]` + ',', print `in_pos[j]` + ',',
if xtype <> a_type:
print '('+xtype+' *)',
print '&arg' + `i+1` + '))' print '&arg' + `i+1` + '))'
print '\t\treturn NULL;' print '\t\treturn NULL;'
if a_factor: if a_factor:
...@@ -268,25 +282,34 @@ def generate(type, func, database): ...@@ -268,25 +282,34 @@ def generate(type, func, database):
print '= arg' + `i+1`, print '= arg' + `i+1`,
print '/', a_factor + ';' print '/', a_factor + ';'
elif a_mode == 's': elif a_mode == 's':
if a_sub: # Allocate memory for varsize array if a_sub and not isnum(a_sub):
# Allocate memory for varsize array
print '\tif ((arg' + `i+1`, '=', print '\tif ((arg' + `i+1`, '=',
print 'NEW(' + a_type + ',', if a_factor:
if a_factor: print a_factor, '*', print '('+a_type+'(*)['+a_factor+'])',
print 'NEW(' + a_type, ',',
if a_factor:
print a_factor, '*',
print a_sub, ')) == NULL)' print a_sub, ')) == NULL)'
print '\t\treturn err_nomem();' print '\t\treturn err_nomem();'
print '\tif', print '\tif',
if a_factor or a_sub: # Get a fixed-size array array if a_factor or a_sub: # Get a fixed-size array array
print '(!geti' + a_type + 'array(args,', print '(!geti' + xtype + 'array(args,',
print `n_in_args` + ',', print `n_in_args` + ',',
print `in_pos[i]` + ',', print `in_pos[i]` + ',',
if a_factor: print a_factor, if a_factor: print a_factor,
if a_factor and a_sub: print '*', if a_factor and a_sub: print '*',
if a_sub: print a_sub, if a_sub: print a_sub,
print ', arg' + `i+1` + '))' print ',',
if (a_sub and a_factor) or xtype <> a_type:
print '('+xtype+' *)',
print 'arg' + `i+1` + '))'
else: # Get a simple variable else: # Get a simple variable
print '(!geti' + a_type + 'arg(args,', print '(!geti' + xtype + 'arg(args,',
print `n_in_args` + ',', print `n_in_args` + ',',
print `in_pos[i]` + ',', print `in_pos[i]` + ',',
if xtype <> a_type:
print '('+xtype+' *)',
print '&arg' + `i+1` + '))' print '&arg' + `i+1` + '))'
print '\t\treturn NULL;' print '\t\treturn NULL;'
# #
...@@ -314,7 +337,7 @@ def generate(type, func, database): ...@@ -314,7 +337,7 @@ def generate(type, func, database):
# #
for i in range(len(database)): for i in range(len(database)):
a_type, a_mode, a_factor, a_sub = database[i] a_type, a_mode, a_factor, a_sub = database[i]
if a_mode == 's' and a_sub: if a_mode == 's' and a_sub and not isnum(a_sub):
print '\tDEL(arg' + `i+1` + ');' print '\tDEL(arg' + `i+1` + ');'
# #
# Return # Return
...@@ -373,12 +396,21 @@ def generate(type, func, database): ...@@ -373,12 +396,21 @@ def generate(type, func, database):
# Subroutine to return a function call to mknew<type>object(<arg>) # Subroutine to return a function call to mknew<type>object(<arg>)
# #
def mkobject(type, arg): def mkobject(type, arg):
if type[:9] == 'unsigned ':
type = type[9:]
return 'mknew' + type + 'object((' + type + ') ' + arg + ')'
return 'mknew' + type + 'object(' + arg + ')' return 'mknew' + type + 'object(' + arg + ')'
# Open optional file argument defined_archs = []
if sys.argv[1:]:
sys.stdin = open(sys.argv[1], 'r') # usage: cgen [ -Dmach ... ] [ file ]
for arg in sys.argv[1:]:
if arg[:2] == '-D':
defined_archs.append(arg[2:])
else:
# Open optional file argument
sys.stdin = open(arg, 'r')
# Input line number # Input line number
...@@ -426,9 +458,19 @@ while 1: ...@@ -426,9 +458,19 @@ while 1:
functions.append(func) functions.append(func)
else: else:
print line print line
elif not words: continue
pass # skip empty line if not words:
elif words[0] == '#include': continue # skip empty line
elif words[0] == 'if':
# if XXX rest
# if !XXX rest
if words[1][0] == '!':
if words[1][1:] in defined_archs:
continue
elif words[1] not in defined_archs:
continue
words = words[2:]
if words[0] == '#include':
print line print line
elif words[0][:1] == '#': elif words[0][:1] == '#':
pass # ignore comment pass # ignore comment
......
...@@ -299,6 +299,9 @@ extern void initXlib(); ...@@ -299,6 +299,9 @@ extern void initXlib();
#ifdef USE_PARSER #ifdef USE_PARSER
extern void initparser(); extern void initparser();
#endif #endif
#ifdef USE_RGBIMG
extern void initrgbimg();
#endif
/* -- ADDMODULE MARKER 1 -- */ /* -- ADDMODULE MARKER 1 -- */
struct { struct {
...@@ -482,6 +485,10 @@ struct { ...@@ -482,6 +485,10 @@ struct {
{"parser", initparser}, {"parser", initparser},
#endif #endif
#ifdef USE_RGBIMG
{"rgbimg", initrgbimg},
#endif
/* -- ADDMODULE MARKER 2 -- */ /* -- ADDMODULE MARKER 2 -- */
{0, 0} /* Sentinel */ {0, 0} /* Sentinel */
......
...@@ -22,7 +22,13 @@ Each definition must be contained on one line: ...@@ -22,7 +22,13 @@ Each definition must be contained on one line:
argI argI
retval retval
N*argI N*argI
N*I
N*retval N*retval
In the case where the subscript consists of two parts
separated by *, the first part is the width of the matrix, and
the second part is the length of the matrix. This order is
opposite from the order used in C to declare a two-dimensional
matrix.
*/ */
/* /*
...@@ -847,7 +853,7 @@ gl_gversion(self, args) ...@@ -847,7 +853,7 @@ gl_gversion(self, args)
%% %%
long getshade long getshade
void devport short s long s if !solaris void devport short s long s
void rdr2i long s long s void rdr2i long s long s
void rectfs short s short s short s short s void rectfs short s short s short s short s
void rects short s short s short s short s void rects short s short s short s short s
...@@ -888,7 +894,7 @@ void textinit ...@@ -888,7 +894,7 @@ void textinit
void initnames void initnames
void pclos void pclos
void popname void popname
void spclos if !solaris void spclos
void zclear void zclear
void screenspace void screenspace
void reshapeviewport void reshapeviewport
...@@ -896,9 +902,9 @@ void winpush ...@@ -896,9 +902,9 @@ void winpush
void winpop void winpop
void foreground void foreground
void endfullscrn void endfullscrn
void endpupmode if !solaris void endpupmode
void fullscrn void fullscrn
void pupmode if !solaris void pupmode
void winconstraints void winconstraints
void pagecolor short s void pagecolor short s
void textcolor short s void textcolor short s
...@@ -910,7 +916,7 @@ void setlinestyle short s ...@@ -910,7 +916,7 @@ void setlinestyle short s
void setmap short s void setmap short s
void swapinterval short s void swapinterval short s
void writemask short s void writemask short s
void textwritemask short s if !solaris void textwritemask short s
void qdevice short s void qdevice short s
void unqdevice short s void unqdevice short s
void curvebasis short s void curvebasis short s
...@@ -919,9 +925,9 @@ void loadname short s ...@@ -919,9 +925,9 @@ void loadname short s
void passthrough short s void passthrough short s
void pushname short s void pushname short s
void setmonitor short s void setmonitor short s
void setshade short s if !solaris void setshade short s
void setpattern short s void setpattern short s
void pagewritemask short s if !solaris void pagewritemask short s
# #
void callobj long s void callobj long s
void delobj long s void delobj long s
...@@ -942,7 +948,7 @@ void freepup long s ...@@ -942,7 +948,7 @@ void freepup long s
# #
void backbuffer long s void backbuffer long s
void frontbuffer long s void frontbuffer long s
void lsbackup long s if !solaris void lsbackup long s
void resetls long s void resetls long s
void lampon long s void lampon long s
void lampoff long s void lampoff long s
...@@ -1003,13 +1009,13 @@ void rpdr2 float s float s ...@@ -1003,13 +1009,13 @@ void rpdr2 float s float s
void rpmv2 float s float s void rpmv2 float s float s
void xfpt2 float s float s void xfpt2 float s float s
# #
void loadmatrix float s[16] void loadmatrix float s[4*4]
# Really [4][4] # Really [4][4]
void multmatrix float s[16] void multmatrix float s[4*4]
# Really [4][4] # Really [4][4]
void crv float s[12] void crv float s[3*4]
# Really [4][3] # Really [4][3]
void rcrv float s[16] void rcrv float s[4*4]
# Really [4][4] # Really [4][4]
# #
# Methods that have strings. # Methods that have strings.
...@@ -1040,12 +1046,12 @@ void polfs long s short s[3*arg1] ...@@ -1040,12 +1046,12 @@ void polfs long s short s[3*arg1]
void polys long s short s[3*arg1] void polys long s short s[3*arg1]
void poly2s long s short s[2*arg1] void poly2s long s short s[2*arg1]
# #
void defcursor short s short s[128] void defcursor short s u_short s[128]
# Is this useful? # Is this useful?
void writepixels short s short s[arg1] void writepixels short s u_short s[arg1]
# Should be unsigned short... # Should be unsigned short...
void defbasis long s float s[16] void defbasis long s float s[4*4]
void gewrite short s short s[arg1] if !solaris void gewrite short s short s[arg1]
# #
void rotate short s char s void rotate short s char s
# This is not in the library!? # This is not in the library!?
...@@ -1103,16 +1109,16 @@ void xfpts short s short s short s ...@@ -1103,16 +1109,16 @@ void xfpts short s short s short s
void curorigin short s short s short s void curorigin short s short s short s
void cyclemap short s short s short s void cyclemap short s short s short s
# #
void patch float s[16] float s[16] float s[16] void patch float s[4*4] float s[4*4] float s[4*4]
void splf long s float s[3*arg1] short s[arg1] void splf long s float s[3*arg1] u_short s[arg1]
void splf2 long s float s[2*arg1] short s[arg1] void splf2 long s float s[2*arg1] u_short s[arg1]
void splfi long s long s[3*arg1] short s[arg1] void splfi long s long s[3*arg1] u_short s[arg1]
void splf2i long s long s[2*arg1] short s[arg1] void splf2i long s long s[2*arg1] u_short s[arg1]
void splfs long s short s[3*arg1] short s[arg1] void splfs long s short s[3*arg1] u_short s[arg1]
void splf2s long s short s[2*arg1] short s[arg1] void splf2s long s short s[2*arg1] u_short s[arg1]
###void defpattern short s short s short s[arg2*arg2/16] ###void defpattern short s short s u_short s[arg2*arg2/16]
# #
void rpatch float s[16] float s[16] float s[16] float s[16] void rpatch float s[4*4] float s[4*4] float s[4*4] float s[4*4]
# #
# routines that send 4 floats # routines that send 4 floats
# #
...@@ -1154,7 +1160,7 @@ void polarview float s short s short s short s ...@@ -1154,7 +1160,7 @@ void polarview float s short s short s short s
void arcfs short s short s short s short s short s void arcfs short s short s short s short s short s
void arcs short s short s short s short s short s void arcs short s short s short s short s short s
void rectcopy short s short s short s short s short s short s void rectcopy short s short s short s short s short s short s
void RGBcursor short s short s short s short s short s short s short s if !solaris void RGBcursor short s short s short s short s short s short s short s
# #
long getbutton short s long getbutton short s
long getcmmode long getcmmode
...@@ -1198,7 +1204,7 @@ void getcpos short r short r ...@@ -1198,7 +1204,7 @@ void getcpos short r short r
void getsize long r long r void getsize long r long r
void getorigin long r long r void getorigin long r long r
void getviewport short r short r short r short r void getviewport short r short r short r short r
void gettp short r short r short r short r if !solaris void gettp short r short r short r short r
void getgpos float r float r float r float r void getgpos float r float r float r float r
void winposition long s long s long s long s void winposition long s long s long s long s
void gRGBcolor short r short r short r void gRGBcolor short r short r short r
...@@ -1210,7 +1216,7 @@ void mapw long s short s short s float r float r float r float r float r float ...@@ -1210,7 +1216,7 @@ void mapw long s short s short s float r float r float r float r float r float
void mapw2 long s short s short s float r float r void mapw2 long s short s short s float r float r
###void defrasterfont short s short s short s Fontchar s[arg3] short s short s[4*arg5] ###void defrasterfont short s short s short s Fontchar s[arg3] short s short s[4*arg5]
###long qread short r ###long qread short r
void getcursor short r short r short r long r void getcursor short r u_short r u_short r long r
# #
# For these we receive arrays of stuff # For these we receive arrays of stuff
# #
...@@ -1241,7 +1247,7 @@ void mmode long s ...@@ -1241,7 +1247,7 @@ void mmode long s
void normal float s[3] void normal float s[3]
void overlay long s void overlay long s
void RGBrange short s short s short s short s short s short s short s short s void RGBrange short s short s short s short s short s short s short s short s
void setvideo long s long s if !solaris void setvideo long s long s
void shademodel long s void shademodel long s
void underlay long s void underlay long s
# #
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment