Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge gameside changes into OSS scriptcomp #116

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion neverwinter/nwscript/compilerapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern "C" NativeCompileResult scriptCompApiCompileFile(CScriptCompiler* instanc
ret.code = STRREF_CSCRIPTCOMPILER_ERROR_FATAL_COMPILER_ERROR;
}

ret.str = ret.code ? instance->GetCapturedError()->CStr() : (char*)"";
ret.str = ret.code ? (char*)instance->GetCapturedError()->CStr() : (char*)"";
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion neverwinter/nwscript/native/exobase.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class CExoString
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
char* CStr() const;
const char* CStr() const;
//-------------------------------------------------------------------------
// Desc: Retuns a null terminated character array.
// Returns: Null terminated character array.
Expand Down
4 changes: 2 additions & 2 deletions neverwinter/nwscript/native/exostring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ float CExoString::AsFLOAT() const
// Description:Retuns a null terminated character array
///////////////////////////////////////////////////////////////////////////////
static char g_szEmptyString[1] = { 0 };
char* CExoString::CStr() const
const char* CExoString::CStr() const
{
//EXOWARNINGSTR( m_sString != NULL, "CExoString::CStr(): Obtaining NULL pointer from CExoString." );

Expand Down Expand Up @@ -1278,7 +1278,7 @@ BOOL CExoString::CompareNoCase(const CExoString &string) const
///////////////////////////////////////////////////////////////////////////////
BOOL CExoString::ComparePrefixNoCase(const CExoString &string, int32_t nSize) const
{
char *pStringChar = string.CStr();
const char *pStringChar = string.CStr();
char *pThisStringChar = m_sString;

if (pStringChar == NULL && pThisStringChar == NULL)
Expand Down
27 changes: 27 additions & 0 deletions neverwinter/nwscript/native/instrumentation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Stub file for compatibility with the game
#pragma once

#define INSTR_IS_ENABLED(...) 0
#define INSTR_SCOPE_IS_ACTIVE(...) 0
#define INSTR_SCOPE_COND(...)
#define INSTR_SCOPE(...)
#define INSTR_SCOPE_NAMEDL(...)
#define INSTR_SCOPE_TEXT(...)
#define INSTR_SCOPE_TEXTL(...)
#define INSTR_SCOPE_TEXT_TMPVAL(...)
#define INSTR_SCOPE_STR(...)
#define INSTR_SCOPE_PROP(...)
#define INSTR_SCOPE_PROP_STR(...)
#define INSTR_SCOPE_PROP_NUM(...)
#define INSTR_SCOPE_PROP_HEX8(...)
#define INSTR_SCOPE_PROP_HEX16(...)
#define INSTR_SCOPE_PROP_HEX32(...)
#define INSTR_SCOPE_PROP_HEX64(...)
#define INSTR_FRAME_MARK_ROOT(...)
#define INSTR_SCOPE_FRAME_MARK_NAMEDL(...)
#define INSTR_MESSAGE(...)
#define INSTR_MESSAGEL(...)
#define PERF_SCOPE(...)
#define PERF_SCOPE_FINAL(...)
#define INSTR_SET_THREAD_NAMEL(...)
#define INSTR_PLOT_COUNT(...)
6 changes: 3 additions & 3 deletions neverwinter/nwscript/native/scriptcomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class CScriptCompiler
int32_t ParseCharacterAmpersand(int32_t chNext);
int32_t ParseCharacterVerticalBar(int32_t chNext);
int32_t ParseCharacterAlphabet(int32_t ch);
int32_t ParseStringCharacter(int32_t ch, int32_t chNext, char *pScript, int32_t nScriptLength);
int32_t ParseStringCharacter(int32_t ch, int32_t chNext, const char *pScript, int32_t nScriptLength);
int32_t ParseRawStringCharacter(int32_t ch, int32_t chNext);
int32_t ParseCharacterQuotationMark();
int32_t ParseCharacterHyphen(int32_t chNext);
Expand All @@ -375,10 +375,10 @@ class CScriptCompiler

int32_t ParseCommentedOutCharacter(int32_t ch);

int32_t ParseNextCharacter(int32_t ch, int32_t chNext, char *pScript, int32_t nScriptLength);
int32_t ParseNextCharacter(int32_t ch, int32_t chNext, const char *pScript, int32_t nScriptLength);

int32_t PrintParseSourceError(int32_t nParseCharacterError);
int32_t ParseSource(char *pScript, int32_t nScriptLength);
int32_t ParseSource(const char *pScript, int32_t nScriptLength);

int32_t OutputError(int32_t nError, CExoString *psFileName, int32_t nLineNumber, const CExoString &sErrorText);
CScriptParseTreeNode *DuplicateScriptParseTree(CScriptParseTreeNode *pNode);
Expand Down
20 changes: 14 additions & 6 deletions neverwinter/nwscript/native/scriptcompcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
// external header files
#include "exobase.h"
#include "scriptcomp.h"
#include "instrumentation.h"

// internal header files
#include "scriptinternal.h"
Expand Down Expand Up @@ -712,7 +713,7 @@ uint32_t CScriptCompiler::HashString(const CExoString &sString)
uint32_t nHashValue = 0;
uint32_t nStringLength = sString.GetLength();
uint32_t nStringCount = 0;
char *pcString = sString.CStr();
const char *pcString = sString.CStr();

for (nStringCount = 0; nStringCount < nStringLength; nStringCount++)
{
Expand Down Expand Up @@ -1195,8 +1196,10 @@ void CScriptCompiler::CleanUpAfterCompiles()

int32_t CScriptCompiler::CompileFile(const CExoString &sFileName)
{
INSTR_SCOPE();
INSTR_SCOPE_TEXT(sFileName.CStr(), sFileName.GetLength());

char *pScript;
const char *pScript;
uint32_t nScriptLength;

if (m_nCompileFileLevel == 0)
Expand Down Expand Up @@ -1302,6 +1305,9 @@ int32_t CScriptCompiler::CompileFile(const CExoString &sFileName)

int32_t CScriptCompiler::CompileScriptChunk(const CExoString &sScriptChunk, BOOL bWrapIntoMain)
{
INSTR_SCOPE();
INSTR_SCOPE_TEXT(sScriptChunk.CStr(), sScriptChunk.GetLength());

char *pScript;
uint32_t nScriptLength;

Expand Down Expand Up @@ -1365,6 +1371,8 @@ int32_t CScriptCompiler::CompileScriptChunk(const CExoString &sScriptChunk, BOOL

int32_t CScriptCompiler::CompileScriptConditional(const CExoString &sScriptConditional)
{
INSTR_SCOPE();
INSTR_SCOPE_TEXT(sScriptConditional.CStr(), sScriptConditional.GetLength());

char *pScript;
uint32_t nScriptLength;
Expand Down Expand Up @@ -1467,22 +1475,22 @@ int32_t CScriptCompiler::OutputError(int32_t nError, CExoString *psFileName, int
{
if (nLineNumber > 0)
{
sFullErrorText.Format("%s(%d): %s", psFileName->Right(psFileName->GetLength()-1).CStr(),nLineNumber,sErrorText.CStr());
sFullErrorText.Format("%s(%d): %s\n",psFileName->Right(psFileName->GetLength()-1).CStr(),nLineNumber,sErrorText.CStr());
}
else
{
sFullErrorText.Format("%s: %s", psFileName->Right(psFileName->GetLength()-1).CStr(),sErrorText.CStr());
sFullErrorText.Format("%s: %s\n",psFileName->Right(psFileName->GetLength()-1).CStr(),sErrorText.CStr());
}
}
else
{
if (nLineNumber > 0)
{
sFullErrorText.Format("%s.nss(%d): %s", psFileName->CStr(),nLineNumber,sErrorText.CStr());
sFullErrorText.Format("%s.nss(%d): %s\n",psFileName->CStr(),nLineNumber,sErrorText.CStr());
}
else
{
sFullErrorText.Format("%s.nss: %s", psFileName->CStr(),sErrorText.CStr());
sFullErrorText.Format("%s.nss: %s\n",psFileName->CStr(),sErrorText.CStr());
}
}

Expand Down
2 changes: 1 addition & 1 deletion neverwinter/nwscript/native/scriptcompidentspec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ int32_t CScriptCompiler::PrintParseIdentifierFileError(int32_t nParsingError)
int32_t CScriptCompiler::ParseIdentifierFile()
{

char *pScript;
const char *pScript;
uint32_t nScriptLength;
uint32_t i;
int32_t ch;
Expand Down
6 changes: 3 additions & 3 deletions neverwinter/nwscript/native/scriptcomplexical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// remains available for everyone.
//

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// BIOWARE CORP. CONFIDENTIAL INFORMATION. //
// COPYRIGHT BIOWARE CORP. ALL RIGHTS RESERVED //
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -548,7 +548,7 @@ int32_t CScriptCompiler::ParseCommentedOutCharacter(int32_t ch)
// stuff like \n into a single character (\n). Wow.
///////////////////////////////////////////////////////////////////////////////

int32_t CScriptCompiler::ParseStringCharacter(int32_t ch, int32_t chNext, char *pScript, int32_t nScriptLength)
int32_t CScriptCompiler::ParseStringCharacter(int32_t ch, int32_t chNext, const char *pScript, int32_t nScriptLength)
{
int32_t nReturnValue = 0;

Expand Down Expand Up @@ -1552,7 +1552,7 @@ int32_t CScriptCompiler::HandleIdentifierToken()
// character in chNext.
///////////////////////////////////////////////////////////////////////////////

int32_t CScriptCompiler::ParseNextCharacter(int32_t ch, int32_t chNext, char *pScript, int32_t nScriptLength)
int32_t CScriptCompiler::ParseNextCharacter(int32_t ch, int32_t chNext, const char *pScript, int32_t nScriptLength)
{

if (ch == -1)
Expand Down
2 changes: 1 addition & 1 deletion neverwinter/nwscript/native/scriptcompparsetree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4497,7 +4497,7 @@ int32_t CScriptCompiler::CleanUpDuringCompile(int32_t nReturnValue)
// specified in pScript (of length nScriptLength).
///////////////////////////////////////////////////////////////////////////////

int32_t CScriptCompiler::ParseSource(char *pScript, int32_t nScriptLength)
int32_t CScriptCompiler::ParseSource(const char *pScript, int32_t nScriptLength)
{

int32_t i; // location in the string
Expand Down
Loading
Loading