Skip to content
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
9 changes: 6 additions & 3 deletions integration/ApprovedNativeV8Projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline bool projectNativeGraph(juce::var& snapshot,const juce::var& bus,
if(!rows||rows->isEmpty()||!edges||!nativeV8Decimal(rev)||
!nativeV8Decimal(roster))return false;
juce::Array<juce::var> channels,wires,destinations;
std::unordered_set<std::string> ids,edgeIds;
std::unordered_set<std::string> ids,edgeIds,fxInstanceTokens;
auto meters=std::make_unique<juce::DynamicObject>();
juce::String mainId;
for(const auto& row:*rows) {
Expand All @@ -64,7 +64,8 @@ inline bool projectNativeGraph(juce::var& snapshot,const juce::var& bus,
(format!="MONO"&&format!="STEREO")||
!out.isString()||!nativeV8Number(fader,linear)||
!nativeV8Number(pan,p)||linear<0.||linear>4.||p< -1.||p>1.||
!mute.isBool()||!solo.isBool()||!inserts.isArray())return false;
!mute.isBool()||!solo.isBool()||!inserts.isArray()||
inserts.getArray()->size()>8)return false;
if(role=="MAIN"){if(mainId.isNotEmpty())return false;mainId=id.toString();}
auto ch=std::make_unique<juce::DynamicObject>();
ch->setProperty("id",id);ch->setProperty("name",name);
Expand Down Expand Up @@ -93,7 +94,9 @@ inline bool projectNativeGraph(juce::var& snapshot,const juce::var& bus,
if(!token.isString()||token.toString().isEmpty()||
!catalog.isString()||catalog.toString().isEmpty()||
catalog.toString().getNumBytesAsUTF8()>256||
!label.isString()||!bypass.isBool())return false;
!label.isString()||!bypass.isBool()||
!fxInstanceTokens.insert(token.toString().toStdString()).second)
return false;
auto insert=std::make_unique<juce::DynamicObject>();
insert->setProperty("id",token);insert->setProperty("catalogId",catalog);
insert->setProperty("name",label);
Expand Down
40 changes: 40 additions & 0 deletions tests/approved_native_v8_projection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,46 @@ static void nativeInsertCatalogInstanceProjectionRegression() {
const auto before=juce::JSON::toString(untouched,false);
assert(!projectApprovedNativeV8(untouched,invalid,true));
assert(juce::JSON::toString(untouched,false)==before);

// M6: the native projection is the first fail-closed boundary for
// unstable VST3 lease tokens. JS must never be asked to guess which
// physical plugin/editor is owned by a duplicated instance identity.
const auto rejectUnchanged=[](const juce::var& bus) {
auto untouched=canonicalSnapshot();
const auto before=juce::JSON::toString(untouched,false);
assert(!projectApprovedNativeV8(untouched,bus,true));
assert(juce::JSON::toString(untouched,false)==before);
};
auto duplicateAcrossChannels=juce::JSON::parse(
juce::JSON::toString(source,false));
duplicateAcrossChannels.getProperty("channels",{})[1].getDynamicObject()
->setProperty("inserts",
duplicateAcrossChannels.getProperty("channels",{})[0]
.getProperty("inserts",{}));
rejectUnchanged(duplicateAcrossChannels);

auto duplicateSameChannel=juce::JSON::parse(
juce::JSON::toString(source,false));
auto* existing=duplicateSameChannel.getProperty("channels",{})[0]
.getProperty("inserts",{}).getArray();
assert(existing && existing->size()==1);
existing->add(juce::JSON::parse(juce::JSON::toString((*existing)[0],false)));
rejectUnchanged(duplicateSameChannel);

auto overfullRack=juce::JSON::parse(
juce::JSON::toString(source,false));
juce::Array<juce::var> nine;
for(int i=0;i<9;++i) {
auto fx=std::make_unique<juce::DynamicObject>();
fx->setProperty("instanceId","unique-FX-"+juce::String(i+1));
fx->setProperty("id","vendor.eq.catalog");
fx->setProperty("name","Vendor EQ");
fx->setProperty("bypassed",false);
nine.add(juce::var(fx.release()));
}
overfullRack.getProperty("channels",{})[0].getDynamicObject()
->setProperty("inserts",juce::var(nine));
rejectUnchanged(overfullRack);
}

static void noMutationOnReject(juce::var snapshot,juce::var bus,bool admitted) {
Expand Down
Loading