Add Backup Properties & Update Syntax Highlighting

This commit is contained in:
TheBrokenRail 2024-05-05 00:40:22 -04:00
parent 6ee26aad80
commit 853481bd9a
8 changed files with 116 additions and 8 deletions

View File

@ -120,4 +120,5 @@ export function removeFirstArg(args: string) {
index++;
}
return '(' + args.substring(index).trim();
}
}
export const ORIGINAL_SUFFIX = '_backup_do_not_use';

View File

@ -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);
}
}

View File

@ -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);
}
}
}

View File

@ -13,5 +13,7 @@ color yellow "0x[a-f0-9]+"
# Comments
color brightblue "//.*"
# Whitespace.
color normal "[[:space:]]+"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.toml</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>//</string>
</dict>
</array>
</dict>
<key>uuid</key>
<string>C5C885D7-2733-4632-B709-B5B9DD518F90</string>
</dict>
</plist>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>def</string>
</array>
<key>scopeName</key>
<string>source.symbol-processor</string>
<key>name</key>
<string>Symbol Processor Definition</string>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>comment.line.double-slash.symbol-processor</string>
<key>match</key>
<string>//.*$</string>
</dict>
<dict>
<key>name</key>
<string>constant.numeric.symbol-processor.hex</string>
<key>match</key>
<string>\b0[xX][0-9a-fA-F]+</string>
</dict>
<dict>
<key>name</key>
<string>constant.numeric.symbol-processor.decimal</string>
<key>match</key>
<string>\b[0-9]+</string>
</dict>
<dict>
<key>name</key>
<string>keyword.control.symbol-processor</string>
<key>match</key>
<string>\b(extends|size|vtable-size|vtable|property|static-property|method|virtual-method|static-method|constructor|vtable-destructor-offset)\b</string>
</dict>
<dict>
<key>name</key>
<string>storage.type.symbol-processor</string>
<key>match</key>
<string>\b(char|uchar|short|ushort|int|uint|float|bool|void|std::string|std::vector|std::map)\b</string>
</dict>
<dict>
<key>name</key>
<string>keyword.operator.symbol-processor</string>
<key>match</key>
<string>(=|;)</string>
</dict>
</array>
<key>uuid</key>
<string>D44198D4-5AEB-40E5-B4E4-0E11C69FFA42</string>
</dict>
</plist>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>contactEmailRot13</key>
<string>connor24nolan@live.com</string>
<key>contactName</key>
<string>TheBrokenRail</string>
<key>description</key>
<string>Symbol Processor Definition File</string>
<key>name</key>
<string>Symbol Processor</string>
<key>uuid</key>
<string>8209EEB8-4193-4E63-BDBB-0407E47ADF50</string>
</dict>
</plist>