From: Tim R. <ti...@us...> - 2004-09-11 20:42:10
|
Update of /cvsroot/csdopenglnet/csdOpenGL/generator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25560/generator Modified Files: Makefile function.cs Log Message: generator now produces buffer attribute for callbacks Index: function.cs =================================================================== RCS file: /cvsroot/csdopenglnet/csdOpenGL/generator/function.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** function.cs 11 Sep 2004 19:36:36 -0000 1.6 --- function.cs 11 Sep 2004 20:41:58 -0000 1.7 *************** *** 25,28 **** --- 25,32 ---- */ protected ArrayList list; + + protected ArrayList listWrap; + protected SortedList attrList; + /** \brief to resolve user defined types * *************** *** 37,40 **** --- 41,46 ---- protected string lib; + protected bool isCallback = false; + protected string dllFlags; protected string dllAttr; *************** *** 78,81 **** --- 84,90 ---- baseTypes.Add( "ulong" ); + listWrap = new ArrayList(); + attrList = new SortedList(); + Debug.WriteLine( "Exiting Function.Function(StreamWriter)" ); Debug.Unindent(); *************** *** 92,98 **** --- 101,109 ---- if ( name==typedef.processName(name) ) { if ( (s.IndexOf( '(' ) >= 0) || (s.IndexOf(')')>=0) ) { // decided whether if complex type + isCallback = true; typedef.addCallBack( s, name, c ); return typedef.cbParamSet( name, c ); } else { // or standard type + isCallback = false; int i = s.LastIndexOf( ' ' ); // find crossover between type and name if ( i >= 0 ) { // is type+id *************** *** 214,219 **** --- 225,234 ---- ArrayList p; ParamSet ps = null; + bool isCB = false; + string t; + string n; while ( e.MoveNext() ) { // cycle thorugh function list and procerss types and names + isCB = false; fs = (FunctionSet)e.Current; p = new ArrayList(); *************** *** 221,224 **** --- 236,240 ---- for ( int i=0; i<fs.parameters.Count; i++ ) { ps = processParam( (string)(fs.parameters[i]), fs.name, i ); + isCB = isCB || isCallback; if (ps!=null) { p.Add( ps ); *************** *** 226,231 **** } ! ! fs2 = new FunctionSet( typedef.processType( fs.type ), typedef.processName( fs.name ), p ); list.Add( fs2 ); removeIntPtr( fs2 ); --- 242,253 ---- } ! t = typedef.processType( fs.type ); ! n = typedef.processName( fs.name ); ! if (isCB) { ! addWrapper( t, n, p ); ! fs2 = new FunctionSet( t, "__"+n, p ); ! } else { ! fs2 = new FunctionSet( t, n, p ); ! } list.Add( fs2 ); removeIntPtr( fs2 ); *************** *** 237,240 **** --- 259,271 ---- } + protected void addWrapper( string t, string n, ArrayList p ) { + listWrap.Add( new FunctionSet( t, n, p ) ); + ParamSet ps; + for ( int i=0; i<p.Count; i++ ) { + ps = (ParamSet)p[i]; + attrList.Add( "par_"+n+i.ToString(), ps.type ); + } + } + protected void removeIntPtr( FunctionSet fs ) { FunctionSet f; *************** *** 278,287 **** Debug.WriteLine( "Entering Functions.write()" ); ! Console.WriteLine( "Writing function statements" ); ! ! IEnumerator e = list.GetEnumerator(); FunctionSet fs; ParamSet ps; while ( e.MoveNext() ) { fs = (FunctionSet)e.Current; --- 309,366 ---- Debug.WriteLine( "Entering Functions.write()" ); ! IDictionaryEnumerator s = attrList.GetEnumerator(); ! while ( s.MoveNext() ) { ! writer.Write( " private static " ); ! writer.Write( (string)s.Value ); ! writer.Write( " " ); ! writer.Write( (string)s.Key ); ! writer.Write( ";\n" ); ! } ! ! IEnumerator e = listWrap.GetEnumerator(); FunctionSet fs; ParamSet ps; + while ( e.MoveNext() ) { + fs = (FunctionSet)e.Current; + + writer.Write( " public static " ); + writer.Write( fs.type ); + writer.Write( " " ); + writer.Write( fs.name ); + + writer.Write( "( " ); + for (int i=0; i<fs.parameters.Count; i++ ) { + ps = (ParamSet)fs.parameters[i]; + writer.Write( ps.type ); + writer.Write( " " ); + writer.Write( ps.name ); + if (i<fs.parameters.Count-1) writer.Write( ", " ); + } + writer.WriteLine( " ) {" ); + for ( int i=0; i<fs.parameters.Count; i++ ) { + ps = (ParamSet)fs.parameters[i]; + writer.WriteLine( " " ); + writer.WriteLine( "par_"+fs.name+i.ToString() ); + writer.WriteLine( " = " ); + writer.WriteLine( ps.name ); + writer.WriteLine( ";\n" ); + } + writer.Write( " " ); + if ( fs.type != "void" ) writer.Write( "return " ); + writer.Write( "__"); + writer.Write( fs.name ); + writer.Write( "( " ); + for (int i=0; i<fs.parameters.Count; i++ ) { + ps = (ParamSet)fs.parameters[i]; + writer.Write( "par_"+fs.name+i.ToString() ); + if (i<fs.parameters.Count-1) writer.Write( ", " ); + } + writer.Write( " );" ); + writer.WriteLine( " }" ); + + } + Console.WriteLine( "Writing function statements" ); + e = list.GetEnumerator(); while ( e.MoveNext() ) { fs = (FunctionSet)e.Current; Index: Makefile =================================================================== RCS file: /cvsroot/csdopenglnet/csdOpenGL/generator/Makefile,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile 11 Sep 2004 17:26:19 -0000 1.12 --- Makefile 11 Sep 2004 20:41:58 -0000 1.13 *************** *** 3,7 **** CC=mcs DEBUG=/d:DEBUG ! #DEBUG= OPTS=$(DEBUG) MCS=$(CC) $(OPTS) --- 3,7 ---- CC=mcs DEBUG=/d:DEBUG ! DEBUG= OPTS=$(DEBUG) MCS=$(CC) $(OPTS) |