2 using System
.Collections
.Generic
;
6 namespace glstubgenerator
12 public string Register
;
15 class ArgumentList
: List
<Argument
>
21 public string ReturnType
;
23 public ArgumentList Arguments
= new ArgumentList();
25 public void CalculateRegisters()
30 foreach(Argument a
in Arguments
)
32 if ((a
.Type
.IndexOf("*") >= 0) || (nextdreg
> 7))
35 throw new ApplicationException("A6 reached");
37 a
.Register
= string.Format("A{0}", nextareg
++);
40 a
.Register
= string.Format("D{0}", nextdreg
++);
45 public void CorrectionForArrayArguments()
47 bool correctioMade
= false;
48 foreach(Argument a
in Arguments
)
50 int bracketpos
= a
.Name
.IndexOf("[");
53 /* Change array to pointer */
55 a
.Name
= a
.Name
.Substring(0, bracketpos
);
61 Console
.WriteLine("Correction for array arguments: {0}", this.Name
);
64 public bool ReturnsVoid()
66 if (ReturnType
.Equals("void"))
73 class FunctionList
: List
<Function
>
76 /// Removes entries from this list which have the same name as an entry in other list
78 /// <param name="other">
79 /// A <see cref="FunctionList"/>
81 public void RemoveFunctions(FunctionList other
)
83 /* Copy this list to hashtable */
84 Dictionary
<string, Function
> temp
= new Dictionary
<string, Function
>();
85 FunctionList toBeRemoved
= new FunctionList();
87 foreach(Function f
in this)
91 foreach(Function f
in other
)
92 if (temp
.ContainsKey(f
.Name
))
94 Function thisf
= temp
[f
.Name
];
95 if (thisf
.Arguments
.Count
!= f
.Arguments
.Count
)
96 throw new ApplicationException(string.Format("Same name, different arguments count: {0} {1} {2}",
97 f
.Name
, f
.Arguments
.Count
, thisf
.Arguments
.Count
));
98 toBeRemoved
.Add(thisf
);
101 foreach(Function f
in toBeRemoved
)
105 public void RemoveFunctionByName(string functionName
)
107 FunctionList toBeRemoved
= new FunctionList();
109 foreach(Function f
in this)
111 if (f
.Name
== functionName
)
115 foreach(Function f
in toBeRemoved
)
121 public void RemoveFunctionsExceptFor(FunctionNameDictionary functions
)
123 FunctionList toBeRemoved
= new FunctionList();
125 foreach(Function f
in this)
127 if (!functions
.ContainsKey(f
.Name
))
133 functions
.MarkAsMatched(f
.Name
);
137 foreach(Function f
in toBeRemoved
)
143 public void CorrectionForArrayArguments()
145 foreach (Function f
in this)
146 f
.CorrectionForArrayArguments();
149 public void CalculateRegisters()
151 foreach (Function f
in this)
152 f
.CalculateRegisters();
155 public void ReorderToMatch(FunctionList requestedOrderOfFunctions
)
157 /* Rather not effective implementation
158 * For each item on ordered list, find it in this list, put to temp list, remove from this list
159 * when finished, copy remaining items on this list to temp list
160 * copy temp list to this list */
161 FunctionList tempList
= new FunctionList();
163 foreach(Function ordered
in requestedOrderOfFunctions
)
165 foreach(Function current
in this)
167 if ((current
.Name
== ordered
.Name
) &&
168 current
.ReturnType
== ordered
.ReturnType
)
170 tempList
.Add(current
);
171 this.Remove(current
);
177 foreach(Function current
in this)
178 tempList
.Add(current
);
182 this.AddRange(tempList
);
186 class FunctionNameDictionary
: Dictionary
<string, object>
188 public void MarkAsMatched(string function
)
190 if (this.ContainsKey(function
))
191 this[function
] = (object)1;
194 public void WriteUnmatched()
196 foreach (string function
in this.Keys
)
197 if (this[function
] == null)
198 Console
.WriteLine("Unmatched implemented function: {0}", function
);
204 class GLApiTempParser
207 /// Path to glapitemp.h file
209 public FunctionNameDictionary
Parse(string path
)
211 StreamReader sr
= File
.OpenText(path
);
212 FunctionNameDictionary functions
= new FunctionNameDictionary();
217 while ((line
= sr
.ReadLine()) != null)
219 if ((matchpos
= line
.IndexOf("KEYWORD2 NAME(")) >= 0)
221 int closingbracketpos
= line
.IndexOf(")", matchpos
);
222 string fname
= "gl" + line
.Substring(matchpos
+ 14, closingbracketpos
- 14 - matchpos
);
224 if (fname
.IndexOf("_dispatch_stub") >= 0)
225 continue; /* Trash not needed */
227 if (!functions
.ContainsKey(fname
))
229 functions
.Add(fname
, null);
238 class GLApiTableParser
241 /// Path to glapioffsets.h file
243 public FunctionNameDictionary
Parse(string path
)
245 StreamReader sr
= File
.OpenText(path
);
246 FunctionNameDictionary functions
= new FunctionNameDictionary();
250 while ((line
= sr
.ReadLine()) != null)
252 if (line
.IndexOf("#define _gloffset_") >= 0)
254 string part
= line
.Substring(18, line
.Length
- 18);
255 string fname
= "gl" + (part
.Split(' ')[0].Trim());
256 if (!functions
.ContainsKey(fname
))
258 functions
.Add(fname
, null);
267 class APIHeaderParser
269 public const string APIENTRY
= "APIENTRY";
270 public const string GLAPI
= "GLAPI";
271 public const string GLAPIENTRY
= "GLAPIENTRY";
272 public const string EGLAPI
= "EGLAPI";
273 public const string EGLAPIENTRY
= "EGLAPIENTRY";
274 public const string VGAPI
= "VG_API_CALL";
275 public const string VGAPIENTRY
= "VG_API_ENTRY";
276 public const string VGUAPI
= "VGU_API_CALL";
277 public const string VGUAPIENTRY
= "VGU_API_ENTRY";
279 public string readandnormalize(StreamReader sr
)
281 string s
= sr
.ReadLine();
283 if (s
== null) return null;
285 s
= s
.Replace("\n","");
286 s
= s
.Replace("\t","");
292 public FunctionList
Parse(string pathToHeader
, string APIstring
, string APIENTRYstring
)
294 FunctionList functions
= new FunctionList();
296 StreamReader sr
= File
.OpenText(pathToHeader
);
299 int APIposition
= -1;
300 int APIENTRYposition
= -1;
301 int openbracketposition
= -1;
302 int closebracketpositiong
= -1;
304 while((line
= readandnormalize(sr
)) != null)
306 if (line
== string.Empty
)
309 if (line
.IndexOf("#") >= 0)
313 APIposition
= line
.IndexOf(APIstring
);
318 /* Check APIENTRY first */
319 APIENTRYposition
= line
.IndexOf(APIENTRYstring
, APIposition
);
321 if (APIENTRYposition
< 0)
323 if (line
[APIENTRYposition
- 1] != ' ') /* Space before APIENTRY is required */
326 openbracketposition
= line
.IndexOf("(", APIENTRYposition
);
328 if (openbracketposition
< 0)
331 closebracketpositiong
= line
.IndexOf(")", openbracketposition
);
333 if (closebracketpositiong
< 0)
335 /* read next lines for closing brackets */
336 string nextline
= null;
338 while((nextline
= readandnormalize(sr
))!= null)
341 closebracketpositiong
= line
.IndexOf(")", openbracketposition
);
342 if (closebracketpositiong
>= 0)
348 Function f
= new Function();
349 f
.ReturnType
= line
.Substring(APIposition
+ APIstring
.Length
, APIENTRYposition
- APIposition
- APIstring
.Length
).Trim();
350 f
.Name
= line
.Substring(APIENTRYposition
+ APIENTRYstring
.Length
, openbracketposition
- APIENTRYposition
- APIENTRYstring
.Length
).Trim();
352 string argumentsstring
= line
.Substring(openbracketposition
+ 1, closebracketpositiong
- 1 - openbracketposition
);
354 string [] arguments
= argumentsstring
.Split(',');
356 char nextargumentname
= 'a';
358 foreach (string argument
in arguments
)
360 /* change * and & so that they are no concatenated with variable name */
361 string innerargument
= argument
.Replace("*", " * ");
362 innerargument
= innerargument
.Replace("&", " & ");
363 innerargument
= innerargument
.Replace(" ", " ");
364 innerargument
= innerargument
.Replace(" [", "[");
365 innerargument
= innerargument
.Trim();
367 /* Possible situations:
368 * (A) innerargument = "void"
369 * (B) innerargument = "type variable"
370 * (C) innerargument = "type * variable"
371 * (D) innerargument = "type & variable"
372 * (E) innerargumetn = "type"
373 * (F) innerargument = "type *"
374 * (G) innerargument = "type &"
377 string [] argumentparts
= innerargument
.Split(' ');
379 /* Detection for A: only one argument with one argumentpart containing void*/
380 if ((argumentparts
.Length
== 1) && (arguments
.Length
== 1) && (argumentparts
[0].IndexOf("void") >= 0))
383 int lastPositionOfTypeBackwards
= 1; /* Means the last element of argumentparts is variable name */
385 /* Detection for E, F, G: argument without variable name */
386 if ((argumentparts
[argumentparts
.Length
- 1] == "*") ||
387 (argumentparts
[argumentparts
.Length
- 1] == "&") ||
388 (argumentparts
.Length
== 1)
391 lastPositionOfTypeBackwards
= 0; /* Means the last element of argumentparts is type */
394 Argument arg
= new Argument();
396 for (int i
= 0; i
< argumentparts
.Length
- lastPositionOfTypeBackwards
; i
++)
397 arg
.Type
= arg
.Type
+ argumentparts
[i
] + " ";
398 arg
.Type
= arg
.Type
.Trim();
400 if (lastPositionOfTypeBackwards
== 1)
401 arg
.Name
= argumentparts
[argumentparts
.Length
- 1].Trim();
404 /* Autoname for the variable */
405 arg
.Name
= string.Format("{0}", nextargumentname
++);
408 f
.Arguments
.Add(arg
);
414 /*Console.Write("{0} {1} (", f.ReturnType, f.Name);
416 if (f.Arguments.Count > 0)
418 for (j = 0; j < f.Arguments.Count - 1; j++)
419 Console.Write("{0} {1} ({2}), ", f.Arguments[j].Type, f.Arguments[j].Name, f.Arguments[j].Register);
420 Console.Write("{0} {1} ({2})", f.Arguments[j].Type, f.Arguments[j].Name, f.Arguments[j].Register);
422 Console.WriteLine(");");*/
434 public FunctionList
Parse(string pathToFile
)
436 FunctionList functions
= new FunctionList();
438 /* This file might not yet exist */
439 if (!File
.Exists(pathToFile
))
442 StreamReader sr
= File
.OpenText(pathToFile
);
445 int spacePosition
= -1;
446 int bracketPosition
= -1;
448 while((line
= sr
.ReadLine()) != null)
450 if ((line
.IndexOf(" gl") < 0) &&
451 (line
.IndexOf(" egl") < 0) &&
452 (line
.IndexOf(" vg") < 0))
455 bracketPosition
= line
.IndexOf("(", 0);
456 if (bracketPosition
< 0)
459 spacePosition
= line
.LastIndexOf(" ", bracketPosition
);
460 if (spacePosition
< 0)
463 Function f
= new Function();
464 f
.ReturnType
= line
.Substring(0, spacePosition
).Trim();
465 f
.Name
= line
.Substring(spacePosition
+ 1, bracketPosition
- spacePosition
- 1).Trim();
473 abstract class ArosFileWriter
475 protected string getDefine(string path
)
477 string define
= Path
.GetFileName(path
);
478 define
= define
.Replace('.', '_');
479 define
= define
.ToUpper();
483 public abstract void Write(string path
, FunctionList functions
);
486 class StubsFileWriter
: ArosFileWriter
488 private bool addRegSaveRest
;
489 private string baseName
;
490 private string functionPrefix
;
491 private int firstFunctionLVO
;
493 public StubsFileWriter(bool addRegSaveRest
, string libraryName
, int firstFunctionLVO
)
495 this.addRegSaveRest
= addRegSaveRest
;
496 this.baseName
= libraryName
+ "Base";
497 this.functionPrefix
= libraryName
.ToLower();
498 this.functionPrefix
= char.ToUpper(this.functionPrefix
[0]) + this.functionPrefix
.Substring(1);
499 this.firstFunctionLVO
= firstFunctionLVO
;
503 public override void Write (string path
, FunctionList functions
)
505 StreamWriter swStubs
= new StreamWriter(path
, false);
506 int lvo
= firstFunctionLVO
;
508 foreach (Function f
in functions
)
510 swStubs
.WriteLine("AROS_LH{0}({1}, {2},", f
.Arguments
.Count
, f
.ReturnType
, f
.Name
);
511 foreach (Argument a
in f
.Arguments
)
513 swStubs
.WriteLine(" AROS_LHA({0}, {1}, {2}),", a
.Type
, a
.Name
, a
.Register
);
515 swStubs
.WriteLine(" struct Library *, {0}, {1}, {2})", baseName
, lvo
++ ,functionPrefix
);
516 swStubs
.WriteLine("{");
517 swStubs
.WriteLine(" AROS_LIBFUNC_INIT");
521 swStubs
.WriteLine(" SAVE_REG");
523 swStubs
.WriteLine(" PUT_MESABASE_IN_REG");
526 if (!f
.ReturnsVoid())
528 swStubs
.Write(" {0} _return = {1}(", f
.ReturnType
, f
.Name
);
533 swStubs
.Write(" {0}(", f
.Name
);
535 if (f
.Arguments
.Count
> 0)
538 for (i
= 0; i
< f
.Arguments
.Count
- 1; i
++)
539 swStubs
.Write("{0}, ", f
.Arguments
[i
].Name
);
540 swStubs
.Write("{0}", f
.Arguments
[i
].Name
);
542 swStubs
.WriteLine(");");
546 swStubs
.WriteLine(" RESTORE_REG");
549 if (!f
.ReturnsVoid())
551 swStubs
.WriteLine(" return _return;");
554 swStubs
.WriteLine(" AROS_LIBFUNC_EXIT");
555 swStubs
.WriteLine("}");
570 class ConfFileWriter
: ArosFileWriter
572 private CallType calltype
;
574 public ConfFileWriter(CallType calltype
)
576 this.calltype
= calltype
;
579 public override void Write (string path
, FunctionList functions
)
581 StreamWriter swConf
= new StreamWriter(path
, false);
583 foreach (Function f
in functions
)
585 swConf
.Write("{0} {1}(", f
.ReturnType
, f
.Name
);
586 if (f
.Arguments
.Count
> 0)
589 for (i
= 0; i
< f
.Arguments
.Count
- 1; i
++)
590 swConf
.Write("{0} {1}, ", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
591 swConf
.Write("{0} {1}", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
594 if (calltype
== CallType
.RegCall
)
596 /* Extend with register specification */
599 if (f
.Arguments
.Count
> 0)
602 for (i
= 0; i
< f
.Arguments
.Count
- 1; i
++)
603 swConf
.Write("{0}, ", f
.Arguments
[i
].Register
);
604 swConf
.Write("{0}", f
.Arguments
[i
].Register
);
608 swConf
.WriteLine(")");
617 class UndefFileWriter
: ArosFileWriter
619 public override void Write (string path
, FunctionList functions
)
621 StreamWriter swUndef
= new StreamWriter(path
, false);
623 foreach (Function f
in functions
)
625 swUndef
.WriteLine("#undef {0}", f
.Name
);
632 class MangleFileWriter
: ArosFileWriter
634 public override void Write (string path
, FunctionList functions
)
636 StreamWriter swMangle
= new StreamWriter(path
, false);
638 string define
= getDefine(path
);
640 swMangle
.WriteLine("#ifndef {0}", define
);
641 swMangle
.WriteLine("#define {0}", define
);
643 foreach (Function f
in functions
)
645 swMangle
.WriteLine("#define {0} m{0}", f
.Name
);
648 swMangle
.WriteLine("#endif");
654 class MangledHeaderFileWriter
: ArosFileWriter
656 public override void Write (string path
, FunctionList functions
)
658 StreamWriter swMangledHeader
= new StreamWriter(path
, false);
660 string define
= getDefine(path
);
662 swMangledHeader
.WriteLine("#ifndef {0}", define
);
663 swMangledHeader
.WriteLine("#define {0}", define
);
665 foreach (Function f
in functions
)
667 swMangledHeader
.Write("{0} m{1} (", f
.ReturnType
, f
.Name
);
668 if (f
.Arguments
.Count
> 0)
671 for (i
= 0; i
< f
.Arguments
.Count
- 1; i
++)
672 swMangledHeader
.Write("{0} {1}, ", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
673 swMangledHeader
.Write("{0} {1}", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
675 swMangledHeader
.WriteLine(");");
678 swMangledHeader
.WriteLine("#endif");
680 swMangledHeader
.Close();
684 class MangledImplementationFileWriter
: ArosFileWriter
686 public override void Write (string path
, FunctionList functions
)
688 StreamWriter swMangledImplementation
= new StreamWriter(path
, false);
690 foreach (Function f
in functions
)
692 swMangledImplementation
.Write("{0} m{1} (", f
.ReturnType
, f
.Name
);
693 if (f
.Arguments
.Count
> 0)
696 for (i
= 0; i
< f
.Arguments
.Count
- 1; i
++)
697 swMangledImplementation
.Write("{0} {1}, ", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
698 swMangledImplementation
.Write("{0} {1}", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
700 swMangledImplementation
.WriteLine(")");
701 swMangledImplementation
.WriteLine("{");
702 if (!f
.ReturnsVoid())
703 swMangledImplementation
.WriteLine(" {0} _ret;", f
.ReturnType
);
705 if (f
.Name
.Equals("glEnd"))
706 swMangledImplementation
.WriteLine(" /* glBegin/glEnd must be atomic */");
708 swMangledImplementation
.WriteLine(" HOSTGL_PRE");
709 swMangledImplementation
.WriteLine(" D(bug(\"[HostGL] TASK: 0x%x, {0}\", FindTask(NULL)));", f
.Name
);
712 swMangledImplementation
.Write(" GLCALL({0}", f
.Name
);
714 swMangledImplementation
.Write(" _ret = GLCALL({0}", f
.Name
);
715 if (f
.Arguments
.Count
> 0)
718 for (i
= 0; i
< f
.Arguments
.Count
; i
++)
719 swMangledImplementation
.Write(", {0}", f
.Arguments
[i
].Name
);
721 swMangledImplementation
.WriteLine(");");
723 swMangledImplementation
.WriteLine(" D(bug(\"...exit\\n\"));");
724 if (f
.Name
.Equals("glBegin"))
725 swMangledImplementation
.WriteLine(" /* glBegin/glEnd must be atomic */");
727 swMangledImplementation
.WriteLine(" HOSTGL_POST");
729 if (!f
.ReturnsVoid())
730 swMangledImplementation
.WriteLine(" return _ret;");
731 swMangledImplementation
.WriteLine("}");
732 swMangledImplementation
.WriteLine();
735 swMangledImplementation
.Close();
739 class GLFUNCFileWriter
: ArosFileWriter
741 public override void Write (string path
, FunctionList functions
)
743 StreamWriter swGLFUNC
= new StreamWriter(path
, false);
745 swGLFUNC
.WriteLine("struct gl_func {");
747 foreach (Function f
in functions
)
749 swGLFUNC
.Write(" {0} (*{1}) (", f
.ReturnType
, f
.Name
);
750 if (f
.Arguments
.Count
> 0)
753 for (i
= 0; i
< f
.Arguments
.Count
- 1; i
++)
754 swGLFUNC
.Write("{0} {1}, ", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
755 swGLFUNC
.Write("{0} {1}", f
.Arguments
[i
].Type
, f
.Arguments
[i
].Name
);
757 swGLFUNC
.WriteLine(");");
760 swGLFUNC
.WriteLine("};");
762 swGLFUNC
.WriteLine();swGLFUNC
.WriteLine();swGLFUNC
.WriteLine();swGLFUNC
.WriteLine();
764 swGLFUNC
.WriteLine("static const char *gl_func_names[] = {");
765 foreach (Function f
in functions
)
767 swGLFUNC
.WriteLine(" \"{0}\",", f
.Name
);
769 swGLFUNC
.WriteLine(" NULL");
770 swGLFUNC
.WriteLine("};");
778 public static void Main(string[] args
)
780 string PATH_TO_MESA
= @"/ssd/deadwood/repo-gitorious-aros/AROS/AROS/workbench/libs/mesa/";
781 string OUTPUT_PATH
= @"/ssd/deadwood/temp/";
782 CallType eglCallType
= CallType
.StackCall
;
783 CallType vgCallType
= CallType
.StackCall
;
784 CallType gluCallType
= CallType
.StackCall
;
785 CallType glCallType
= CallType
.StackCall
;
788 GLApiTempParser apiParser
= new GLApiTempParser();
789 FunctionNameDictionary implementedFunctions
=
790 apiParser
.Parse(PATH_TO_MESA
+ @"/src/mapi/glapi/glapitemp.h");
793 Console
.WriteLine("Implemented functions: {0}", implementedFunctions
.Keys
.Count
);
796 APIHeaderParser p
= new APIHeaderParser();
798 FunctionList functionsglh
= p
.Parse(PATH_TO_MESA
+ @"/include/GL/gl.h", APIHeaderParser
.GLAPI
, APIHeaderParser
.GLAPIENTRY
);
799 FunctionList functionsglhquirk
= p
.Parse(PATH_TO_MESA
+ @"/include/GL/gl.h", APIHeaderParser
.GLAPI
, APIHeaderParser
.APIENTRY
);
800 functionsglh
.AddRange(functionsglhquirk
);
802 FunctionList functionsglexth
= p
.Parse(PATH_TO_MESA
+ @"/include/GL/glext.h", APIHeaderParser
.GLAPI
, APIHeaderParser
.APIENTRY
);
805 ConfParser confParser
= new ConfParser();
806 FunctionList orderedExistingFunctions
= confParser
.Parse(PATH_TO_MESA
+ @"/src/aros/arosmesa/gl.conf");
808 Console
.WriteLine("Initial parse results: GL: {0} GLEXT: {1}", functionsglh
.Count
, functionsglexth
.Count
);
810 functionsglexth
.RemoveFunctionsExceptFor(implementedFunctions
);
811 functionsglh
.RemoveFunctionsExceptFor(implementedFunctions
);
812 functionsglexth
.RemoveFunctions(functionsglh
);
814 implementedFunctions
.WriteUnmatched();
816 Console
.WriteLine("After filtering of unimplemented functions: GL: {0} GLEXT: {1}", functionsglh
.Count
, functionsglexth
.Count
);
818 /* Generation part */
821 FunctionList functionsGL
= new FunctionList();
823 Console
.WriteLine("After duplicates removal GL: {0}, GLEXT: {1}", functionsglh
.Count
, functionsglexth
.Count
);
824 functionsGL
.AddRange(functionsglh
);
826 functionsGL
.RemoveFunctionByName("glBlendEquationSeparateATI"); /* Extension found in gl.h instead of glext.h */
827 functionsGL
.RemoveFunctionByName("glFramebufferTextureLayerEXT"); /* Extension found in gl.h instead of glext.h */
828 functionsGL
.RemoveFunctionByName("glEGLImageTargetTexture2DOES"); /* Extension found in gl.h instead of glext.h */
829 functionsGL
.RemoveFunctionByName("glEGLImageTargetRenderbufferStorageOES"); /* Extension found in gl.h instead of glext.h */
831 Console
.WriteLine("After merging GL {0}", functionsGL
.Count
);
834 FunctionList functionsfinal
= new FunctionList();
835 functionsfinal
.AddRange(functionsGL
);
837 functionsfinal
.CorrectionForArrayArguments();
838 functionsfinal
.ReorderToMatch(orderedExistingFunctions
);
840 if (glCallType
== CallType
.RegCall
)
842 functionsfinal
.CalculateRegisters();
844 StubsFileWriter sfw
= new StubsFileWriter(false, "Mesa", 35);
845 sfw
.Write(OUTPUT_PATH
+ @"arosmesa_library_api.c", functionsfinal
);
848 ConfFileWriter cfw
= new ConfFileWriter(glCallType
);
849 cfw
.Write(OUTPUT_PATH
+ @"gl.conf", functionsfinal
);
851 /*MangledImplementationFileWriter glmifw = new MangledImplementationFileWriter();
852 glmifw.Write(OUTPUT_PATH + @"hostgl_gl_api.c", functionsfinal);
854 GLFUNCFileWriter glfuncfw = new GLFUNCFileWriter();
855 glfuncfw.Write(OUTPUT_PATH + @"gl_func.ch", functionsfinal);*/
858 FunctionList functionseglh
= p
.Parse(PATH_TO_MESA
+ @"/include/EGL/egl.h", APIHeaderParser
.EGLAPI
, APIHeaderParser
.EGLAPIENTRY
);
859 FunctionList orderedExistingFunctionsEGL
= confParser
.Parse(PATH_TO_MESA
+ @"/src/aros/egl/egl.conf");
861 FunctionList functionsEGL
= new FunctionList();
863 functionsEGL
.AddRange(functionseglh
);
865 Console
.WriteLine("After merging EGL {0}", functionsEGL
.Count
);
867 functionsfinal
.Clear();
868 functionsfinal
.AddRange(functionsEGL
);
870 functionsfinal
.CorrectionForArrayArguments();
872 functionsfinal
.ReorderToMatch(orderedExistingFunctionsEGL
);
874 if (eglCallType
== CallType
.RegCall
)
876 functionsfinal
.CalculateRegisters();
878 StubsFileWriter eglsfw
= new StubsFileWriter(false, "EGL", 35);
879 eglsfw
.Write(OUTPUT_PATH
+ @"egl_library_api.c", functionsfinal
);
882 ConfFileWriter eglcfw
= new ConfFileWriter(eglCallType
);
883 eglcfw
.Write(OUTPUT_PATH
+ @"egl.conf", functionsfinal
);
887 FunctionList functionsopenvgh
= p
.Parse(PATH_TO_MESA
+ @"/include/VG/openvg.h", APIHeaderParser
.VGAPI
, APIHeaderParser
.VGAPIENTRY
);
888 FunctionList functionsvguh
= p
.Parse(PATH_TO_MESA
+ @"/include/VG/vgu.h", APIHeaderParser
.VGUAPI
, APIHeaderParser
.VGUAPIENTRY
);
890 FunctionList orderedExistingFunctionsVG
= confParser
.Parse(PATH_TO_MESA
+ @"/src/aros/vega/vega.conf");
892 FunctionList functionsVG
= new FunctionList();
893 functionsVG
.AddRange(functionsopenvgh
);
894 functionsVG
.AddRange(functionsvguh
);
896 Console
.WriteLine("After merging VG {0}", functionsVG
.Count
);
898 functionsfinal
.Clear();
899 functionsfinal
.AddRange(functionsVG
);
901 functionsfinal
.CorrectionForArrayArguments();
902 functionsfinal
.ReorderToMatch(orderedExistingFunctionsVG
);
904 if (vgCallType
== CallType
.RegCall
)
906 functionsVG
.RemoveFunctionByName("vguComputeWarpQuadToQuad"); /* Too many parameters */
907 functionsfinal
.CalculateRegisters();
909 StubsFileWriter vgsfw
= new StubsFileWriter(false, "Vega", 35);
910 vgsfw
.Write(OUTPUT_PATH
+ @"vega_library_api.c", functionsfinal
);
913 ConfFileWriter vgcfw
= new ConfFileWriter(vgCallType
);
914 vgcfw
.Write(OUTPUT_PATH
+ @"vega.conf", functionsfinal
);
918 FunctionList functionsgluh
= p
.Parse(PATH_TO_MESA
+ @"/include/GL/glu.h", APIHeaderParser
.GLAPI
, APIHeaderParser
.GLAPIENTRY
);
920 FunctionList orderedExistingFunctionsGLU
= confParser
.Parse(PATH_TO_MESA
+ @"/src/aros/glu/glu.conf");
922 FunctionList functionsGLU
= new FunctionList();
923 functionsGLU
.AddRange(functionsgluh
);
925 Console
.WriteLine("After merging GLU {0}", functionsGLU
.Count
);
927 functionsfinal
.Clear();
928 functionsfinal
.AddRange(functionsGLU
);
930 functionsfinal
.CorrectionForArrayArguments();
931 functionsfinal
.ReorderToMatch(orderedExistingFunctionsGLU
);
933 if (gluCallType
== CallType
.RegCall
)
935 functionsGLU
.RemoveFunctionByName("gluUnProject4"); /* Too many parameters */
936 functionsfinal
.CalculateRegisters();
938 StubsFileWriter glusfw
= new StubsFileWriter(false, "GLU", 35);
939 glusfw
.Write(OUTPUT_PATH
+ @"glu_library_api.c", functionsfinal
);
942 ConfFileWriter glucfw
= new ConfFileWriter(gluCallType
);
943 glucfw
.Write(OUTPUT_PATH
+ @"glu.conf", functionsfinal
);