mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-25 05:12:10 +00:00
safety push
This commit is contained in:
parent
27350c0a5f
commit
d7ebd9fdbe
5 changed files with 44 additions and 1 deletions
3
Makefile
3
Makefile
|
@ -104,3 +104,6 @@ $(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.c
|
||||||
$(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.S
|
$(BUILDDIR)/$(TARGET)/%.o: $(BDKDIR)/%.S
|
||||||
@mkdir -p "$(@D)"
|
@mkdir -p "$(@D)"
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(SOURCEDIR)/script/builtin.c: scripts/*.te
|
||||||
|
@py te2c.py source/script/builtin scripts
|
||||||
|
|
|
@ -70,6 +70,16 @@ ClassFunction(stringIndexGet) {
|
||||||
return newStringVariablePtr(a, 0, 0);
|
return newStringVariablePtr(a, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassFunction(stringMinusInt){
|
||||||
|
u32 baseStrLen = strlen(caller->string.value);
|
||||||
|
if (baseStrLen < args[0]->integer.value){
|
||||||
|
SCRIPT_FATAL_ERR("Index of string out of range");
|
||||||
|
}
|
||||||
|
char* newStr = calloc(baseStrLen - args[0]->integer.value + 1, 1);
|
||||||
|
memcpy(newStr, caller->string.value, baseStrLen - args[0]->integer.value);
|
||||||
|
return newStringVariablePtr(newStr, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
u8 strOneIntArg[] = { IntClass };
|
u8 strOneIntArg[] = { IntClass };
|
||||||
u8 oneStringArg[] = { StringClass };
|
u8 oneStringArg[] = { StringClass };
|
||||||
|
|
||||||
|
@ -79,6 +89,7 @@ ClassFunctionTableEntry_t stringFunctions[] = {
|
||||||
{"len", getStringLength, 0, 0},
|
{"len", getStringLength, 0, 0},
|
||||||
{"bytes", stringBytes, 0, 0},
|
{"bytes", stringBytes, 0, 0},
|
||||||
{"get", stringIndexGet, 1, strOneIntArg},
|
{"get", stringIndexGet, 1, strOneIntArg},
|
||||||
|
{"-", stringMinusInt, 1, strOneIntArg},
|
||||||
};
|
};
|
||||||
|
|
||||||
Variable_t getStringMember(Variable_t* var, char* memberName) {
|
Variable_t getStringMember(Variable_t* var, char* memberName) {
|
||||||
|
|
|
@ -226,6 +226,25 @@ ClassFunction(eqArray){
|
||||||
return newIntVariablePtr(!res);
|
return newIntVariablePtr(!res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassFunction(arrayFind){
|
||||||
|
Variable_t *arg = (*args);
|
||||||
|
if (caller->solvedArray.vector.count <= arg->solvedArray.vector.count || arg->variableType != caller->variableType){
|
||||||
|
return newIntVariablePtr(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 step = (arg->variableType == ByteArrayClass) ? 1 : 8;
|
||||||
|
char *haystack = caller->solvedArray.vector.data;
|
||||||
|
void *needle = arg->solvedArray.vector.data;
|
||||||
|
|
||||||
|
for (int i = 0; i < caller->solvedArray.vector.count - arg->solvedArray.vector.count; i++){
|
||||||
|
if (!memcmp(haystack + (i * step), needle, step * arg->solvedArray.vector.count)){
|
||||||
|
return newIntVariablePtr(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return newIntVariablePtr(-1);
|
||||||
|
}
|
||||||
|
|
||||||
ClassFunctionTableEntry_t arrayFunctions[] = {
|
ClassFunctionTableEntry_t arrayFunctions[] = {
|
||||||
{"get", getArrayIdx, 1, anotherOneIntArg },
|
{"get", getArrayIdx, 1, anotherOneIntArg },
|
||||||
{"len", getArrayLen, 0, 0},
|
{"len", getArrayLen, 0, 0},
|
||||||
|
@ -239,6 +258,8 @@ ClassFunctionTableEntry_t arrayFunctions[] = {
|
||||||
{"bytestostr", bytesToStr, 0, 0},
|
{"bytestostr", bytesToStr, 0, 0},
|
||||||
{"==", eqArray, 1, oneByteArrayClass},
|
{"==", eqArray, 1, oneByteArrayClass},
|
||||||
{"==", eqArray, 1, oneIntArrayClass},
|
{"==", eqArray, 1, oneIntArrayClass},
|
||||||
|
{"find", arrayFind, 1, oneByteArrayClass},
|
||||||
|
{"find", arrayFind, 1, oneIntArrayClass},
|
||||||
};
|
};
|
||||||
|
|
||||||
Variable_t getArrayMember(Variable_t* var, char* memberName) {
|
Variable_t getArrayMember(Variable_t* var, char* memberName) {
|
||||||
|
|
|
@ -274,6 +274,13 @@ void freeVariableInternal(Variable_t* referencedTarget) {
|
||||||
}
|
}
|
||||||
FREE(referencedTarget->dictionary.vector.data);
|
FREE(referencedTarget->dictionary.vector.data);
|
||||||
break;
|
break;
|
||||||
|
case SaveClass:;
|
||||||
|
#ifndef WIN32
|
||||||
|
save_free_contexts(&referencedTarget->save->saveCtx);
|
||||||
|
f_close(&referencedTarget->save->saveFile);
|
||||||
|
FREE(referencedTarget->save);
|
||||||
|
#endif // !WIN32
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
te2c.py
1
te2c.py
|
@ -65,3 +65,4 @@ def te2c(dest: str, path: str, suffix: str=".te"):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
te2c(dest=sys.argv[1], path=sys.argv[2])
|
te2c(dest=sys.argv[1], path=sys.argv[2])
|
||||||
|
print("converting .te files done!")
|
||||||
|
|
Loading…
Reference in a new issue