Skip to content

Commit 2d1f956

Browse files
committed
Having more than one type of virtual machine would make the "machine_" prefix sound too generic for a specialized API for the media machine, so I'm changing it to "mediaMachine_" while custom themes are still highly experimental.
1 parent d40c4c7 commit 2d1f956

File tree

7 files changed

+105
-102
lines changed

7 files changed

+105
-102
lines changed

Source/DFPSR/History.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ Changes from version 0.3.0
9696
If you see that the compiler can't find a constructor for StorableCallback and it points to a variable declaration, you need to initialize it with a function.
9797
string_assignMessageHandler now uses function pointers to avoid cyclic dependencies between stringAPI.h and StorableCallback.h.
9898
A message handler needs to be stored but will usually only work with global and thread-local variables.
99+
* The "machine_" prefix was replaced with "mediaMachine_".
100+
Because there will likely be more instances of VirtualMachine with their own APIs, so it is best to rename it before there are compilers generating the undocumented assembler language.
101+
In case that you decided to learn an undocumented assembler language for the media machine before the script compiler is ready, simply replace "machine_" with "mediaMachine_" and the code should work as before.

Source/DFPSR/api/mediaMachineAPI.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,14 +1039,14 @@ static VMA resolveImmediateConstant(PlanarMemory<MEDIA_MACHINE_TYPE_COUNT> &memo
10391039
}
10401040
}
10411041

1042-
MediaMachine machine_create(const ReadableString& code) {
1042+
MediaMachine mediaMachine_create(const ReadableString& code) {
10431043
Handle<PlanarMemory<MEDIA_MACHINE_TYPE_COUNT>> memory = handle_create<MediaMemory>().setName("MediaMemory");
10441044
static const int32_t mediaMachineInstructionCount = sizeof(mediaMachineInstructions) / sizeof(InsSig<MEDIA_MACHINE_TYPE_COUNT>);
10451045
static const int32_t mediaMachineTypeCount = sizeof(mediaMachineTypes) / sizeof(VMTypeDef<MEDIA_MACHINE_TYPE_COUNT>);
10461046
return MediaMachine(handle_create<VirtualMachine<MEDIA_MACHINE_TYPE_COUNT>>(code, memory, mediaMachineInstructions, mediaMachineInstructionCount, mediaMachineTypes, mediaMachineTypeCount, resolveImmediateConstant).setName("MediaMachine"));
10471047
}
10481048

1049-
void machine_executeMethod(MediaMachine& machine, int32_t methodIndex) {
1049+
void mediaMachine_executeMethod(MediaMachine& machine, int32_t methodIndex) {
10501050
checkMethodIndex(machine, methodIndex);
10511051
machine->executeMethod(methodIndex);
10521052
}
@@ -1078,28 +1078,28 @@ static T& accessOutputByIndex(MemoryPlane<T>& stack, int32_t framePointer, Metho
10781078

10791079
// Set input by argument index
10801080
// Indexed arguments are confirmed to be inputs during compilation of the script
1081-
void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, int32_t input) {
1081+
void mediaMachine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, int32_t input) {
10821082
#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
10831083
printText(U"Input ", inputIndex, U" of ", machine->methods[methodIndex].inputCount, U" (", machine->methods[methodIndex].locals[inputIndex].name, U") to ", machine->methods[methodIndex].name, U" = ", input, U"\n");
10841084
#endif
10851085
checkMethodIndex(machine, methodIndex);
10861086
setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->fixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, inputIndex, FixedPoint::fromWhole(input));
10871087
}
1088-
void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const FixedPoint& input) {
1088+
void mediaMachine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const FixedPoint& input) {
10891089
#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
10901090
printText(U"Input ", inputIndex, U" of ", machine->methods[methodIndex].inputCount, U" (", machine->methods[methodIndex].locals[inputIndex].name, U") to ", machine->methods[methodIndex].name, U" = ", input, U"\n");
10911091
#endif
10921092
checkMethodIndex(machine, methodIndex);
10931093
setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->fixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, inputIndex, input);
10941094
}
1095-
void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const AlignedImageU8& input) {
1095+
void mediaMachine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const AlignedImageU8& input) {
10961096
#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
10971097
printText(U"Input ", inputIndex, U" of ", machine->methods[methodIndex].inputCount, U" (", machine->methods[methodIndex].locals[inputIndex].name, U") to ", machine->methods[methodIndex].name, U" = monochrome image of ", image_getWidth(input), U"x", image_getHeight(input), U" pixels\n");
10981098
#endif
10991099
checkMethodIndex(machine, methodIndex);
11001100
setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->alignedImageU8Memory, machine->memory->current.framePointer[DataType_ImageU8], machine->methods[methodIndex], DataType_ImageU8, inputIndex, input);
11011101
}
1102-
void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const OrderedImageRgbaU8& input) {
1102+
void mediaMachine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const OrderedImageRgbaU8& input) {
11031103
#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
11041104
printText(U"Input ", inputIndex, U" of ", machine->methods[methodIndex].inputCount, U" (", machine->methods[methodIndex].locals[inputIndex].name, U") to ", machine->methods[methodIndex].name, U" = rgba image of ", image_getWidth(input), U"x", image_getHeight(input), U" pixels\n");
11051105
#endif
@@ -1108,74 +1108,74 @@ void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t
11081108
}
11091109

