Beispiel #1
0
sBool RequestHandler(sMiniFTPServer::RequestInfo &info)
{
  // CAUTION: You should *never ever* pass filenames from network
  // directly to sCreateFile. You at least want to clean the filename
  // beforehand to make sure it doesn't reference any directory above
  // the server root! (sIsBelowCurrentDir is your friend)
  const sChar *filename = info.Filename;
  sBool fnOk = sCmpString(filename,L"test1.txt") == 0 || sCmpString(filename,L"test2.txt") == 0;
  static const sChar listing[] = L"test1.txt\0test2.txt\0";
  sInt nListing = sCOUNTOF(listing);
  
  switch(info.Command)
  {
  case sMFC_EXISTS: return fnOk && sCheckFile(filename);
  case sMFC_GET:    info.File = fnOk ? sCreateFile(filename,sFA_READ) : 0;      return info.File != 0;
  case sMFC_PUT:    info.File = fnOk ? sCreateFile(filename,sFA_READWRITE) : 0; return info.File != 0;
  case sMFC_LIST:   sCopyMem(info.DirListing.AddMany(nListing),listing,nListing*2); return sTRUE;
  }
  
  return sFALSE;
}
Beispiel #2
0
bool sLoadDir(sArray<sDirEntry> &list,const char *path)
{
  DIR *dir;
  dirent *dp;
  sDirEntry *de;
  sString<sMaxPath> buffer;

  dir = opendir(path);
  if(!dir) 
  {
    sLogF("file","load dir failed <%s>",path);
    return 0;
  }
  else
  {
    sLogF("file","load dir <%s>",path);
  }

  bool ok = 1;
  list.Clear();  
  while(1)
  {
    dp = readdir(dir);
    if(!dp) 
      break;
    if(sCmpString(dp->d_name,".")==0 || sCmpString(dp->d_name,"..")==0)
      continue;
    buffer.PrintF("%s/%s",path,dp->d_name);
    de = list.AddMany(1);
    if(!sGetFileInfo(buffer,de))
      ok = 0;
    de->Name = dp->d_name;
  }
  
  closedir(dir);

  return ok;
}
Beispiel #3
0
sXSIModel *sXSIModel::FindModel(sChar *name)
{
  sInt i;
  sXSIModel *mod;

  mod = 0;
  if(sCmpString(name,Name)==0)
  {
    mod = this;
  }
  else
  {
    for(i=0;i<Childs->GetCount() && mod==0;i++)
      mod = Childs->Get(i)->FindModel(name);
  }

  return mod;
}
Beispiel #4
0
sInt DebugInfo::MakeString(sChar *string)
{
  // TODO: write a better implementation using hashing

  sInt i;

  for(i=0;i<Strings.Count;i++)
    if(!sCmpString(string,&StringData[Strings[i]]))
      return Strings[i];

  i = StringData.Count;
  while(*string)
    *StringData.Add() = *string++;

  *StringData.Add() = 0;
  *Strings.Add() = i;

  return i;
}
Beispiel #5
0
sBool Document::OutputXCode4()
{
    sBool ok = 1;
    for(auto sol : Solutions)
    {
        sChangeDir(sol->Path);
        for(auto pro : sol->Projects)
        {
        	for(auto dep : pro->Depends)
            {
              	for (auto opt : dep->Project->Root->Options)
                {
                    for(auto conf : pro->Configs)
                    {
                        if (sFindFirstString(conf->Name,opt->Name)!=-1)
          				{
           					AddOptions(conf, opt);
           				}
                    }
                }
            }
            
    		for (auto opt : pro->Root->Options)
            {
                for(auto conf : pro->Configs)
                {
                    if (sFindFirstString(conf->Name,opt->Name)!=-1)
          			{
                    	AddOptions(conf, opt);
                    }
                }
            }
            
            if (TargetProject.IsEmpty() || sCmpString(TargetProject.Get(),pro->Name.Get())==0)
                if(!OutputXCode4(pro))
                    ok = 0;
        }
        
    }
    return ok;
}
Beispiel #6
0
void ToolCodeGen::Emit(ToolCodeSnip *snip)
{
  PageOp *op;
  sInt i,j;
  sInt comma;
  sInt column;

  if(snip->Flags & TCS_LOAD)
  {
    if(snip->OutputCount>1)
    {
      Error = 1;
      return;
    }

    Emit("  load %s;\n",snip->Name);
  }
  else if(snip->Flags & TCS_STORE)
  {
    if(snip->InputCount!=1)
    {
      Error = 1;
      return;
    }

    Emit("  store %s;\n",snip->Name);
  }
  else if(snip->CodeObject && snip->CodeObject->GetClass()==sCID_TOOL_PAGEOP)
  {
    if(snip->OutputCount>1)
    {
      Error = 1;
      return;
    }

    op = (PageOp *) snip->CodeObject;

    column = SourceUsed;
    Emit("  %s(",op->Class->Name);
    comma = 0;
    for(i=0;i<op->Class->ParaCount;i++)
    {
      if(comma)
      {
        Emit(",");
        if(SourceUsed-column>60)
        {
          Emit("\n    ");
          column = SourceUsed-4;
        }
      }
      comma = sTRUE;
      if(op->Data[i].Anim)
      {
        if(op->Class->Para[i].Cycle && sCmpString(op->Class->Para[i].Cycle,"1234")==0)
          Emit("%d",MakeLabel(op->Data[i].Anim));
        else
          Emit("\"%s\"",op->Data[i].Anim);
      }
      else
      {
        switch(op->Class->Para[i].Type)
        {
        case sCT_LABEL:
          comma = sFALSE;
          break;

        case sCT_FIXED:
          if(op->Class->Para[i].Zones<2)
          {
            Emit("%H",op->Data[i].Data[0]);
          }
          else
          {
            Emit("[");
            for(j=0;j<op->Class->Para[i].Zones;j++)
            {
              if(j>0)
                Emit(",");
              Emit("%H",op->Data[i].Data[j]);
            }
            Emit("]");
          }
          break;

        case sCT_INT:
          if(op->Class->Para[i].Zones<2)
          {
            if(sCmpString(op->Class->Para[i].Name,"ocount")==0)
              Emit("%d",snip->FXViewport ? -snip->OriginalOutputCount : snip->OriginalOutputCount);
            else
              Emit("%d",op->Data[i].Data[0]);
          }
          else
          {
            Emit("[");
            for(j=0;j<op->Class->Para[i].Zones;j++)
            {
              if(j>0)
                Emit(",");
              Emit("%d",op->Data[i].Data[j]);
            }
            Emit("]");
          }
          break;

        case sCT_RGBA:
          Emit("#%02x%02x%02x%02x",
            sRange(op->Data[i].Data[3]>>8,255,0),
            sRange(op->Data[i].Data[0]>>8,255,0),
            sRange(op->Data[i].Data[1]>>8,255,0),
            sRange(op->Data[i].Data[2]>>8,255,0));
          break;

        case sCT_RGB:
          Emit("#%02x%02x%02x",
            sRange(op->Data[i].Data[0]>>8,255,0),
            sRange(op->Data[i].Data[1]>>8,255,0),
            sRange(op->Data[i].Data[2]>>8,255,0));
          break;

        case sCT_CYCLE:
        case sCT_CHOICE:
          Emit("%d",op->Data[i].Data[0]);
          break;

        case sCT_MASK:
          Emit("%h",op->Data[i].Data[0]);
          break;

        default:
          sVERIFYFALSE;
          break;
        }
      }
    }
    Emit(");\n");
  }
}
Beispiel #7
0
sBool Document::OutputXCode4(mProject *pro)
{
    sBool ok = 1;
    mFile *file;
    cVSGroup *gr;
    sArray<sPoolString> Frameworks;

    // prepare

    const sBool COOLLIBS = 0;
    
    bool nosetup = false;
    bool shell = false;
    for(auto con : pro->Configs)
    {
        nosetup = nosetup || (sFindFirstString(con->Name,"nosetup")!=-1);
        shell = shell || (sFindFirstString(con->Name,"shell")!=-1);
    }
        
    if(pro->Library && !nosetup) return 1;
    if(pro->Configs.GetCount()==0) return 1;

    Set("rootpath",(const sChar *)TargetRootPath);
    Set("library",pro->Library ? "1" : "0");
    Set("compiler","make");
    Set("solutiondir",pro->Name);

    sArray<mFile *> files;
    OutputFolder(pro->Root,files);
    if(!COOLLIBS)
    {
        for(auto dep : pro->Depends)
            OutputFolder(dep->Project->Root,files);
    }
    sString<sMaxPath> basepath = (const sChar *) pro->SolutionPath;
    sRemoveName(basepath);


    // gather frameworks

    for(auto con : pro->Configs)
    {
        for(auto gr : con->VSGroups)
        {
            if(gr->Compiler==OK_XCode4 && gr->Name.IsEmpty())
            {
                for(auto it : gr->VSItems)
                {
                    if(it->Key=="Frameworks")
                    {
                        const sChar *s = it->Value;
                        while(*s==' ') s++;
                        while(*s)
                        {
                            const sChar *ss = s;
                            while(*s!=' ' && *s!=0) s++;
                            sPoolString name(ss,s-ss);
                            if(!Frameworks.FindEqual(name))
                                Frameworks.Add(name);
                            while(*s==' ') s++;
                        }
                    }
                }
            }
        }
    }
    if(0)
    {
        for(auto pp : Frameworks)
            sDPrintF("(%s) ",pp);
        sDPrintF("\n");
    }

    // gather files
    
    sArray<mFile *> AdditionalFiles;
    for(auto file : files)
    {
        if(file->ToolId == mTI_packfile)
        {
            sString<sMaxPath> buffer;
            buffer.PrintF("%s.pak",file->NameWithoutExtension);
            sASSERT(sCmpString(file->Name,file->OriginalName)==0);

            mFile *af = new mFile;
            af->Name = buffer;
            af->OriginalName = buffer;
            af->NameWithoutExtension = file->NameWithoutExtension;
            af->NoNew = 1;
            af->ToolId = mTI_pak;
            af->Project = file->Project;
            af->FullPath.PrintF("%s/%s",af->Project->SolutionPath,af->Name);

            AdditionalFiles.Add(af);
        }
    }
    for(auto file : AdditionalFiles)
        files.Add(file);

    sInt i = 1;
    for(auto file : files)
    {
        file->XCodeRefGuid .PrintF("%08X000000A0%08X",pro->GuidHash,i);
        file->XCodeFileGuid.PrintF("%08X000000A1%08X",pro->GuidHash,i);

        i++;
    }

    for(sInt i=0;i<files.GetCount();)
    {
        file = files[i];
        if(file->Options.GetCount())
        {
            sInt cfound = 0;
            sInt cexcld = 0;
            for(auto con : pro->Configs)
            {
                for(auto opt : file->Options)
                {
                    sBool ok = 0;
                    if(opt->Name[0]=='!')
                        ok = !sMatchWildcard(opt->Name+1,con->Name,0,1);
                    else
                        ok = sMatchWildcard(opt->Name,con->Name,0,1);
                    if(ok)
                    {
                        cfound++;
                        if(opt->Excluded)
                            cexcld++;
                    }
                }
            }
            if(cfound>0 && cfound==cexcld)
            {
                files[i] = files[files.GetCount()-1];
                files.RemTail();
            }
            else
            {
                i++;
            }
        }
        else
        {
            i++;
        }
    }

    // prepare guids

    sString<32> guidApp            ; guidApp            .PrintF("%08X000000E000000001",pro->GuidHash);
    sString<32> guidPhaseFrameworks; guidPhaseFrameworks.PrintF("%08X000000E000000002",pro->GuidHash);
    sString<32> guidPhaseSources   ; guidPhaseSources   .PrintF("%08X000000E000000003",pro->GuidHash);
    sString<32> guidCopyFiles      ; guidCopyFiles      .PrintF("%08X000000E000000004",pro->GuidHash);
    sString<32> guidProducts       ; guidProducts       .PrintF("%08X000000E000000005",pro->GuidHash);
    sString<32> guidMyProject      ; guidMyProject      .PrintF("%08X000000E000000006",pro->GuidHash);
    sString<32> guidmaingroup      ; guidmaingroup      .PrintF("%08X000000E000000007",pro->GuidHash);
    sString<32> guidTarget         ; guidTarget         .PrintF("%08X000000E000000008",pro->GuidHash);
    sString<32> guidProject        ; guidProject        .PrintF("%08X000000E000000009",pro->GuidHash);
    sString<32> guidBuildTarget    ; guidBuildTarget    .PrintF("%08X000000E00000000A",pro->GuidHash);
    sString<32> guidBuildProject   ; guidBuildProject   .PrintF("%08X000000E00000000B",pro->GuidHash);
    sString<32> guidProductRef     ; guidProductRef     .PrintF("%08X000000E00000000C",pro->GuidHash);
    sString<32> guidGroupFrameworks; guidGroupFrameworks.PrintF("%08X000000E00000000D",pro->GuidHash);
    sString<32> guidPhaseResources ; guidPhaseResources .PrintF("%08X000000E00000000E",pro->GuidHash);

    sString<32> guidRuleIncbin     ; guidRuleIncbin     .PrintF("%08X000000E000000201",pro->GuidHash);
    sString<32> guidRuleAsc        ; guidRuleAsc        .PrintF("%08X000000E000000202",pro->GuidHash);
    sString<32> guidRulePackfile   ; guidRulePackfile   .PrintF("%08X000000E000000203",pro->GuidHash);
    sString<32> guidRuleOps        ; guidRuleOps        .PrintF("%08X000000E000000204",pro->GuidHash);

    // output project file (this is loooooong)

    sln.Clear();
    sln.Print("// !$*UTF8*$!\n");
    sln.Print("{\n");
    sln.Print("  archiveVersion = 1;\n");
    sln.Print("  classes = {\n");
    sln.Print("  };\n");
    sln.Print("  objectVersion = 46;\n");
    sln.Print("  objects = {\n");
    sln.Print("\n");
    sln.Print("/* Begin PBXBuildFile section */\n");
    
    if (!pro->Library && !shell)
    {
	    if(Platform->Name=="ios")
    	 	sln.Print("		566655C616F0BE660016BA8A /* ios.info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 566655C516F0BE660016BA8A /* ios.info.plist */; };\n");
	    else
    	 	sln.Print("		566655C616F0BE660016BA8A /* osx.info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 566655C516F0BE660016BA8A /* osx.info.plist */; };\n");
    }
    for(auto file : files)
    {
        switch(file->ToolId)
        {
        case mTI_cpp:
        case mTI_c:
        case mTI_m:
        case mTI_mm:
        case mTI_incbin:
        case mTI_packfile:
        case mTI_xib:
        case mTI_pak:
        case mTI_asc:
        case mTI_ops:
        case mTI_dat:
        case mTI_xml:
            sln.PrintF("    %s = {isa = PBXBuildFile; fileRef = %s /* %s */; }; \n",file->XCodeRefGuid,file->XCodeFileGuid,file->FullPath);
            break;
        default:
            break;
        }
    }
    i = 1;
    for(auto pp : Frameworks)
    {
        sln.PrintF("    %08X000000A2%08X = {isa = PBXBuildFile; fileRef = %08X000000A3%08X /* %s.framework */; }; \n",pro->GuidHash,i,pro->GuidHash,i,pp);
        i++;
    }
    if(COOLLIBS)
    {
        for(auto dep : pro->Depends)
            sln.PrintF("    %08X000000B8%08X = {isa = PBXBuildFile; fileRef = %08X000000B9%08X /* lib%s.a */; };\n",pro->GuidHash,dep->Project->GuidHash,pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
    }
    sln.Print ("/* End PBXBuildFile section */\n");

    sln.Print ("\n");

    sln.Print ("/* Begin PBXBuildRule section */\n");

    sln.PrintF("    %s /* PBXBuildRule */ = {\n",guidRuleIncbin);
    sln.Print ("      isa = PBXBuildRule;\n");
    sln.Print ("      compilerSpec = com.apple.compilers.proxy.script;\n");
    sln.Print ("      filePatterns = \"*.incbin\";\n");
    sln.Print ("      fileType = pattern.proxy;\n");
    sln.Print ("      isEditable = 1;\n");
    sln.Print ("      outputFiles = (\n");
    sln.Print ("        \"${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.c\",\n");
    sln.Print ("      );\n");
    sln.PrintF ("      script = \""
        "cd ${INPUT_FILE_DIR}\\n"
        "echo %saltona2/Bin/osx/incbinasc -i=${INPUT_FILE_PATH} -o=${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}\\n"
        "%saltona2/Bin/osx/incbinasc -i=${INPUT_FILE_PATH} -o=${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}"
        "\";\n", (const char*)TargetRootPath,(const char*)TargetRootPath);
    sln.Print ("    };\n");

    sln.PrintF("    %s /* PBXBuildRule */ = {\n",guidRulePackfile);
    sln.Print ("      isa = PBXBuildRule;\n");
    sln.Print ("      compilerSpec = com.apple.compilers.proxy.script;\n");
    sln.Print ("      filePatterns = \"*.packfile\";\n");
    sln.Print ("      fileType = pattern.proxy;\n");
    sln.Print ("      isEditable = 1;\n");
    sln.Print ("      outputFiles = (\n");
    sln.Print ("        \"${INPUT_FILE_DIR}/${INPUT_FILE_BASE}.pak\",\n");
    sln.Print ("      );\n");
    sln.PrintF ("      script = \""
        "cd ${INPUT_FILE_DIR}\\n"
        "echo %saltona2/Bin/osx/packfile -i=${INPUT_FILE_PATH} ${INPUT_FILE_DIR}/${INPUT_FILE_BASE}.pak\\n"
        "%saltona2/Bin/osx/packfile -i=${INPUT_FILE_PATH} -o=${INPUT_FILE_DIR}/${INPUT_FILE_BASE}.pak"
        "\";\n", (const char*)TargetRootPath,(const char*)TargetRootPath);
    sln.Print ("    };\n");

    sln.PrintF("    %s /* PBXBuildRule */ = {\n",guidRuleAsc);
    sln.Print ("      isa = PBXBuildRule;\n");
    sln.Print ("      compilerSpec = com.apple.compilers.proxy.script;\n");
    sln.Print ("      filePatterns = \"*.asc\";\n");
    sln.Print ("      fileType = pattern.proxy;\n");
    sln.Print ("      isEditable = 1;\n");
    sln.Print ("      outputFiles = (\n");
    sln.Print ("        \"${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.cpp\",\n");
    sln.Print ("        \"${INPUT_FILE_DIR}/${INPUT_FILE_BASE}.hpp\",\n");
    sln.Print ("      );\n");
    if(Platform->Name=="ios")
    {
        sln.PrintF ("      script = \""
            "cd ${INPUT_FILE_DIR}\\n"
            "echo %saltona2/Bin/osx/asc -i=${INPUT_FILE_PATH} -cpp=${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.cpp -h=${INPUT_FILE_BASE}.hpp -p=gles2\\n"
            "%saltona2/Bin/osx/asc -i=${INPUT_FILE_PATH} -cpp=${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.cpp -h=${INPUT_FILE_BASE}.hpp -p=gles2"
            "\";\n", (const char*)TargetRootPath,(const char*)TargetRootPath);
    }
    else
    {
        sln.PrintF ("      script = \""
            "cd \\${INPUT_FILE_DIR}\\n"
            "echo %saltona2/Bin/osx/asc -i=${INPUT_FILE_PATH} -cpp=${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.cpp -h=${INPUT_FILE_BASE}.hpp -p=gl2\\n"
            "%saltona2/Bin/osx/asc -i=${INPUT_FILE_PATH} -cpp=${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.cpp -h=${INPUT_FILE_BASE}.hpp -p=gl2"
            "\";\n", (const char*)TargetRootPath,(const char*)TargetRootPath);
    }
    sln.Print ("    };\n");
    sln.Print ("/* End PBXBuildRule section */\n");


    sln.PrintF("    %s /* PBXBuildRule */ = {\n",guidRuleOps);
    sln.Print ("      isa = PBXBuildRule;\n");
    sln.Print ("      compilerSpec = com.apple.compilers.proxy.script;\n");
    sln.Print ("      filePatterns = \"*.ops\";\n");
    sln.Print ("      fileType = pattern.proxy;\n");
    sln.Print ("      isEditable = 1;\n");
    sln.Print ("      outputFiles = (\n");
    sln.Print ("        \"${INPUT_FILE_DIR}/${INPUT_FILE_BASE}.ops.hpp\",\n");
    sln.Print ("      );\n");
    sln.PrintF ("      script = \""
        "cd ${INPUT_FILE_DIR}\\n"
        "echo %saltona2/Bin/osx/wz5ops -i=${INPUT_FILE_PATH} -c=${INPUT_FILE_BASE}.ops.cpp -h=${INPUT_FILE_BASE}.ops.hpp \\n"
        "%saltona2/Bin/osx/wz5ops -i=${INPUT_FILE_PATH} -c=${INPUT_FILE_BASE}.ops.cpp -h=${INPUT_FILE_BASE}.ops.hpp"
        "\";\n", (const char*)TargetRootPath,(const char*)TargetRootPath);
    sln.Print ("    };\n");
    sln.Print ("/* End PBXBuildRule section */\n");

    sln.Print ("\n");


    if(COOLLIBS)
    {
        sln.Print ("/* Begin PBXContainerItemProxy section */\n");
        for(auto dep : pro->Depends)
        {
            sln.PrintF("    %08X000000B1%08X /* PBXContainerItemProxy */ = {\n",pro->GuidHash,dep->Project->GuidHash);
            sln.Print ("      isa = PBXContainerItemProxy;\n");
            sln.PrintF("      containerPortal = %08X000000BA%08X /* xcodeproj */;\n",pro->GuidHash,dep->Project->GuidHash);
            sln.Print ("      proxyType = 2;\n");
            sln.PrintF("      remoteGlobalIDString = %08X000000E000000001;\n",dep->Project->GuidHash);
            sln.PrintF("      remoteInfo = %s;\n",dep->Project->Name);
            sln.Print ("    };\n");
            sln.PrintF("    %08X000000B3%08X /* PBXContainerItemProxy */ = {\n",pro->GuidHash,dep->Project->GuidHash);
            sln.Print ("      isa = PBXContainerItemProxy;\n");
            sln.PrintF("      containerPortal = %08X000000BA%08X /* xcodeproj */;\n",pro->GuidHash,dep->Project->GuidHash);
            sln.Print ("      proxyType = 1;\n");
            sln.PrintF("      remoteGlobalIDString = %08X000000E000000008;\n",dep->Project->GuidHash);
            sln.PrintF("      remoteInfo = %s;\n",dep->Project->Name);
            sln.Print ("    };\n");
        }
        sln.Print ("/* End PBXContainerItemProxy section */\n");

        sln.Print ("\n");
    }

    sln.Print ("/* Begin PBXCopyFilesBuildPhase section */\n");
    /*
    sln.PrintF("    %s = {\n",guidCopyFiles);
    sln.Print ("      isa = PBXCopyFilesBuildPhase;\n");
    sln.Print ("      buildActionMask = 2147483647;\n");
    sln.Print ("      dstPath = /usr/share/man/man1/;\n");
    sln.Print ("      dstSubfolderSpec = 0;\n");
    sln.Print ("      files = (\n");
    sln.Print ("      );\n");
    sln.Print ("      runOnlyForDeploymentPostprocessing = 1;\n");
    sln.Print ("    };\n");
    */
    sln.Print ("/* End PBXCopyFilesBuildPhase section */\n");

    sln.Print ("\n");

    sln.Print ("/* Begin PBXFileReference section */\n");
    
    if (!pro->Library && !shell)
    {
	    if(Platform->Name=="ios")
			sln.Print ("		566655C516F0BE660016BA8A /* ios.info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ios.info.plist; sourceTree = \"<group>\"; };\n");
	    else
			sln.Print ("		566655C516F0BE660016BA8A /* osx.info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = osx.info.plist; sourceTree = \"<group>\"; };\n");
    }
    i = 1;
    for(auto pp : Frameworks)
    {
        sln.PrintF("    %08X000000A3%08X = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = %s.framework; path = System/Library/Frameworks/%s.framework; sourceTree = SDKROOT; };\n",pro->GuidHash,i,pp,pp);
        i++;
    }
    if(pro->Library)
        sln.PrintF("    %s = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = lib%s.a; sourceTree = BUILT_PRODUCTS_DIR; };\n",guidApp,sExtractName(pro->SolutionPath));
    else
        sln.PrintF("    %s = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = %s; sourceTree = BUILT_PRODUCTS_DIR; };\n",guidApp,sExtractName(pro->SolutionPath));
    for(auto file : files)
    {
        sString<sMaxPath> buffer,from;
        from = pro->SolutionPath;
        //    sRemoveName(from);

        sMakeRelativePath(buffer,from,file->FullPath);
        switch(file->ToolId)
        {
        case mTI_cpp:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_c:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_m:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_mm:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objc; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_xib:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_hpp:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_dat:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        case mTI_xml:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        default:
            sln.PrintF("    %s /* %s */ = {isa = PBXFileReference; lastKnownFileType = text; path = \"%s\"; sourceTree = \"<group>\"; };\n",file->XCodeFileGuid,file->Name,file->OriginalName);
            break;
        }
    }
    if(COOLLIBS)
    {
        for(auto dep : pro->Depends)
        {
            sString<sMaxPath> buffer,from,to;

            buffer = dep->Project->SolutionPath;
            sRemoveName(buffer);
            to.PrintF("%s/%s.xcodeproj",buffer,dep->Project->Name);
            from = pro->SolutionPath;
            sRemoveName(from);
            sMakeRelativePath(buffer,from,to);
            sln.PrintF("    %08X000000BA%08X = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = %s.xcodeproj; path = %s; sourceTree = \"<group>\"; };\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name,buffer);
            sln.PrintF("    %08X000000B9%08X = {isa = PBXFileReference; explicitFileType = archive.ar; path = lib%s.a; sourceTree = SOURCE_ROOT; };\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
        }
    }
    sln.Print ("/* End PBXFileReference section */\n");


    sln.Print ("\n");
    sln.Print ("/* Begin PBXFrameworksBuildPhase section */\n");
    sln.PrintF("    %s /* Frameworks */ = {\n",guidPhaseFrameworks);
    sln.Print ("      isa = PBXFrameworksBuildPhase;\n");
    sln.Print ("      buildActionMask = 2147483647;\n");
    sln.Print ("      files = (\n");
    i = 1;
    for(auto pp : Frameworks)
    {
        sln.PrintF("        %08X000000A2%08X /* %s.framework */,\n",pro->GuidHash,i,pp);
        i++;
    }
    if(COOLLIBS)
    {
        for(auto dep : pro->Depends)
            sln.PrintF("        %08X000000B8%08X /* lib%s.a */,\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
    }
    sln.Print ("      );\n");
    sln.Print ("      runOnlyForDeploymentPostprocessing = 0;\n");
    sln.Print ("    };\n");
    sln.Print ("/* End PBXFrameworksBuildPhase section */\n");

    sln.Print ("\n");

    sln.Print ("/* Begin PBXGroup section */\n");
    sln.PrintF("    %s = {\n",guidmaingroup);
    sln.Print ("      isa = PBXGroup;\n");
    sln.Print ("      children = (\n");
    if(COOLLIBS)
    {
        for(auto dep : pro->Depends)
        {
            sln.PrintF("        %08X000000B9%08X /* library %s */,\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
            sln.PrintF("        %08X000000BA%08X /* library %s */,\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
        }
    }
    else
    {
        for(auto dep : pro->Depends)
            sln.PrintF("        %08X000000BF%08X /* library %s */,\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
    }
    sln.PrintF("        %s /* MyProject */,\n",guidMyProject);
    sln.PrintF("        %s /* Products */,\n",guidProducts);
    sln.PrintF("        %s /* Framworks */,\n",guidGroupFrameworks);
    sln.Print ("      );\n");
    sln.Print ("      sourceTree = \"<group>\";\n");
    sln.Print ("    };\n");

    sln.PrintF("    %s /* Products */ = {\n",guidProducts);
    sln.Print ("      isa = PBXGroup;\n");
    sln.Print ("      children = (\n");
    sln.PrintF("        %s /* app */,\n",guidApp);
    sln.Print ("      );\n");
    sln.Print ("      name = Products;\n");
    sln.Print ("      sourceTree = \"<group>\";\n");
    sln.Print ("    };\n");

    sln.PrintF("    %s /* MyProject */ = {\n",guidMyProject);
    sln.Print ("      isa = PBXGroup;\n");
    sln.Print ("      children = (\n");
    
    if (!pro->Library && !shell)
    {
    	if(Platform->Name=="ios")
        	sln.Print ("				566655C516F0BE660016BA8A /* ios.info.plist */,\n");
    	else
        	sln.Print ("				566655C516F0BE660016BA8A /* osx.info.plist */,\n");
    }
    
    for(auto file : files)
    {
        if(file->Project==pro)
        {
            sln.PrintF("        %s /* %s */,\n",file->XCodeFileGuid,file->Name);
        }
    }
    sln.Print ("      );\n");
    sln.PrintF("      path = %s;\n",sExtractName(pro->SolutionPath));
    sln.Print ("      sourceTree = \"<group>\";\n");
    sln.Print ("    };\n");

    if(!COOLLIBS)
    {
        for(auto dep : pro->Depends)
        {
            sln.PrintF("    %08X000000BF%08X /* library %s */ = {\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
            sln.Print ("      isa = PBXGroup;\n");
            sln.Print ("      children = (\n");
                        
            for(auto file : files)
            {
                if(file->Project==dep->Project)
                {
                    sln.PrintF("        %s /* %s */,\n",file->XCodeFileGuid,file->Name);
                }
            }
            sln.Print ("      );\n");
            sln.PrintF("      name = %s;\n",dep->Project->Name);
            sString<sMaxPath> buffer;
            sMakeRelativePath(buffer,basepath,dep->Project->PathName);
            sRemoveName(buffer);
            sln.PrintF("      path = %s;\n",buffer);
            sln.Print ("      sourceTree = \"<group>\";\n");
            sln.Print ("    };\n");
        }
    }
    if(COOLLIBS && !pro->Depends.IsEmpty())
    {
        sln.PrintF("    %s /* Products */ = {\n",guidProductRef);
        sln.Print ("      isa = PBXGroup;\n");
        sln.Print ("      children = (\n");
        for(auto dep : pro->Depends)
        {
            sln.PrintF("        %08X000000BC%08X /* lib%s.a */,\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
        }
        sln.Print ("      );\n");
        sln.Print ("      name = Products;\n");
        sln.Print ("      sourceTree = \"<group>\";\n");
        sln.Print ("    };  \n");
    }
    sln.PrintF("    %s /* Frameworks */ = {\n",guidGroupFrameworks);
    sln.Print ("      isa = PBXGroup;\n");
    sln.Print ("      children = (\n");
    i = 1;
    for(auto pp : Frameworks)
    {
        sln.PrintF("        %08X000000A3%08X /* %s.framework */,\n",pro->GuidHash,i,pp);
        i++;
    }
    sln.Print ("      );\n");
    sln.Print ("      name = Frameworks;\n");
    sln.Print ("      sourceTree = \"<group>\";\n");
    sln.Print ("    };  \n");

    sln.Print ("/* End PBXGroup section */\n");

    sln.Print ("\n");

    sln.Print ("/* Begin PBXNativeTarget section */\n");
    sln.PrintF("    %s /* target */ = {\n",guidTarget);
    sln.Print ("      isa = PBXNativeTarget;\n");
    sln.PrintF("      buildConfigurationList = %s /* Build configuration list for PBXNativeTarget \"%s\" */;\n",guidBuildTarget,pro->Name);
    sln.Print ("      buildPhases = (\n");
    sln.PrintF("        %s /* Sources */,\n",guidPhaseSources);
    sln.PrintF("        %s /* Frameworks */,\n",guidPhaseFrameworks);
    sln.PrintF("        %s /* Resources */,\n",guidPhaseResources);
    //  sln.PrintF("        %s /* CopyFiles */,\n",guidCopyFiles);
    sln.Print ("      );\n");
    sln.Print ("      buildRules = (\n");
    sln.PrintF("        %s /* incbin */,\n",guidRuleIncbin);
    sln.PrintF("        %s /* packfile */,\n",guidRulePackfile);
    sln.PrintF("        %s /* asc */,\n",guidRuleAsc);
    sln.PrintF("        %s /* ops */,\n",guidRuleOps);
    sln.Print ("      );\n");
    sln.Print ("      dependencies = (\n");
    if(COOLLIBS)
    {
        for(auto dep : pro->Depends)
            sln.PrintF("				%08X000000BD%08X /* lib%s.a */,\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
    }
    sln.Print ("      );\n");
    sln.PrintF("      name = %s;\n",pro->Name);
    sln.PrintF("      productName = %s;\n",pro->Name);
    sln.PrintF("      productReference = %s /* app */;\n",guidApp);
    
    if(pro->Library)
        sln.Print ("      productType = \"com.apple.product-type.library.static\";\n");  // OR APPLICATION
    else
    {
    	if (shell)
	        sln.Print ("      productType = \"com.apple.product-type.tool\";\n");  // OR shell application
        else
        	sln.Print ("      productType = \"com.apple.product-type.application\";\n");  // OR APPLICATION
              }
    sln.Print ("    };\n");
    sln.Print ("/* End PBXNativeTarget section */\n");

    sln.Print ("\n");

    sln.Print ("/* Begin PBXProject section */\n");
    sln.PrintF("    %s /* Project object */ = {\n",guidProject);
    sln.Print ("      isa = PBXProject;\n");
    sln.Print ("      attributes = {\n");
    sln.Print ("        ORGANIZATIONNAME = Farbrausch;\n");
    sln.Print ("      };\n");
    sln.PrintF("      buildConfigurationList = %s /* Build configuration list for PBXProject */;\n",guidBuildProject);
    sln.Print ("      compatibilityVersion = \"Xcode 3.2\";\n");
    sln.Print ("      developmentRegion = English;\n");
    sln.Print ("      hasScannedForEncodings = 0;\n");
    sln.Print ("      knownRegions = (\n");
    sln.Print ("        en,\n");
    sln.Print ("      );\n");
    sln.PrintF("      mainGroup = %s;\n",guidmaingroup);
    sln.PrintF("      productRefGroup = %s /* Products */;\n",guidProducts);
    sln.Print ("      projectDirPath = \"\";\n");
    if(COOLLIBS)
    {
        sln.Print ("      projectReferences = (\n");
        for(auto dep : pro->Depends)
        {
            sln.Print ("        {\n");
            sln.PrintF("          ProductGroup = %s /* Productsref */;\n",guidProductRef);
            sln.PrintF("          ProjectRef = %08X000000BA%08X /* %s.xcodeproj */;\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
            sln.Print ("        },\n");
        }
        sln.Print ("      );\n");
    }
    sln.Print ("      projectRoot = \"\";\n");

    sln.Print ("      targets = (\n");
    sln.PrintF("        %s /* target */,\n",guidTarget);
    sln.Print ("      );\n");
    sln.Print ("    };\n");
    sln.Print ("/* End PBXProject section */\n");
    sln.Print ("\n");

    sln.Print ("\n");

    if(COOLLIBS)
    {
        sln.Print ("/* Begin PBXReferenceProxy section */\n");
        for(auto dep : pro->Depends)
        {
            sln.PrintF("    %08X000000BC%08X /* lib%s.a */  = {\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
            sln.Print ("      isa = PBXReferenceProxy;\n");
            sln.Print ("      fileType = archive.ar;\n");
            sln.PrintF("      path = lib%s.a;\n",dep->Project->Name);
            sln.PrintF("      remoteRef = %08X000000B1%08X /* PBXContainerItemProxy */;\n",pro->GuidHash,dep->Project->GuidHash);
            sln.Print ("      sourceTree = BUILT_PRODUCTS_DIR;\n");
            sln.Print ("    };\n");
        }
        sln.Print ("/* End PBXReferenceProxy section */\n");

        sln.Print ("\n");
    }

    sln.Print ("/* Begin PBXResourcesBuildPhase section */\n");
    sln.PrintF("    %s /* Resources */ = {\n",guidPhaseResources);
    sln.Print ("      isa = PBXResourcesBuildPhase;\n");
    sln.Print ("      buildActionMask = 2147483647;\n");
    sln.Print ("      files = (\n");
    for(auto file : files)
    {
        if(file->ToolId==mTI_xib || file->ToolId==mTI_pak || file->ToolId==mTI_dat || file->ToolId==mTI_xml)
            sln.PrintF("        %s /* %s */,\n",file->XCodeRefGuid,file->Name);
    }
    sln.Print ("      );\n");
    sln.Print ("      runOnlyForDeploymentPostprocessing = 0;\n");
    sln.Print ("    };\n");
    sln.Print ("/* End PBXResourcesBuildPhase section */\n");
    sln.Print ("\n");

    sln.Print ("/* Begin PBXSourcesBuildPhase section */\n");
    sln.PrintF("    %s /* Sources */ = {\n",guidPhaseSources);
    sln.Print ("      isa = PBXSourcesBuildPhase;\n");
    sln.Print ("      buildActionMask = 2147483647;\n");
    sln.Print ("      files = (\n");
    for(auto file : files)
    {
        switch(file->ToolId)
        {
        case mTI_cpp:
        case mTI_c:
        case mTI_m:
        case mTI_mm:
        case mTI_incbin:
        case mTI_packfile:
        case mTI_asc:
        case mTI_ops:
            //    case mTI_xib:
            sln.PrintF("        %s /* %s */,\n",file->XCodeRefGuid,file->Name);
            break;
        default:
            break;
        }
    }
    sln.Print ("      );\n");
    sln.Print ("      runOnlyForDeploymentPostprocessing = 0;\n");
    sln.Print ("    };\n");
    sln.Print ("/* End PBXSourcesBuildPhase section */\n");

    sln.Print ("\n");

    if(COOLLIBS)
    {
        sln.Print ("/* Begin PBXTargetDependency section */\n");
        for(auto dep : pro->Depends)
        {
            sln.PrintF("    %08X000000BD%08X /* lib%s.a */  = {\n",pro->GuidHash,dep->Project->GuidHash,dep->Project->Name);
            sln.Print ("      isa = PBXTargetDependency;\n");
            sln.PrintF("      name = %s;\n",dep->Project->Name);
            sln.PrintF("      targetProxy = %08X000000B3%08X /* PBXContainerItemProxy */;\n",pro->GuidHash,dep->Project->GuidHash);
            sln.Print ("    };\n");
        }
        sln.Print ("/* End PBXTargetDependency section */\n");

        sln.Print ("\n");
    }

    sln.Print ("/* Begin XCBuildConfiguration section */\n");
    sInt n;
    n = 1;
    for(auto con : pro->Configs)
    {
        sPoolString PbxPro("PBXProject");
        gr = con->VSGroups.Find([=](cVSGroup *g){return g->Name==PbxPro;});
        if(gr)
        {
            sln.PrintF("    %08X000000D1%08X /* %s */ = {\n",pro->GuidHash,n,con->Name);
            sln.Print ("      isa = XCBuildConfiguration;\n");
            sln.Print ("      buildSettings = {\n");
            for(auto it : gr->VSItems)
            {
                Resolve(LargeBuffer,it->Value);
                sln.PrintF("        %Q = %Q;\n",it->Key,LargeBuffer);
            }
            sln.Print ("      };\n");
            sln.PrintF("      name = %s;\n",con->Name);
            sln.Print ("    };\n");
        }
        sPoolString PbxNav("PBXNativeTarget");
        gr = con->VSGroups.Find([=](cVSGroup *g){return g->Name==PbxNav;});
        if(gr)
        {
            sln.PrintF("    %08X000000D2%08X /* %s */ = {\n",pro->GuidHash,n,con->Name);
            sln.Print ("      isa = XCBuildConfiguration;\n");
            sln.Print ("      buildSettings = {\n");
            for(auto it : gr->VSItems)
            {
                Resolve(LargeBuffer,it->Value);
                sln.PrintF("        %Q = %Q;\n",it->Key,LargeBuffer);
            }
            sln.Print ("      };\n");
            sln.PrintF("      name = %s;\n",con->Name);
            sln.Print ("    };\n");
        }
        n++;
    }
    sln.Print ("/* End XCBuildConfiguration section */\n");

    sln.Print ("\n");

    sln.Print ("/* Begin XCConfigurationList section */\n");
    sln.PrintF("    %s /* Build configuration list for PBXProject  */ = {\n",guidBuildProject);
    sln.Print ("      isa = XCConfigurationList;\n");
    sln.Print ("      buildConfigurations = (\n");
    n = 1;
    for(auto con : pro->Configs)
        sln.PrintF("        %08X000000D1%08X /* %s */,\n",pro->GuidHash,n++,con->Name);
    sln.Print ("      );\n");
    sln.Print ("      defaultConfigurationIsVisible = 0;\n");
    sln.Print ("    };\n");
    sln.PrintF("    %s /* Build configuration list for PBXNativeTarget  */ = {\n",guidBuildTarget);
    sln.Print ("      isa = XCConfigurationList;\n");
    sln.Print ("      buildConfigurations = (\n");
    n = 1;
    for(auto con : pro->Configs)
        sln.PrintF("        %08X000000D2%08X /* %s */,\n",pro->GuidHash,n++,con->Name);
    sln.Print ("      );\n");
    sln.Print ("      defaultConfigurationIsVisible = 0;\n");
    sln.Print ("    };\n");
    sln.Print ("/* End XCConfigurationList section */\n");

    sln.Print ("\n");

    sln.Print ("  };\n");
    sln.PrintF("  rootObject = %s /* Project object */;\n",guidProject);
    sln.Print ("}\n");

    // done

    if(!Pretend)
    {
        sString<sMaxPath> buffer;
        buffer.PrintF("%s/%s_%s.xcodeproj",basepath,pro->Name,Platform->Name);
        sMakeDir(buffer);
        buffer.PrintF("%s/%s_%s.xcodeproj/project.pbxproj",basepath,pro->Name,Platform->Name);
        if(!sSaveTextAnsi(buffer,sln.Get(),0)) ok = 0;
      
        if (!pro->Library && !shell)
        {
        	if(Platform->Name=="ios")
        	{
          		buffer.PrintF("%s/%s/ios.info.plist",basepath,pro->Name);
          		if(!sCheckFile(buffer) || ForceInfo)
            		sSaveTextUTF8(buffer,plist_txt);
        	}
            else
        	{
          		buffer.PrintF("%s/%s/osx.info.plist",basepath,pro->Name);
          		if(!sCheckFile(buffer) || ForceInfo)
            		sSaveTextUTF8(buffer,osxplist_txt);
            }
        }
    }
    if(pro->Dump)
    {
        sDPrint("------------------------------------------------------------------------------\n");
        sDPrint(sln.Get());
        sDPrint("------------------------------------------------------------------------------\n");
    }


    AdditionalFiles.DeleteAll();

    return ok;
}
Beispiel #8
0
bool DumpMemory()
{
    // whats up?

    if(Active==0) return 0;
    if(Active==2) return 0;
    if(LeakCount==0)
    {
        sLog("sys","no memory leaks detected\n\n");
        return 1;
    }
    if(LeakCount<0)
    {
        sDPrint("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        sDPrint("negative number of leaks - this can't be\n");
        return 0;
    }

    // make linear array of all leaks

    sArray<Leak> Leaks;
    int count = LeakCount;
    Leak *data = (Leak *) sAllocMemSystem(count*sizeof(Leak),4,0);
    Leaks.OverrideStorage(data,count);
    for(int i=0;i<HashSize;i++)
    {
        Leak *n = Hash[i];
        while(n)
        {
            Leaks.Add(*n);
            n = n->Next;
        }
    }
    sASSERT(count==Leaks.GetCount());
    Leaks.QuickSort(cmp());

    // merge

    {
        sptr count = Leaks.GetCount();
        Leak *data = Leaks.GetData();
        int d = 0;
        int s = 0;
        while(s<count)
        {
            if(d>0 && data[d-1].Line==data[s].Line && sCmpString(data[d-1].File,data[s].File)==0)
            {
                data[d-1].Count++;
                data[d-1].Size += data[s].Size;
                data[d-1].Id = sMin(data[d].Id,data[s].Id);
                s++;
            }
            else
            {
                data[d++] = data[s++];
            }
        }
        Leaks.SetSize(d);
    }

    // sort for output

    Leaks.QuickSort(cmp2());

    // output (combined)

    sDPrint("/****************************************************************************/\n");
    sDPrint("/***                                                                      ***/\n");
    sDPrint("/***   memory leaks!                                                      ***/\n");
    sDPrint("/***                                                                      ***/\n");
    sDPrint("/****************************************************************************/\n");
    sDPrint("\n");
    sDPrintF("file(line):                                                   size count    id\n");
    sDPrint("\n");
    for(auto &n : Leaks)
    {
        sString<256> buffer;
        buffer.PrintF("%s(%d):",n.File,n.Line);
        sDPrintF("%-60s%6K %5d %5d\n",buffer,n.Size,n.Count,n.Id);
    }
    sDPrint("\n");
    sDPrint("/****************************************************************************/\n\n");

    // done

    Leaks.OverrideStorage(0,0);

    sFreeMemSystem(data);
    return 0;
}
Beispiel #9
0
 inline bool operator()(const Leak &a,const Leak &b) const 
 { if(a.Size!=b.Size) return a.Size>b.Size; int r=sCmpString(a.File,b.File); if(r!=0) return r<0; return a.Line<b.Line; }
Beispiel #10
0
void sMain()
{
  Document Doc;
  sString<sMAXPATH> path;
  const sChar *proj;
  sString<sMAXPATH> configbuffer;
  sString<sMAXPATH> projbuffer;

  // command line parameters

  Doc.WriteFlag = !(sGetShellSwitch(L"p")||sGetShellSwitch(L"-pretend"));
  Doc.CheckLicenseFlag = sGetShellSwitch(L"l")||sGetShellSwitch(L"-license");
  Doc.TestFlag = sGetShellSwitch(L"t")||sGetShellSwitch(L"-test");
  Doc.DebugFlag = sGetShellSwitch(L"d")||sGetShellSwitch(L"-debug");
  Doc.BriefFlag = !(sGetShellSwitch(L"v")||sGetShellSwitch(L"-verbose"));
  Doc.CreateNewFiles = sGetShellSwitch(L"c")||sGetShellSwitch(L"-create");

  if(sGetShellParameter(L"r",0))                    
    path.PrintF(L"%p",sGetShellParameter(L"r",0)); // this converts '\\' to '/'
  else
    path.PrintF(L"%p",sCONFIG_CODEROOT);
  

  const sChar *depPattern = sGetShellParameter(L"D",0);

  projbuffer = path;
  projbuffer.AddPath(sCONFIG_MP_TEMPLATES);
  proj = projbuffer;

  Doc.RootPath.RootPath[OmniPath::PT_SYSTEM]    = path;
  Doc.RootPath.RootPath[OmniPath::PT_SOLUTION]  = path; // was sCONFIG_CODEROOT_WINDOWS, which was sCONFIG_CODEROOT, but doesn't work -r param
  SetTildeExpand(Doc.RootPath.RootPath[OmniPath::PT_MAKEFILE],path);

  configbuffer = path;
  configbuffer.AddPath(sCONFIG_CONFIGFILE);
  Doc.ConfigFile.Scan(configbuffer);
  Doc.ConfigFile.DPrint();

  if(sCmpString(Doc.ConfigFile.VSVersion,L"2008")>=0)
  {
    Doc.VS_Version = 9;
    Doc.VS_ProjectVersion  = 9;
    Doc.VS_SolutionVersion = 10; 
  }

  if(sCmpString(Doc.ConfigFile.VSVersion,L"2010")>=0)
  {
    Doc.VS_ProjExtension = L".vcxproj";
    Doc.VS_Version = 10;
    Doc.VS_ProjectVersion  = 10;
    Doc.VS_SolutionVersion = 11; 
  }

	if(sCmpString(Doc.ConfigFile.VSVersion,L"2012")>=0)
  {
    Doc.VS_ProjExtension = L".vcxproj";
    Doc.VS_Version = 11;
    Doc.VS_ProjectVersion  = 10;
    Doc.VS_SolutionVersion = 11; 
  }

  Doc.IntermediatePath.RootPath[OmniPath::PT_SYSTEM] = Doc.ConfigFile.IntermediateRoot;
  Doc.IntermediatePath.RootPath[OmniPath::PT_SOLUTION] = Doc.ConfigFile.IntermediateRoot;
  SetTildeExpand(Doc.IntermediatePath.RootPath[OmniPath::PT_MAKEFILE],Doc.ConfigFile.IntermediateRoot);

  Doc.OutputPath.RootPath[OmniPath::PT_SYSTEM] = Doc.ConfigFile.OutputRoot;
  Doc.OutputPath.RootPath[OmniPath::PT_SOLUTION] = Doc.ConfigFile.OutputRoot;
  SetTildeExpand(Doc.OutputPath.RootPath[OmniPath::PT_MAKEFILE],Doc.ConfigFile.OutputRoot);

  Doc.VSPlatformMask = 0;
  if(Doc.ConfigFile.Solution & sSLN_WIN32)    Doc.VSPlatformMask |= sVSPLAT_WIN32;
  if(Doc.ConfigFile.Solution & sSLN_WIN64)    Doc.VSPlatformMask |= sVSPLAT_WIN64;
  Doc.ConfMakefile = Document::MF_NONE;
  if(Doc.ConfigFile.Makefile==sMAKE_MINGW)    Doc.ConfMakefile = Document::MF_MINGW;
  if(Doc.ConfigFile.Makefile==sMAKE_LINUX)    Doc.ConfMakefile = Document::MF_LINUX;


  sPrintF(L"makeproject v%d.%d\n",VERSION,REVISION);

  if(sGetShellSwitch(L"vs"))
  {
    sPrint(L"the '-vs' option is obsolete. please use 'altona_config.hpp'\n");
  }
  else if(sGetShellSwitch(L"h")||sGetShellSwitch(L"-help"))
  {
    sPrint(L"makeproject [options]\n");
    sPrint(L"-r path       root (default c:/svn2)\n");
    sPrint(L"-h --help     print this text\n");
    sPrint(L"-p --pretend  don't write destination files\n");
    sPrint(L"-t --test     write to .vsproj.txt\n");
    sPrint(L"-d --debug    output parser tree\n");
    sPrint(L"-v --verbose  more output\n");
    sPrint(L"-l --license  check and fix license header in all sources\n");
    sPrint(L"-c --create   create new files.\n");
    sPrint(L"-D pattern    write dependency graph of matching solutions.\n");
  }
  else if(path)
  {
    if(Doc.ParseGlobal(proj))
    {
      sPrintF(L"Scan for projects...\n");
      if (Doc.ScanForSolutions(&Doc.RootPath))
      {
        if(Doc.WriteFlag)
          sPrintF(L"Write Projects...\n");

        Doc.WriteProjectsAndSolutions();

        if(depPattern)
        {
          sPrintF(L"Write dependency graphs....\n");
          Doc.WriteDependencyGraphs(depPattern);
        }
        
        sPrintF(L"%d Configurations.\n",Doc.GetConfigCount());
        Doc.Cleanup();
      }
    }
  }
}
Beispiel #11
0
void wDocument::HlslDecl()
{
    while(Scan->IfToken('['))
    {
        OutPtr->Print("[");
        for(;;)
        {
            OutPtr->Print(Scan->ScanName());
            while(Scan->IfToken('.'))
                OutPtr->PrintF(".%s",Scan->ScanName());
            if(Scan->IfToken('('))
            {
                OutPtr->Print("(");
                while(1)
                {
                    HlslExpr();
                    if(!Scan->IfToken(','))
                        break;
                    OutPtr->Print(",");
                }
                OutPtr->Print(")");
                Scan->Match(')');
            }
            if(Scan->IfToken(','))
                OutPtr->Print(",");
            else
                break;
        }
        OutPtr->Print("]\n");
        Scan->Match(']');
    }
    while(HlslIsStorageClass())
    {
        Scan->PrintToken(*OutPtr);
        Scan->Scan();
    }
    while(HlslIsTypeModifer())
    {
        Scan->PrintToken(*OutPtr);
        Scan->Scan();
    }
    if(Scan->IfName("precise "))
    {
        OutPtr->Print("precise ");
    }

    sBool found = 0;
    if(Scan->Token==sTOK_Name)
    {
        static const sChar *names[] =
        {
            "SamplerState",
            "Sampler1D",
            "Sampler2D",
            "Sampler3D",
            "SamplerCube",
            "Sampler1DArray",
            "Sampler2DArray",
            "Sampler3DArray",
            "SamplerCubeArray",
            "SamplerComparisonState",
            "Texture1D",
            "Texture1DArray",
            "Texture2D",
            "Texture2DArray",
            "Texture2DMS",
            "Texture2DMSArray",
            "Texture3D",
            "TextureCube",
            "TextureCubeArray",

            "AppendStructuredBuffer",
            "Buffer",
            "ByteAddressBuffer",
            "ConsumeStructuredBuffer",
            "StructuredBuffer",
            "RWBuffer",
            "RWByteAddressBuffer",
            "RWStructuredBuffer",
            "RWTexture1D",
            "RWTexture1DArray",
            "RWTexture2D",
            "RWTexture2DArray",
            "RWTexture3D",
            "RWTextureCube",
            "RWTextureCubeArray",
        };

        for(sInt i=0;i<sCOUNTOF(names) && !found;i++)
        {
            if(sCmpString(names[i],Scan->Name)==0)
                found = 1;
        }
        if(found)
        {
            OutPtr->PrintF("%s",Scan->ScanName());
        }

        HlslTemplateArgs();
    }
    if(!found)
        HlslType();

    sPoolString name = Scan->ScanName();
    OutPtr->PrintF(" %s ",name);

    sBool func = Scan->IfToken('(');
    if(func)
    {
        OutPtr->Print("(");
        if(Scan->Token!=')')
        {
            for(;;)
            {
                while(Scan->Token==TokIn || Scan->Token==TokOut || Scan->Token==TokInOut || Scan->Token==TokUniform || 
                    (Scan->Token==sTOK_Name && (Scan->Name=="point" || Scan->Name=="line" || Scan->Name=="triangle" || Scan->Name=="lineadj" || Scan->Name=="triangleadj")))
                {
                    Scan->PrintToken(*OutPtr);
                    Scan->Scan();
                }

                if(!HlslType())
                    Scan->Error("type expected");

                OutPtr->PrintF(" %s",Scan->ScanName());

                if(Scan->IfToken('['))
                {
                    OutPtr->Print("[");
                    HlslExpr();
                    OutPtr->Print("]");
                    Scan->Match(']');
                }

                if(Scan->IfToken(':'))
                    OutPtr->PrintF(" : %s",Scan->ScanName());

                if(Scan->IfName("linear")) 
                    OutPtr->Print("linear ");
                else if(Scan->IfName("centroid")) 
                    OutPtr->Print("centroid ");
                else if(Scan->IfName("nointerpolation")) 
                    OutPtr->Print("nointerpolation ");
                else if(Scan->IfName("noperspective")) 
                    OutPtr->Print("noperspective ");
                else if(Scan->IfName("sample")) 
                    OutPtr->Print("sample ");

                if(Scan->IfToken('='))
                {
                    OutPtr->Print(" = ");
                    HlslExpr();
                }

                if(Scan->IfToken(','))
                    OutPtr->Print(",");
                else
                    break;
            }
        }
        Scan->Match(')');
        OutPtr->Print(")");
    }

    while(Scan->IfToken('['))
    {
        OutPtr->Print("[");
        HlslExpr();
        OutPtr->Print("]");
        Scan->Match(']');
    }

    if(Scan->IfToken('='))
    {
        OutPtr->Print("=");
        HlslExpr();
    }

    if(Scan->IfToken(':'))
    {
        Scan->Match(TokRegister);
        Scan->Match('(');
        OutPtr->PrintF(" : register(%s)",Scan->ScanName());
        Scan->Match(')');
    }

    if(func)
    {
        if(Scan->Token!='{')
            Scan->Error("'{' expected");
        OutPtr->Print("\n");
        HlslBlock(0);
    }
    else
    {
        Scan->Match(';');
        OutPtr->Print(";\n");
    }
    OutPtr->Print("\n");
}
Beispiel #12
0
sBool wDocument::HlslType()
{
    if(Scan->Token!=sTOK_Name)
        return 0;

    // already known type?

    for(auto &pstr : Typenames)
    {
        if(pstr == Scan->Name)
        {
            OutPtr->PrintF("%s",Scan->Name);
            Scan->Scan();
            return 1;
        }
    }

    if(Scan->IfToken(TokMatrix))
    {
        Scan->Match('<');
        OutPtr->Print("matrix<");
        HlslType();
        Scan->Match(',');
        OutPtr->PrintF(",%d",Scan->ScanInt());
        Scan->Match(',');
        OutPtr->PrintF(",%d>",Scan->ScanInt());
        Scan->Match('>');
        return 1;
    }

    if(Scan->IfToken(TokVector))
    {
        Scan->Match('<');
        OutPtr->Print("vector");
        HlslType();
        Scan->Match(',');
        OutPtr->PrintF(",%d>",Scan->ScanInt());
        Scan->Match('>');
        return 1;
    }

    // parse normal type. 

    sBool ok = 0;
    if(Scan->IfName("snorm"))
    {
        ok = 1;
        OutPtr->Print("snorm ");
    }
    else if(Scan->IfName("unorm"))
    {
        ok = 1;
        OutPtr->Print("unorm ");
    }

    if(Scan->Token!=sTOK_Name)
        return ok;


    sString<64> buffer = (const sChar *) Scan->Name;
    sInt len = sGetStringLen(buffer);
    if(len>1 && buffer[len-1]>='1' && buffer[len-1]<='4')
    {
        len--;
        if(len>2 && buffer[len-1]=='x' && buffer[len-2]>='1' && buffer[len-2]<='4')
            len-=2;
        buffer[len] = 0;
    }
    const sChar *typenames[] = 
    {
        "void","bool","int","uint","float","double",
        "min16float","min10float","min16int","min12int","min16uint",
        "TriangleStream","LineStream","PointStream","InputPatch","OutputPatch",
    };


    sBool found = 0;
    for(sInt i=0;i<sCOUNTOF(typenames) && !found;i++)
        if(sCmpString(typenames[i],buffer)==0)
            found = 1;

    if(!found) 
        return ok;

    OutPtr->Print(Scan->Name);
    Scan->Scan();
    HlslTemplateArgs();
    return 1;
}
Beispiel #13
0
sBool wDocument::GlslType()
{
    // already known type?

    for(auto &pstr : Typenames)
    {
        if(pstr == Scan->Name)
        {
            OutPtr->PrintF("%s",Scan->Name);
            Scan->Scan();
            return 1;
        }
    }

    if(Scan->IfToken(TokMatrix))
    {
        Scan->Match('<');
        OutPtr->Print("matrix<");
        GlslType();
        Scan->Match(',');
        OutPtr->PrintF(",%d",Scan->ScanInt());
        Scan->Match(',');
        OutPtr->PrintF(",%d>",Scan->ScanInt());
        Scan->Match('>');
        return 1;
    }

    if(Scan->IfToken(TokVector))
    {
        Scan->Match('<');
        OutPtr->Print("vector<");
        GlslType();
        Scan->Match(',');
        OutPtr->PrintF(",%d>",Scan->ScanInt());
        Scan->Match('>');
        return 1;
    }

    // parse normal type. 

    sBool ok = 0;
    if(Scan->IfName("highp"))
    {
        ok = 1;
        if(Platform==sConfigRenderGLES2)
          OutPtr->Print("highp ");
    }
    else if(Scan->IfName("lowp"))
    {
        ok = 1;
        if(Platform==sConfigRenderGLES2)
          OutPtr->Print("lowp ");
    }
    else if(Scan->IfName("mediump"))
    {
        ok = 1;
        if(Platform==sConfigRenderGLES2)
          OutPtr->Print("mediump ");
    }

    if(Scan->Token!=sTOK_Name)
        return ok;


    sString<64> buffer = (const sChar *) Scan->Name;
    sInt len = sGetStringLen(buffer);

    const sChar *typenames[] = 
    {
        "void","bool","int","uint","float","double",0
    };
    const sChar *vectornames[] = 
    {
        "vec","ivec","uvec","dvec","bvec",0
    };
    const sChar *matrixnames[] = 
    {
        "mat","dmat",0
    };

    const sChar **names = typenames;

    sInt cl = 0;
    if(len>1 && buffer[len-1]>='1' && buffer[len-1]<='4')
    {
        names = vectornames;
        len--;
        if(len>2 && buffer[len-1]=='x' && buffer[len-2]>='1' && buffer[len-2]<='4')
        {
            names = matrixnames;
            len-=2;      
        }
        buffer[len] = 0;
    }

    sBool found = 0;
    for(sInt i=0;names[i] && !found;i++)
        if(sCmpString(names[i],buffer)==0)
            found = 1;

    if(!found) 
        return ok;

    OutPtr->Print(Scan->Name);
    Scan->Scan();
    return 1;
}
Beispiel #14
0
void sXSILoader::ScanMesh(sInt indent,sXSIModel *model)
{
  sChar buffer[256];
  sChar chunk[XSISIZE];
  sChar name[XSISIZE];
  sChar *cmd;
  sInt supports,i,j,k,max;
  sInt fcount;
  sInt vcount;
  sXSICluster *cluster;
  sInt cr,cg,cb,ca;
  sInt set,set2;

  sInt PosCount;
  sVector *Pos;
  sInt NormCount;
  sVector *Norm;
  sInt ColorCount;
  sU32 *Color;
  sInt UVCount[sXSI_MAXUV];
  sF32 *UV[sXSI_MAXUV];
  sChar UVName[sXSI_MAXUV][XSISIZE];

// init shape holder

  PosCount = 0;
  Pos = 0;
  NormCount = 0;
  Norm = 0;
  ColorCount = 0;
  Color = 0;
  for(i=0;i<sXSI_MAXUV;i++)
  {
    UVCount[i] = 0;
    UV[i] = 0;
  }

  while(*Scan!=0 && *Scan!='}' && !Error)
  {
    ScanChunk(indent,chunk,name);

    if(sCmpString(chunk,"SI_Shape")==0)
    {
      supports = ScanInt();
      ScanString(buffer,sizeof(buffer));
      if(sCmpString(buffer,"ORDERED")!=0)
        Error = sTRUE;

      for(i=0;i<supports && !Error;i++)
      {
        max = ScanInt();
        ScanString(buffer,sizeof(buffer));
        if(sCmpString(buffer,"POSITION")==0)
        {
          sVERIFY(Pos==0);
          PosCount = max;
          Pos = new sVector[max];

          for(j=0;j<max;j++)
          {
            Pos[j].x = ScanFloat();
            Pos[j].y = ScanFloat();
            Pos[j].z = ScanFloat();
          }
        }
        else if(sCmpString(buffer,"NORMAL")==0)
        {
          sVERIFY(Norm==0);
          NormCount = max;
          Norm = new sVector[max];

          for(j=0;j<max;j++)
          {
            Norm[j].x = ScanFloat();
            Norm[j].y = ScanFloat();
            Norm[j].z = ScanFloat();
          }
        }
        else if(sCmpString(buffer,"COLOR")==0)
        {
          sVERIFY(Color==0);
          ColorCount = max;
          Color = new sU32[max];

          for(j=0;j<max;j++)
          {
            cr = sRange<sInt>(ScanFloat()*255,255,0);
            cg = sRange<sInt>(ScanFloat()*255,255,0);
            cb = sRange<sInt>(ScanFloat()*255,255,0);
            ca = sRange<sInt>(ScanFloat()*256,255,0);
            Color[j] = (ca<<24)|(cb<<16)|(cg<<8)|(cr);
          }
        }
        else if(sCmpString(buffer,"TEX_COORD_UV")==0)
        {
          set = 0;
          sVERIFY(UV[set]==0);
          UVCount[set] = max;
          UV[set] = new sF32[max*2];

          for(j=0;j<max;j++)
          {
            UV[set][j*2+0] = ScanFloat();
            UV[set][j*2+1] = 1.0f-ScanFloat();
          }
        }
        else if(sCmpMem(buffer,"TEX_COORD_UV",12)==0)
        {
          j=12;
          set = 0;
          while(buffer[j]>='0' && buffer[j]<='9')
            set = set*10 + (buffer[j++]-'0');
          sVERIFY(set>=0 && set<sXSI_MAXUV);
          sVERIFY(UV[set]==0);

          ScanString(UVName[set],sizeof(UVName[set]));

          UVCount[set] = max;
          UV[set] = new sF32[max*2];

          for(j=0;j<max;j++)
          {
            UV[set][j*2+0] = ScanFloat();
            UV[set][j*2+1] = 1.0f-ScanFloat();
          }
        }
        else 
        {
          Error = sTRUE;
        }
      }

      EndChunk();
    }
    else if(sCmpString(chunk,"SI_PolygonList")==0)
    {
      cluster = new sXSICluster;

      fcount = ScanInt();

      sCopyString(buffer,"|POSITION|",sizeof(buffer));
      i = sGetStringLen(buffer);
      ScanString(buffer+i,sizeof(buffer)-i);
#if DUMPCHUNK
      sDPrintF("  %s",buffer);
#endif

      ScanString(name,sizeof(name));
      cluster->Material = FindMaterial(name);

      vcount = ScanInt();
      cluster->VertexCount = vcount;
      cluster->IndexCount = vcount;

      cluster->Vertices = new sXSIVertex[vcount];
      cluster->Faces = new sInt[vcount*2];

      model->Clusters->Add(cluster);


      j = 0;
      for(i=0;i<fcount;i++)
      {
        max = ScanInt();
        cluster->Vertices[j].Init();
        cluster->Faces[j*2+0] = max;
        cluster->Faces[j*2+1] = j;
        j++;
        for(k=1;k<max;k++)
        {
          cluster->Vertices[j].Init();
          cluster->Faces[j*2+0] = 0;
          cluster->Faces[j*2+1] = j;
          j++;
        }
      }
      sVERIFY(j==vcount);

      cmd = buffer;
      while(!Error && *cmd)
      {
        if(sCmpMem(cmd,"|POSITION",9)==0)
        {
          cmd+=9;
          sVERIFY(Pos);
          for(i=0;i<vcount;i++)
          {
            j = ScanInt();
            cluster->Vertices[i].Pos = Pos[j];
            cluster->Vertices[i].Index = j;
          }
        }
        else if(sCmpMem(cmd,"|NORMAL",7)==0)
        {
          cmd+=7;
          sVERIFY(Norm);
          for(i=0;i<vcount;i++)
          {
            j = ScanInt();
            cluster->Vertices[i].Normal = Norm[j];
            cluster->Vertices[i].Normal.Init(0,0,0,1);
          }
        }
        else if(sCmpMem(cmd,"|COLOR",6)==0)
        {
          cmd+=6;
          sVERIFY(Color);
          for(i=0;i<vcount;i++)
          {
            j = ScanInt();
            cluster->Vertices[i].Color = Color[j];
          }
        }
        else if(sCmpMem(cmd,"|TEX_COORD_UV",13)==0)
        {
          cmd+=13;
          set = 0;
          if(*cmd>='0' && *cmd<='9')
          {
            while(*cmd>='0' && *cmd<='9')
              set = set*10 + ((*cmd++)-'0');

            sVERIFY(set>=0 && set<sXSI_MAXUV);
            sVERIFY(UV[set])
            for(set2=0;set2<4;set2++)
              if(sCmpString(TSName[cluster->Material->TUV[set2]],UVName[set])==0)
                break;
          }
          else
          {
            set2 = 0;
          }

          for(i=0;i<vcount;i++)
          {
            j = ScanInt();
            if(set2>=0 && set2<2)
            {
              cluster->Vertices[i].UV[set2][0] = 0.0f;// UV[set][j*2+0];
              cluster->Vertices[i].UV[set2][1] = 0.0f;// UV[set][j*2+1];
            }
          }
        }
        else
        {
Beispiel #15
0
void sXSILoader::ScanMatLib(sInt indent)
{
  sChar chunk[XSISIZE];
  sChar name[XSISIZE];
  sChar texname[256];
  sChar buffer[XSISIZE];
  sChar pname[XSISIZE];
  sChar tname[XSISIZE];
  sChar tsup[2][XSISIZE];
  sInt texena[2];

  sXSIMaterial *mat;
  sXSITexture *tex;
  sInt i,max;
  sInt pcount,ccount;
  sInt ival;
  sF32 fval;

  ScanInt();
  while(*Scan!=0 && *Scan!='}' && !Error)
  {
    ScanChunk(indent,chunk,name);

    if(sCmpString(chunk,"SI_Material")==0)
    {
      mat = new sXSIMaterial;
      sCopyString(mat->Name,name,sizeof(mat->Name));
      mat->Flags |= 0;
      Materials->Add(mat);

      ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
      ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
      ScanFloat(); ScanFloat(); ScanFloat(); 
      ScanInt();
      ScanFloat(); ScanFloat(); ScanFloat();

      sScanSpace(Scan);
      while(*Scan!=0 && *Scan!='}' && !Error)
      {
        ScanChunk(indent+1,chunk,name);
        if(sCmpString(chunk,"SI_Texture2D")==0)
        {
          ScanString(texname,sizeof(texname));
          ScanInt(); ScanInt(); ScanInt(); ScanInt();
          ScanInt(); ScanInt(); ScanInt(); ScanInt();
          ScanInt(); ScanInt(); ScanInt(); ScanInt();
          ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
          ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
          ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
          ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
          ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
          ScanInt();
          ScanFloat(); ScanFloat(); ScanFloat(); ScanFloat();
          ScanFloat(); ScanFloat(); ScanFloat();
          EndChunk();

          if(mat->Tex[0] == 0)
          {
            tex = FindTexture(texname);
            if(tex)
              mat->Tex[0] = tex;
          }
        }
        else
        {
          SkipChunk();
        }
        sScanSpace(Scan);
      }
      EndChunk();
    }
    else if(sCmpString(chunk,"XSI_Material")==0)
    {
      mat = new sXSIMaterial;
      sCopyString(mat->Name,name,sizeof(mat->Name));
      mat->TFlags[0] = 0;
      mat->TFlags[1] = 0;
      mat->Flags |= 0;
			sDPrintF("%08x:<%s>\n",Scan,name);
      Materials->Add(mat);


      max = ScanInt();
      for(i=0;i<max;i++)
      {
        ScanString(buffer,sizeof(buffer));
        ScanString(buffer,sizeof(buffer));
      }
      sScanSpace(Scan);
      tsup[0][0]=0;
      tsup[0][1]=0;
      texena[0] = 0;
      texena[1] = 0;
      while(*Scan!=0 && *Scan!='}' && !Error)
      {
        ScanChunk(indent+1,chunk,name);

        if(sCmpString(chunk,"XSI_Shader")==0)
        {
          ScanString(buffer,sizeof(buffer));
          ScanInt();
          pcount = ScanInt();
          ccount = ScanInt();
          for(i=0;i<pcount;i++)
          {
            ScanString(pname,sizeof(pname));
            ScanString(tname,sizeof(tname));
            if(sCmpString(tname,"STRING")==0)
            {
              ScanString(buffer,sizeof(buffer));
              if(sCmpString(pname,"tspace_id1")==0)   sCopyString(tsup[0],buffer,sizeof(tsup[0]));
              if(sCmpString(pname,"tspace_id" )==0)   sCopyString(tsup[0],buffer,sizeof(tsup[0]));
              if(sCmpString(pname,"tspace_id2")==0)   sCopyString(tsup[1],buffer,sizeof(tsup[1]));
            }
            else if(sCmpString(tname,"FLOAT")==0)
            {
              fval = ScanFloat();
              ival = sRange<sInt>(255*fval,255,0);
              if(sCmpString(pname,"Ambient.red")==0)    mat->Ambient.r = ival;
              if(sCmpString(pname,"Ambient.green")==0)  mat->Ambient.g = ival;
              if(sCmpString(pname,"Ambient.blue")==0)   mat->Ambient.b = ival;
              if(sCmpString(pname,"Diffuse.red")==0)    mat->Diffuse.r = ival;
              if(sCmpString(pname,"Diffuse.green")==0)  mat->Diffuse.g = ival;
              if(sCmpString(pname,"Diffuse.blue")==0)   mat->Diffuse.b = ival;
              if(sCmpString(pname,"Specular.red")==0)   mat->Specular.r = ival;
              if(sCmpString(pname,"Specular.green")==0) mat->Specular.g = ival;
              if(sCmpString(pname,"Specular.blue")==0)  mat->Specular.b = ival;
              if(sCmpString(pname,"Shininess")==0)      mat->Specularity = fval;
            }
            else if(sCmpString(tname,"INTEGER")==0)
            {
              ival = ScanInt();
            }
            else if(sCmpString(tname,"BOOLEAN")==0)
            {
              ival = ScanInt();
              if(ival!=0)
              {
//                if(sCmpString(pname,"WrapS1")==0)     mat->TFlags[0] |= sMTF_TILE;
//                if(sCmpString(pname,"WrapT1")==0)     mat->TFlags[0] |= sMTF_TILE;
                if(sCmpString(pname,"Refmap1")==0)    mat->TFlags[0] |= sMTF_UVENVI;
                if(sCmpString(pname,"Texture_1_Enable")==0) texena[0]=1;

//                if(sCmpString(pname,"WrapS2")==0)     mat->TFlags[1] |= sMTF_TILE;
//                if(sCmpString(pname,"WrapT2")==0)     mat->TFlags[1] |= sMTF_TILE;
                if(sCmpString(pname,"Refmap2")==0)    mat->TFlags[1] |= sMTF_UVENVI;
                if(sCmpString(pname,"Texture_2_Enable")==0) texena[1]=1;
              }
              else
              {
                if(sCmpString(pname,"Enable_Ambient")==0)  mat->Ambient = 0xffffffff;
                if(sCmpString(pname,"Enable_Diffuse")==0)  mat->Diffuse = 0xffffffff;
                if(sCmpString(pname,"Enable_Specular")==0) mat->Specular = 0xffffffff;
                if(sCmpString(pname,"Enable_Shininess")==0) mat->Specularity = 0;
//                if(sCmpString(pname,"Enable_Lighting")==0) mat->Flags &= ~sMF_LIGHTMASK;
              }
              
            }
            else
            {
              Error = sTRUE;
            }
          }
          for(i=0;i<ccount;i++)
          {
            ScanString(pname,sizeof(pname));
            ScanString(buffer,sizeof(buffer));
            ScanString(tname,sizeof(tname));
            if(sCmpString(tname,"IMAGE")==0)
            {
              if((sCmpString(pname,"Texture_1")==0 || sCmpString(pname,"tex")==0) && texena[0])
              {
                if(mat->Tex[0] == 0 
                  && (tsup[0][0]!=0 || (mat->TFlags[0]&sMTF_UVMASK)==sMTF_UVENVI) 
                  && TSCount<sXSI_MAXTS)
                {
                  tex = FindTexture(buffer);
                  if(tex)
                  {
                    mat->Tex[0] = tex;
                    mat->Mode = sMBM_TEX;
                    sCopyString(TSName[TSCount],tsup[0],XSISIZE);
                    mat->TUV[0] = TSCount++;
                  }
                }
              }

              if(sCmpString(pname,"Texture_2")==0 && texena[1])
              {
                if(mat->Tex[1] == 0 
                  && (tsup[1][0]!=0 || (mat->TFlags[1]&sMTF_UVMASK)==sMTF_UVENVI) 
                  && TSCount<sXSI_MAXTS)
                {
                  tex = FindTexture(buffer);
                  if(tex)
                  {
                    mat->Tex[1] = tex;
                    mat->Mode = sMBM_MUL;
//                    mat->TFlags[1] = sMTF_FILTER|sMTF_MIPMAP;//|sMTF_UVENVI;
                    sCopyString(TSName[TSCount],tsup[1],XSISIZE);
                    mat->TUV[1] = TSCount++;
                  }
                }
              }
            }
          }
          sScanSpace(Scan);
          while(*Scan!=0 && *Scan!='}' && !Error)
          {
            ScanChunk(indent+1,chunk,name);
            SkipChunk();
            sScanSpace(Scan);
          }
          EndChunk();
        }
        else
        {
          SkipChunk();
        }
        sScanSpace(Scan);
      }      
      if((mat->TFlags[1] & sMTF_UVMASK)==0)
        mat->TFlags[1] |= sMTF_UV1;
      if(mat->Specularity>0.0001f || mat->Ambient!=0xffffffff 
        || mat->Diffuse != 0xffffffff || mat->Specular != 0xffffffff)
      {
//        mat->Flags = (mat->Flags & (~sMF_LIGHTMASK)) | sMF_LIGHTMAT;
//        sDPrintF("extlight: %08x %08x %08x\n",mat->Diffuse.Color,mat->Ambient.Color,mat->Specular.Color);
      }
      else
      {
//        mat->Flags |= sMF_COLBOTH;
      }
      mat->TFlags[0] |= sMTF_FILTERMIN | sMTF_FILTERMAG | sMTF_MIPMAP;
      mat->TFlags[1] |= sMTF_FILTERMIN | sMTF_FILTERMAG | sMTF_MIPMAP;
      EndChunk();
    }
    else
    {
      SkipChunk();
    }
    sScanSpace(Scan);
  }
  EndChunk();
}
Beispiel #16
0
void TestString()
{
  sCheckModule(L"sString");

  sString<512> t1(L"the quick brown fox jumps over the lazy dog");

  t1.CutLeft(4);          CHECK(sCmpString(t1, L"quick brown fox jumps over the lazy dog")==0);
  t1.CutRight(4);         CHECK(sCmpString(t1, L"quick brown fox jumps over the lazy")==0);
  t1.CutRange(6,6);       CHECK(sCmpString(t1, L"quick fox jumps over the lazy")==0);
  t1.CutRange(0,5);       CHECK(sCmpString(t1, L" fox jumps over the lazy")==0);
  t1.StripLeft();         CHECK(sCmpString(t1, L"fox jumps over the lazy")==0);
  t1.CutRange(19,4+666);  CHECK(sCmpString(t1, L"fox jumps over the ")==0);
  t1.StripRight();        CHECK(sCmpString(t1, L"fox jumps over the")==0);
  t1.StripLeft(L"fox");   CHECK(sCmpString(t1, L" jumps over the")==0);
  t1.StripRight(L"the");  CHECK(sCmpString(t1, L" jumps over ")==0);
  t1.Strip(L"\n\t");      CHECK(sCmpString(t1, L" jumps over ")==0);
  t1.Strip(L"  ");        CHECK(sCmpString(t1, L"jumps over")==0);
  t1.CutRange(-2,4);      CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutRange(-2,2);      CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutRange(10,2);      CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutRange( 3,0);      CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutRight( 0);        CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutRight(-10);       CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutLeft( 0);         CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutLeft(-10);        CHECK(sCmpString(t1, L"mps over")==0);
  t1.CutRange( 2,-3);     CHECK(sCmpString(t1, L"s over")==0);
  t1.CutRange( 4,-2);     CHECK(sCmpString(t1, L"s er")==0);
  t1.CutRange(66,-200);   CHECK(sCmpString(t1, L"")==0);
  t1.PadRight(3, L'a');   CHECK(sCmpString(t1, L"aaa")==0);
  t1.PadRight(4);         CHECK(sCmpString(t1, L"aaa ")==0);
  t1.PadRight(2);         CHECK(sCmpString(t1, L"aaa ")==0);
  t1.PadRight(-2);        CHECK(sCmpString(t1, L"aaa ")==0);
  t1.PadLeft(-2);         CHECK(sCmpString(t1, L"aaa ")==0);
  t1.PadLeft(0);          CHECK(sCmpString(t1, L"aaa ")==0);
  t1.PadLeft(5);          CHECK(sCmpString(t1, L" aaa ")==0);
  t1.PadLeft(6, L'\n');   CHECK(sCmpString(t1, L"\n aaa ")==0);
  t1.PadLeft(9, L'*');    CHECK(sCmpString(t1, L"***\n aaa ")==0);
  t1.Strip();             CHECK(sCmpString(t1, L"***\n aaa")==0);
  t1.Strip(L"*a");        CHECK(sCmpString(t1, L"\n ")==0);
  t1.Strip();             CHECK(sCmpString(t1, L"")==0);
}
Beispiel #17
0
void TestStringFunctions()
{
  sChar b0[256];
  sChar b1[256];

  sCheckModule(L"String Functions");

  sClear(b0);
  sClear(b1);

  CHECK(sCmpString(L"0000",L"0000")==0);
  CHECK(sCmpString(L"0000",L"000")!=0);
  CHECK(sCmpString(L"000",L"0000")!=0);
  CHECK(sCmpString(L"000",L"100")!=0);
  CHECK(sCmpString(L"000",L"010")!=0);
  CHECK(sCmpString(L"000",L"001")!=0);
  CHECK(sCmpString(L"100",L"100")==0);
  CHECK(sCmpString(L"010",L"010")==0);
  CHECK(sCmpString(L"001",L"001")==0);
  CHECK(sCmpString(L"001",L"002")<0);
  CHECK(sCmpString(L"002",L"001")>0);
  CHECK(sCmpString(L"021",L"012")>0);

  sCopyString(b0,L"000000000000",256);
  sCopyString(b0+4,L"1111",256);
  CHECK(sCmpString(b0,L"00001111")==0);
  CHECK(sCmpString(b0+9,L"000")==0);

  sCopyString(b0,L"abcd",6);
  CHECK(sCmpString(b0,L"abcd")==0);
  sCopyString(b0,L"abcd",5);
  CHECK(sCmpString(b0,L"abcd")==0);
  sCopyString(b0,L"abcd",4);
  CHECK(sCmpString(b0,L"abc")==0);
  sCopyString(b0,L"abcd",3);
  CHECK(sCmpString(b0,L"ab")==0);

  sCopyString(b0,L"abcd",256); sAppendString(b0,L"1234",10);
  CHECK(sCmpString(b0,L"abcd1234")==0);
  sCopyString(b0,L"abcd",256); sAppendString(b0,L"1234",9);
  CHECK(sCmpString(b0,L"abcd1234")==0);
  sCopyString(b0,L"abcd",256); sAppendString(b0,L"1234",8);
  CHECK(sCmpString(b0,L"abcd123")==0);
  sCopyString(b0,L"abcd",256); sAppendString(b0,L"1234",7);
  CHECK(sCmpString(b0,L"abcd12")==0);

  sCopyString(b0,L"aBcDeFgHiJkLmNoPqRsTuVwXyZ \n\t_:;öÄü-",256);
  sCopyString(b1,L"AbCdEfGhIjKlMnOpQrStUvWxYz \n\t_:;ÖäÜ-",256);

  sMakeUpper(b0);
  sMakeLower(b1); 
  sMakeUpper(b1);
  CHECK(sCmpString(b0,b1)==0);
  sMakeLower(b0); 
  sMakeLower(b1);
  CHECK(sCmpString(b0,b1)==0);

  CHECK(sFindString(b0, L"klmn") == 10);
  CHECK(sFindString(b0, L"KlMn") == -1);
  CHECK(sFindString(b0, L"abcd") == 0);
}
Beispiel #18
0
void wDocument::GlslDecl()
{
    while(GlslIsTypeModifer())
    {
        Scan->PrintToken(*OutPtr);
        Scan->Scan();
    }

    sBool found = 0;
    if(Scan->Token==sTOK_Name)
    {
        static const sChar *names[] =
        {
            "sampler1D",
            "sampler2D",
            "sampler3D",
            "samplerCube",
            "sampler2DRect",
            "sampler1DShadow",
            "sampler2DShadow",
            "sampler2DRectShadow",
            "sampler1DArray",
            "sampler2DArray",
            "sampler1DArrayShadow",
            "sampler2DArrayShadow",
            "samplerBuffer",
            "sampler2DMS",
            "sampler2DMSArray",
            "samplerCubeShadow",
            "samplerCubeArray",
            "samplerCubeArrayShadow",

            "isampler1D",
            "isampler2D",
            "isampler3D",
            "isamplerCube",
            "isampler2DRect",
            "isampler1DArray",
            "isampler2DArray",
            "isamplerBuffer",
            "isampler2DMS",
            "isampler2DMSArray",
            "isamplerCubeArray",

            "usampler1D",
            "usampler2D",
            "usampler3D",
            "usamplerCube",
            "usampler2DRect",
            "usampler1DArray",
            "usampler2DArray",
            "usamplerBuffer",
            "usampler2DMS",
            "usampler2DMSArray",
            "usamplerCubeArray",
        };

        for(sInt i=0;i<sCOUNTOF(names) && !found;i++)
        {
            if(sCmpString(names[i],Scan->Name)==0)
                found = 1;
        }
        if(found)
        {
            OutPtr->PrintF("%s",Scan->ScanName());
        }
    }
    if(!found)
        GlslType();

    sPoolString name = Scan->ScanName();

    if(found) // this is a sampler -> rename
    {
        sString<64> to;
        to.PrintF("%s_%d",name,GlslSamplerCount++);
        GlslReplacements.AddMany(1)->Set(name,to);
        name = to;
    }

    OutPtr->PrintF(" %s ",name);

    sBool func = Scan->IfToken('(');
    if(func)
    {
        OutPtr->Print("(");
        if(Scan->Token!=')')
        {
            for(;;)
            {
                while(Scan->Token==TokIn || Scan->Token==TokOut || Scan->Token==TokInOut || Scan->Token==TokUniform)
                {
                    Scan->PrintToken(*OutPtr);
                    Scan->Scan();
                }
                if(!GlslType())
                    Scan->Error("type expected");
                OutPtr->PrintF(" %s",Scan->ScanName());
                if(Scan->IfToken(':'))
                    OutPtr->PrintF(" : %s",Scan->ScanName());

                if(Scan->IfName("linear")) 
                    OutPtr->Print("linear ");
                else if(Scan->IfName("centroid")) 
                    OutPtr->Print("centroid ");
                else if(Scan->IfName("nointerpolation")) 
                    OutPtr->Print("nointerpolation ");
                else if(Scan->IfName("noperspective")) 
                    OutPtr->Print("noperspective ");
                else if(Scan->IfName("sample")) 
                    OutPtr->Print("sample ");

                if(Scan->IfToken('='))
                {
                    OutPtr->Print(" = ");
                    GlslExpr();
                }

                if(Scan->IfToken(','))
                    OutPtr->Print(",");
                else
                    break;
            }
        }
        OutPtr->Print(")");
        Scan->Match(')');
    }

    if(Scan->IfToken(':'))
    {
        Scan->Match(TokRegister);
        Scan->Match('(');
        OutPtr->PrintF(" : register(%s)",Scan->ScanName());
        Scan->Match(')');
    }

    if(func)
    {
        if(Scan->Token!='{')
            Scan->Error("'{' expected");
        OutPtr->Print("\n");
        GlslBlock(0);
    }
    else
    {
        Scan->Match(';');
        OutPtr->Print(";\n");
    }
    OutPtr->Print("\n");
}