コード例 #1
0
 private static extern bool NscCompileScriptExternal(
     IntPtr Compiler,
     string ScriptFileName,
     string OutputDirectory,
     bool FlushResources,
     bool GenerateDebugInfo,
     bool Optimize,
     bool IgnoreIncludes,
     int CompilerVersion,
     ref NSC_COMPILER_DISPATCH_TABLE DispatchTable);
コード例 #2
0
        private NSC_COMPILER_DISPATCH_TABLE CreateNscCompilerDispatchTable()
        {
            NSC_COMPILER_DISPATCH_TABLE DispatchTable = new NSC_COMPILER_DISPATCH_TABLE();

            DispatchTable.Size                        = (uint)Marshal.SizeOf(DispatchTable);
            DispatchTable.Context                     = IntPtr.Zero;
            DispatchTable.ResOpenFile                 = this.OpenFile;
            DispatchTable.ResOpenFileByIndex          = this.OpenFileByIndex;
            DispatchTable.ResCloseFile                = this.CloseFile;
            DispatchTable.ResReadEncapsulatedFile     = this.ReadEncapsulatedFile;
            DispatchTable.ResGetEncapsulatedFileSize  = this.GetEncapsulatedFileSize;
            DispatchTable.ResGetEncapsulatedFileType  = this.GetEncapsulatedFileType;
            DispatchTable.ResGetEncapsulatedFileEntry = this.GetEncapsulatedFileEntry;
            DispatchTable.ResGetEncapsulatedFileCount = this.GetEncapsulatedFileCount;
            DispatchTable.NscCompilerDiagnosticOutput = this.CompilerDiagnosticOutput;

            return(DispatchTable);
        }
コード例 #3
0
ファイル: NscCompiler.cs プロジェクト: jakkn/nwn2dev-public
        private NSC_COMPILER_DISPATCH_TABLE CreateNscCompilerDispatchTable()
        {
            NSC_COMPILER_DISPATCH_TABLE DispatchTable = new NSC_COMPILER_DISPATCH_TABLE();

            DispatchTable.Size = (uint)Marshal.SizeOf(DispatchTable);
            DispatchTable.Context = IntPtr.Zero;
            DispatchTable.ResOpenFile = this.OpenFile;
            DispatchTable.ResOpenFileByIndex = this.OpenFileByIndex;
            DispatchTable.ResCloseFile = this.CloseFile;
            DispatchTable.ResReadEncapsulatedFile = this.ReadEncapsulatedFile;
            DispatchTable.ResGetEncapsulatedFileSize = this.GetEncapsulatedFileSize;
            DispatchTable.ResGetEncapsulatedFileType = this.GetEncapsulatedFileType;
            DispatchTable.ResGetEncapsulatedFileEntry = this.GetEncapsulatedFileEntry;
            DispatchTable.ResGetEncapsulatedFileCount = this.GetEncapsulatedFileCount;
            DispatchTable.NscCompilerDiagnosticOutput = this.CompilerDiagnosticOutput;

            return DispatchTable;
        }
コード例 #4
0
ファイル: NscCompiler.cs プロジェクト: jakkn/nwn2dev-public
 private static extern bool NscCompileScriptExternal(
     IntPtr Compiler,
     string ScriptFileName,
     string OutputDirectory,
     bool FlushResources,
     bool GenerateDebugInfo,
     bool Optimize,
     bool IgnoreIncludes,
     int CompilerVersion,
     ref NSC_COMPILER_DISPATCH_TABLE DispatchTable);
コード例 #5
0
        //
        // Compile a script using the specified resource system.  Any errors
        // are returned; if the empty string is returned, the compilation
        // succeeded (but potentially with warnings).
        //

        public string CompileScript(string Name, string OutputDirectory, bool GenerateDebugInfo, out string WarningOutput)
        {
            bool   Status;
            string CompilerDiagnosticOutput;
            NSC_COMPILER_DISPATCH_TABLE DispatchTable = CreateNscCompilerDispatchTable();

            WarningOutput = "";

            if (m_Compiling)
            {
                return("Compiler is busy.");
            }

            //
            // Setup the dispatch table and invoke the script compiler.
            //

            if (m_Compiler == IntPtr.Zero)
            {
                m_Compiler = NscCreateCompiler(true);

                if (m_Compiler == IntPtr.Zero)
                {
                    return("Failed to instantiate NscCompiler.");
                }
            }

            m_CompilerDiagnosticsLog = null;

            m_Compiling = true;

            try
            {
                Status = NscCompileScriptExternal(
                    m_Compiler,
                    Name,
                    OutputDirectory,
                    m_ResourceAccessor.IsIndexInvalidationPending(),
                    GenerateDebugInfo || m_SettingsManager.EnableDebugSymbols,
                    true,
                    true,
                    m_SettingsManager.CompilerVersion, // Compiler version (NWN1 v1.69 drop)
                    ref DispatchTable);
            }
            catch
            {
                m_Compiling = false;
                throw;
            }

            m_Compiling = false;

            m_ResourceAccessor.AcknowledgeIndexInvalidation();

            CompilerDiagnosticOutput = m_CompilerDiagnosticsLog;

            if (CompilerDiagnosticOutput == null)
            {
                CompilerDiagnosticOutput = "";
            }

            m_CompilerDiagnosticsLog = null;

            //
            // If we succeeded but have diagnostics still, record them as
            // warning output.  Otherwise consider the output error output.
            //

            if (Status)
            {
                WarningOutput = CompilerDiagnosticOutput;
                return("");
            }
            else
            {
                WarningOutput = "";

                if (CompilerDiagnosticOutput == "")
                {
                    CompilerDiagnosticOutput = "ERROR: INTERNAL COMPILER ERROR, NO DIAGNOSTICS RETURNED";
                }

                return(CompilerDiagnosticOutput);
            }
        }