11101110
// Get output by index
1111-
FixedPoint machine_getFixedPointOutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
1111+
FixedPoint mediaMachine_getFixedPointOutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
11121112
checkMethodIndex(machine, methodIndex);
11131113
return accessOutputByIndex<FixedPoint>(((MediaMemory*)machine->memory.getUnsafe())->fixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, outputIndex);
11141114
}
1115-
AlignedImageU8 machine_getImageU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
1115+
AlignedImageU8 mediaMachine_getImageU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
11161116
checkMethodIndex(machine, methodIndex);
11171117
return accessOutputByIndex<AlignedImageU8>(((MediaMemory*)machine->memory.getUnsafe())->alignedImageU8Memory, machine->memory->current.framePointer[DataType_ImageU8], machine->methods[methodIndex], DataType_ImageU8, outputIndex);
11181118
}
1119-
OrderedImageRgbaU8 machine_getImageRgbaU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
1119+
OrderedImageRgbaU8 mediaMachine_getImageRgbaU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
11201120
checkMethodIndex(machine, methodIndex);
11211121
return accessOutputByIndex<OrderedImageRgbaU8>(((MediaMemory*)machine->memory.getUnsafe())->orderedImageRgbaU8Memory, machine->memory->current.framePointer[DataType_ImageRgbaU8], machine->methods[methodIndex], DataType_ImageRgbaU8, outputIndex);
11221122
}
11231123

