From 853481bd9ae617747fd1a5d0b6255bdf3946c6dd Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sun, 5 May 2024 00:40:22 -0400 Subject: [PATCH] Add Backup Properties & Update Syntax Highlighting --- src/common.ts | 3 +- src/struct.ts | 5 +- src/vtable.ts | 19 +++++-- .../symbol-processor.xml} | 0 .../symbol-processor.nanorc} | 2 + .../Preferences/Comments.tmPreferences | 24 ++++++++ .../Syntaxes/SymbolProcessor.tmLanguage | 55 +++++++++++++++++++ .../SymbolProcessor.tmbundle/info.plist | 16 ++++++ 8 files changed, 116 insertions(+), 8 deletions(-) rename syntax-highlighting/{ksyntaxhighlighting.xml => ksyntaxhighlighting/symbol-processor.xml} (100%) rename syntax-highlighting/{def.nanorc => nano/symbol-processor.nanorc} (90%) create mode 100644 syntax-highlighting/textmate/SymbolProcessor.tmbundle/Preferences/Comments.tmPreferences create mode 100644 syntax-highlighting/textmate/SymbolProcessor.tmbundle/Syntaxes/SymbolProcessor.tmLanguage create mode 100644 syntax-highlighting/textmate/SymbolProcessor.tmbundle/info.plist diff --git a/src/common.ts b/src/common.ts index 56a2aa1..f9bb23a 100644 --- a/src/common.ts +++ b/src/common.ts @@ -120,4 +120,5 @@ export function removeFirstArg(args: string) { index++; } return '(' + args.substring(index).trim(); -} \ No newline at end of file +} +export const ORIGINAL_SUFFIX = '_backup_do_not_use'; \ No newline at end of file diff --git a/src/struct.ts b/src/struct.ts index 7aa5801..27b44a9 100644 --- a/src/struct.ts +++ b/src/struct.ts @@ -1,4 +1,4 @@ -import { INDENT, STRUCTURE_FILES, toHex, assertSize, formatType, getArgNames, removeFirstArg } from './common'; +import { INDENT, STRUCTURE_FILES, toHex, assertSize, formatType, getArgNames, removeFirstArg, ORIGINAL_SUFFIX } from './common'; import { Method } from './method'; import { Property, StaticProperty } from './property'; import { VTable } from './vtable'; @@ -203,6 +203,7 @@ export class Struct { out += method.generateTypedef(); out += `extern ${method.generateDefinition()}`; out += method.generateNewMethodTest(this.#directParent, '', ''); + out += `extern ${method.generateDefinition(ORIGINAL_SUFFIX)}`; } } @@ -260,6 +261,8 @@ export class Struct { if (!method.isInherited) { init += `${INDENT}${method.getName()} = (${method.getType()}) ${toHex(method.address)};\n`; declarations += method.generateDefinition(); + init += `${INDENT}${method.getName()}${ORIGINAL_SUFFIX} = ${method.getName()};\n`; + declarations += method.generateDefinition(ORIGINAL_SUFFIX); } } diff --git a/src/vtable.ts b/src/vtable.ts index 2c6b777..365e6bf 100644 --- a/src/vtable.ts +++ b/src/vtable.ts @@ -1,4 +1,4 @@ -import { INDENT, POINTER_SIZE, RTTI_SIZE, assertSize, getSelfArg, toHex } from './common'; +import { INDENT, ORIGINAL_SUFFIX, POINTER_SIZE, RTTI_SIZE, assertSize, getSelfArg, toHex } from './common'; import { Method } from './method'; import { Property } from './property'; @@ -128,9 +128,12 @@ export class VTable { for (let i = 0; i < methods.length; i++) { const info = methods[i]; if (info) { - const type = `${info.getType()} *`; - out += `extern ${type}${info.getName()}_vtable_addr;\n`; + const name = info.getName(); + const type = info.getType(); + const pointerType = `${type} *`; + out += `extern ${pointerType}${name}_vtable_addr;\n`; out += info.generateNewMethodTest(directParent, '*', '_vtable_addr'); + out += `extern ${info.generateDefinition(ORIGINAL_SUFFIX)}`; } } } @@ -163,9 +166,13 @@ export class VTable { const info = methods[i]; if (info) { const vtableAddress = this.#address + (i * POINTER_SIZE); - const type = `${info.getType()} *`; - init += `${INDENT}${info.getName()}_vtable_addr = (${type}) ${toHex(vtableAddress)};\n`; - declarations += `${type}${info.getName()}_vtable_addr;\n`; + const name = info.getName(); + const type = info.getType(); + const pointerType = `${type} *`; + init += `${INDENT}${name}_vtable_addr = (${pointerType}) ${toHex(vtableAddress)};\n`; + declarations += `${pointerType}${name}_vtable_addr;\n`; + init += `${INDENT}${name}${ORIGINAL_SUFFIX} = *${name}_vtable_addr;\n`; + declarations += info.generateDefinition(ORIGINAL_SUFFIX); } } } diff --git a/syntax-highlighting/ksyntaxhighlighting.xml b/syntax-highlighting/ksyntaxhighlighting/symbol-processor.xml similarity index 100% rename from syntax-highlighting/ksyntaxhighlighting.xml rename to syntax-highlighting/ksyntaxhighlighting/symbol-processor.xml diff --git a/syntax-highlighting/def.nanorc b/syntax-highlighting/nano/symbol-processor.nanorc similarity index 90% rename from syntax-highlighting/def.nanorc rename to syntax-highlighting/nano/symbol-processor.nanorc index 926abe1..ec81497 100644 --- a/syntax-highlighting/def.nanorc +++ b/syntax-highlighting/nano/symbol-processor.nanorc @@ -13,5 +13,7 @@ color yellow "0x[a-f0-9]+" # Comments color brightblue "//.*" +# Whitespace. +color normal "[[:space:]]+" # Trailing whitespace. color ,green "[[:space:]]+$" diff --git a/syntax-highlighting/textmate/SymbolProcessor.tmbundle/Preferences/Comments.tmPreferences b/syntax-highlighting/textmate/SymbolProcessor.tmbundle/Preferences/Comments.tmPreferences new file mode 100644 index 0000000..3df8e1a --- /dev/null +++ b/syntax-highlighting/textmate/SymbolProcessor.tmbundle/Preferences/Comments.tmPreferences @@ -0,0 +1,24 @@ + + + + + name + Comments + scope + source.toml + settings + + shellVariables + + + name + TM_COMMENT_START + value + // + + + + uuid + C5C885D7-2733-4632-B709-B5B9DD518F90 + + \ No newline at end of file diff --git a/syntax-highlighting/textmate/SymbolProcessor.tmbundle/Syntaxes/SymbolProcessor.tmLanguage b/syntax-highlighting/textmate/SymbolProcessor.tmbundle/Syntaxes/SymbolProcessor.tmLanguage new file mode 100644 index 0000000..643cca0 --- /dev/null +++ b/syntax-highlighting/textmate/SymbolProcessor.tmbundle/Syntaxes/SymbolProcessor.tmLanguage @@ -0,0 +1,55 @@ + + + + + fileTypes + + def + + scopeName + source.symbol-processor + name + Symbol Processor Definition + patterns + + + name + comment.line.double-slash.symbol-processor + match + //.*$ + + + name + constant.numeric.symbol-processor.hex + match + \b0[xX][0-9a-fA-F]+ + + + name + constant.numeric.symbol-processor.decimal + match + \b[0-9]+ + + + name + keyword.control.symbol-processor + match + \b(extends|size|vtable-size|vtable|property|static-property|method|virtual-method|static-method|constructor|vtable-destructor-offset)\b + + + name + storage.type.symbol-processor + match + \b(char|uchar|short|ushort|int|uint|float|bool|void|std::string|std::vector|std::map)\b + + + name + keyword.operator.symbol-processor + match + (=|;) + + + uuid + D44198D4-5AEB-40E5-B4E4-0E11C69FFA42 + + \ No newline at end of file diff --git a/syntax-highlighting/textmate/SymbolProcessor.tmbundle/info.plist b/syntax-highlighting/textmate/SymbolProcessor.tmbundle/info.plist new file mode 100644 index 0000000..763aa93 --- /dev/null +++ b/syntax-highlighting/textmate/SymbolProcessor.tmbundle/info.plist @@ -0,0 +1,16 @@ + + + + + contactEmailRot13 + connor24nolan@live.com + contactName + TheBrokenRail + description + Symbol Processor Definition File + name + Symbol Processor + uuid + 8209EEB8-4193-4E63-BDBB-0407E47ADF50 + + \ No newline at end of file