浏览代码

* fixed some bugs

* added tests
master
Bergmann89 9 年前
父节点
当前提交
95abc62142
共有 5 个文件被更改,包括 45 次插入8 次删除
  1. +11
    -0
      tests/testfiles/code_General_OrderOfMainProcClassContent.shdr
  2. +11
    -0
      tests/testfiles/result_General_OrderOfMainProcClassContent.shdr
  3. +14
    -0
      tests/uShaderFileTestCase.pas
  4. +6
    -6
      uengShaderGenerator.pas
  5. +3
    -2
      uengShaderGeneratorArgs.pas

+ 11
- 0
tests/testfiles/code_General_OrderOfMainProcClassContent.shdr 查看文件

@@ -0,0 +1,11 @@
{$CLASS TestClass}
/* some code here */
{$PROC TestProc}
gl_FragColor = vec4(1.0);
{$END}
{$MAIN}
{$CALL TestProc};
{$END}
{$END}

+ 11
- 0
tests/testfiles/result_General_OrderOfMainProcClassContent.shdr 查看文件

@@ -0,0 +1,11 @@
/* some code here */

void TestClass_TestProc(void)
{
gl_FragColor = vec4(1.0);
}

void main(void)
{
TestClass_TestProc();
}

+ 14
- 0
tests/uShaderFileTestCase.pas 查看文件

@@ -52,6 +52,11 @@ type
procedure InheritedMain;
end;

TTestCase_General = class(TShaderFileTestCase)
published
procedure OrderOfMainProcClassContent;
end;

implementation

uses
@@ -206,11 +211,20 @@ begin
DoTest('code_Class_InheritedMain.shdr', 'SimpleClass', 'result_Class_InheritedMain.shdr');
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TTestCase_General/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TTestCase_General.OrderOfMainProcClassContent;
begin
DoTest('code_General_OrderOfMainProcClassContent.shdr', 'TestClass', 'result_General_OrderOfMainProcClassContent.shdr');
end;

initialization
RegisterTest(TTestCase_IfElifElseEnd);
RegisterTest(TTestCase_FuncProcMain);
RegisterTest(TTestCase_Include);
RegisterTest(TTestCase_Class);
RegisterTest(TTestCase_General);

end.


+ 6
- 6
uengShaderGenerator.pas 查看文件

@@ -205,7 +205,7 @@ begin
sr := TengSearchResults.Create;
walker := TengSearchWalker.Create(sr);
try
walker.SearchFlags := [sfSearchChildren, sfEvaluateIf];
walker.SearchFlags := [sfSearchChildren, sfEvaluateIf, sfSearchInherited];
walker.ResultTypes := CengShaderPartArr.Create(TengShaderPartMain);
walker.ChildrenDoNotLeave := CengShaderPartArr.Create(TengShaderGenerator);
walker.ChildrenForceLeave := CengShaderPartArr.Create(TengShaderFile);
@@ -221,17 +221,17 @@ begin
args.PopFlags;
end;
end;

args.GenerateProcedureCode;
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVar));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVarying));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartUniform));
finally
FreeAndNil(walker);
FreeAndNil(sr);
args.PopCode([pcfAppend, pcfAddEmptyLine]);
end;

args.GenerateProcedureCode;
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVar));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartVarying));
args.GenerateParameterCode(CengShaderPartArr.Create(TengShaderPartUniform));

args.PushCode;
try
args.GenerateMetaCode;


+ 3
- 2
uengShaderGeneratorArgs.pas 查看文件

@@ -86,7 +86,7 @@ type
private type
TCodeStack = specialize TutlSimpleList<TCodeStackItem>;
TParameterMap = specialize TutlMap<string, TengShaderPart>;
TProcedureList = specialize TutlSimpleList<TengShaderPart>;
TProcedureList = specialize TutlList<TengShaderPart>;
TProcParamStack = specialize TutlSimpleList<TStrings>;

private
@@ -663,7 +663,8 @@ procedure TengShaderGeneratorArgs.AddProcedure(const aProc: TengShaderPart);
begin
if not (aProc is TengShaderPartProc) then
raise EengShaderPartInternal.Create('parameter (' + aProc.ClassName + ') is not a ' + TengShaderPartProc.ClassName, aProc);
fProcedures.Add(aProc);
if (fProcedures.IndexOf(aProc) < 0) then
fProcedures.Add(aProc);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


正在加载...
取消
保存