1124-
bool machine_exists(const MediaMachine& machine) {
1124+
bool mediaMachine_exists(const MediaMachine& machine) {
11251125
return machine.isNotNull();
11261126
}
11271127

1128-
int32_t machine_findMethod(const MediaMachine& machine, const ReadableString& methodName) {
1129-
if (!machine_exists(machine)) {
1128+
int32_t mediaMachine_findMethod(const MediaMachine& machine, const ReadableString& methodName) {
1129+
if (!mediaMachine_exists(machine)) {
11301130
throwError(U"Can not look for ", methodName, U" in a media machine that does not exist!\n");
11311131
return -1;
11321132
} else {
11331133
return machine->findMethod(methodName);
11341134
}
11351135
}
11361136

1137-
MediaMethod machine_getMethod(MediaMachine& machine, const ReadableString& methodName, int32_t contextIndex, bool mustExist) {
1138-
int32_t methodIndex = machine_findMethod(machine, methodName);
1137+
MediaMethod mediaMachine_getMethod(MediaMachine& machine, const ReadableString& methodName, int32_t contextIndex, bool mustExist) {
1138+
int32_t methodIndex = mediaMachine_findMethod(machine, methodName);
11391139
if (mustExist && methodIndex == -1) {
11401140
throwError(U"The method name ", methodName, U" could not be found in the media machine!\n");
11411141
}
11421142
return MediaMethod(machine, methodIndex, contextIndex);
11431143
}
11441144

1145-
String machine_getMethodName(const MediaMachine& machine, int32_t methodIndex) {
1145+
String mediaMachine_getMethodName(const MediaMachine& machine, int32_t methodIndex) {
11461146
checkMethodIndex(machine, methodIndex);
11471147
return machine->methods[methodIndex].name;
11481148
}
11491149

1150-
int32_t machine_getMethodCount(const MediaMachine& machine) {
1150+
int32_t mediaMachine_getMethodCount(const MediaMachine& machine) {
11511151
checkMachine(machine);
11521152
return machine->methods.length();
11531153
}
11541154

1155-
int32_t machine_getInputCount(const MediaMachine& machine, int32_t methodIndex) {
1155+
int32_t mediaMachine_getInputCount(const MediaMachine& machine, int32_t methodIndex) {
11561156
checkMethodIndex(machine, methodIndex);
11571157
return machine->methods[methodIndex].inputCount;
11581158
}
11591159

1160-
int32_t machine_getOutputCount(const MediaMachine& machine, int32_t methodIndex) {
1160+
int32_t mediaMachine_getOutputCount(const MediaMachine& machine, int32_t methodIndex) {
11611161
checkMethodIndex(machine, methodIndex);
11621162
return machine->methods[methodIndex].outputCount;
11631163
}
11641164

1165-
String machine_getInputName(const MediaMachine& machine, int32_t methodIndex, int32_t inputIndex) {
1165+
String mediaMachine_getInputName(const MediaMachine& machine, int32_t methodIndex, int32_t inputIndex) {
11661166
checkMethodIndex(machine, methodIndex);
11671167
Method<MEDIA_MACHINE_TYPE_COUNT> *method = &(machine->methods[methodIndex]);
11681168
if (inputIndex < 0 || inputIndex >= method->inputCount) {
1169-
throwError(U"Input index ", inputIndex, U" is out of bound 0..", method->inputCount - 1, U" for method ", machine_getMethodName(machine, methodIndex), U"!\n");
1169+
throwError(U"Input index ", inputIndex, U" is out of bound 0..", method->inputCount - 1, U" for method ", mediaMachine_getMethodName(machine, methodIndex), U"!\n");
11701170
}
11711171
return method->locals[inputIndex].name;
11721172
}
11731173

1174-
String machine_getOutputName(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
1174+
String mediaMachine_getOutputName(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
11751175
checkMethodIndex(machine, methodIndex);
11761176
Method<MEDIA_MACHINE_TYPE_COUNT> *method = &(machine->methods[methodIndex]);
11771177
if (outputIndex < 0 || outputIndex >= method->outputCount) {
1178-
throwError(U"Input index ", outputIndex, U" is out of bound 0..", method->outputCount - 1, U" for method ", machine_getMethodName(machine, methodIndex), U"!\n");
1178+
throwError(U"Input index ", outputIndex, U" is out of bound 0..", method->outputCount - 1, U" for method ", mediaMachine_getMethodName(machine, methodIndex), U"!\n");
11791179
}
11801180
return method->locals[method->inputCount + outputIndex].name;
11811181
}
@@ -1190,7 +1190,7 @@ MediaResult MediaMethod::callUsingKeywords(const TemporaryCallback<void(MediaMac
11901190
for (int32_t i = 0; i < inputCount; i++) {
11911191
setInputAction(this->machine, this->methodIndex, i, method->locals[i].name);
11921192
}
1193-
machine_executeMethod(this->machine, this->methodIndex);
1193+
mediaMachine_executeMethod(this->machine, this->methodIndex);
11941194
return MediaResult(this->machine, this->methodIndex);
11951195
}
11961196

0 commit comments

Comments
 (0)