diff --git a/dist/clef_change.lua b/dist/clef_change.lua index 6e06cf72..e185411f 100644 --- a/dist/clef_change.lua +++ b/dist/clef_change.lua @@ -99,9 +99,7 @@ end package.preload["library.clef"] = package.preload["library.clef"] or function() local clef = {} - local client = require("library.client") - local clef_map = { treble = 0, alto = 1, @@ -128,16 +126,12 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() tab_serif = 17 } - - function clef.get_cell_clef(measure, staff_number) local cell_clef = -1 local cell = finale.FCCell(measure, staff_number) local cell_frame_hold = finale.FCCellFrameHold() - cell_frame_hold:ConnectCell(cell) if cell_frame_hold:Load() then - if cell_frame_hold.IsClefList then cell_clef = cell_frame_hold:CreateFirstCellClefChange().ClefIndex else @@ -147,7 +141,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() return cell_clef end - function clef.get_default_clef(first_measure, last_measure, staff_number) local staff = finale.FCStaff() local cell_clef = clef.get_cell_clef(first_measure - 1, staff_number) @@ -160,10 +153,8 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() return cell_clef end - function clef.set_measure_clef(first_measure, last_measure, staff_number, clef_index) client.assert_supports("clef_change") - for measure = first_measure, last_measure do local cell = finale.FCCell(measure, staff_number) local cell_frame_hold = finale.FCCellFrameHold() @@ -182,18 +173,13 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end - function clef.restore_default_clef(first_measure, last_measure, staff_number) client.assert_supports("clef_change") - local default_clef = clef.get_default_clef(first_measure, last_measure, staff_number) - clef.set_measure_clef(first_measure, last_measure, staff_number, default_clef) - end - function clef.process_clefs(mid_clefs) local clefs = {} local new_mid_clefs = finale.FCCellClefChanges() @@ -201,13 +187,11 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() table.insert(clefs, mid_clef) end table.sort(clefs, function (k1, k2) return k1.MeasurePos < k2.MeasurePos end) - for k, mid_clef in ipairs(clefs) do new_mid_clefs:InsertCellClefChange(mid_clef) new_mid_clefs:SaveAllAsNew() end - for i = new_mid_clefs.Count - 1, 1, -1 do local later_clef_change = new_mid_clefs:GetItemAt(i) local earlier_clef_change = new_mid_clefs:GetItemAt(i - 1) @@ -222,17 +206,14 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end ::continue:: end - return new_mid_clefs end - function clef.clef_change(clef_type, region) local clef_index = clef_map[clef_type] local cell_frame_hold = finale.FCCellFrameHold() local last_clef local last_staff = -1 - for cell_measure, cell_staff in eachcell(region) do local cell = finale.FCCell(region.EndMeasure, cell_staff) if cell_staff ~= last_staff then @@ -243,7 +224,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() cell_frame_hold:ConnectCell(cell) if cell_frame_hold:Load() then end - if region:IsFullMeasureIncluded(cell_measure) then clef.set_measure_clef(cell_measure, cell_measure, cell_staff, clef_index) if not region:IsLastEndMeasure() then @@ -257,13 +237,10 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() cell_frame_hold:SaveNew() end end - - else local mid_measure_clefs = cell_frame_hold:CreateCellClefChanges() local new_mid_measure_clefs = finale.FCCellClefChanges() local mid_measure_clef = finale.FCCellClefChange() - if not mid_measure_clefs then mid_measure_clefs = finale.FCCellClefChanges() mid_measure_clef:SetClefIndex(cell_frame_hold.ClefIndex) @@ -272,7 +249,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() mid_measure_clefs:InsertCellClefChange(mid_measure_clef) mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.StartMeasure and region.StartMeasure ~= region.EndMeasure then for mid_clef in each(mid_measure_clefs) do @@ -288,10 +264,8 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() new_mid_measure_clefs:InsertCellClefChange(mid_measure_clef) new_mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.EndMeasure and region.StartMeasure ~= region.EndMeasure then - for mid_clef in each(mid_measure_clefs) do if mid_clef.MeasurePos == 0 then mid_clef:SetClefIndex(clef_index) @@ -304,17 +278,14 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end - mid_measure_clef:SetClefIndex(last_clef) mid_measure_clef:SetMeasurePos(region.EndMeasurePos) mid_measure_clef:Save() new_mid_measure_clefs:InsertCellClefChange(mid_measure_clef) new_mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.StartMeasure and region.StartMeasure == region.EndMeasure then local last_clef = cell:CalcClefIndexAt(region.EndMeasurePos) - for mid_clef in each(mid_measure_clefs) do if mid_clef.MeasurePos == 0 then if region.StartMeasurePos == 0 then @@ -355,7 +326,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end end - return clef end function plugindef() @@ -366,7 +336,6 @@ function plugindef() finaleplugin.Version = "1.0.1" finaleplugin.Date = "2022-08-30" finaleplugin.RequireSelection = true - finaleplugin.AuthorEmail = "jacob.winkler@mac.com" finaleplugin.AdditionalMenuOptions = [[ Clef 2: Bass @@ -395,14 +364,12 @@ function plugindef() clef_type = "tenor" clef_type = "tenor_voice" clef_type = "percussion" - ]] finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/clef_change.hash" + ]] + finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/clef_change.hash" return "Clef 1: Treble", "Clef 1: Treble", "Changes the selected region to treble clef" end - clef_type = clef_type or "treble" - local clef = require("library.clef") - local region = finenv.Region() region:SetCurrentSelection() clef.clef_change(clef_type, region) \ No newline at end of file diff --git a/dist/cross_staff_offset.lua b/dist/cross_staff_offset.lua index 82480fde..007e805e 100644 --- a/dist/cross_staff_offset.lua +++ b/dist/cross_staff_offset.lua @@ -139,7 +139,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -172,7 +171,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -188,7 +186,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -227,12 +224,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4310,12 +4304,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4326,7 +4317,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4340,7 +4330,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4348,21 +4337,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4376,7 +4361,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4387,38 +4371,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4428,18 +4403,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4451,33 +4422,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4486,16 +4450,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4506,49 +4466,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4557,7 +4505,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4568,7 +4515,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4577,7 +4523,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4596,7 +4541,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4614,7 +4558,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4632,10 +4575,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4648,11 +4589,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4662,7 +4601,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4676,7 +4614,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4684,13 +4621,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4700,113 +4635,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4815,171 +4724,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5015,7 +4882,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/cue_notes_create.lua b/dist/cue_notes_create.lua index 4b059f87..242802ec 100644 --- a/dist/cue_notes_create.lua +++ b/dist/cue_notes_create.lua @@ -138,9 +138,7 @@ end package.preload["library.clef"] = package.preload["library.clef"] or function() local clef = {} - local client = require("library.client") - local clef_map = { treble = 0, alto = 1, @@ -167,16 +165,12 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() tab_serif = 17 } - - function clef.get_cell_clef(measure, staff_number) local cell_clef = -1 local cell = finale.FCCell(measure, staff_number) local cell_frame_hold = finale.FCCellFrameHold() - cell_frame_hold:ConnectCell(cell) if cell_frame_hold:Load() then - if cell_frame_hold.IsClefList then cell_clef = cell_frame_hold:CreateFirstCellClefChange().ClefIndex else @@ -186,7 +180,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() return cell_clef end - function clef.get_default_clef(first_measure, last_measure, staff_number) local staff = finale.FCStaff() local cell_clef = clef.get_cell_clef(first_measure - 1, staff_number) @@ -199,10 +192,8 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() return cell_clef end - function clef.set_measure_clef(first_measure, last_measure, staff_number, clef_index) client.assert_supports("clef_change") - for measure = first_measure, last_measure do local cell = finale.FCCell(measure, staff_number) local cell_frame_hold = finale.FCCellFrameHold() @@ -221,18 +212,13 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end - function clef.restore_default_clef(first_measure, last_measure, staff_number) client.assert_supports("clef_change") - local default_clef = clef.get_default_clef(first_measure, last_measure, staff_number) - clef.set_measure_clef(first_measure, last_measure, staff_number, default_clef) - end - function clef.process_clefs(mid_clefs) local clefs = {} local new_mid_clefs = finale.FCCellClefChanges() @@ -240,13 +226,11 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() table.insert(clefs, mid_clef) end table.sort(clefs, function (k1, k2) return k1.MeasurePos < k2.MeasurePos end) - for k, mid_clef in ipairs(clefs) do new_mid_clefs:InsertCellClefChange(mid_clef) new_mid_clefs:SaveAllAsNew() end - for i = new_mid_clefs.Count - 1, 1, -1 do local later_clef_change = new_mid_clefs:GetItemAt(i) local earlier_clef_change = new_mid_clefs:GetItemAt(i - 1) @@ -261,17 +245,14 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end ::continue:: end - return new_mid_clefs end - function clef.clef_change(clef_type, region) local clef_index = clef_map[clef_type] local cell_frame_hold = finale.FCCellFrameHold() local last_clef local last_staff = -1 - for cell_measure, cell_staff in eachcell(region) do local cell = finale.FCCell(region.EndMeasure, cell_staff) if cell_staff ~= last_staff then @@ -282,7 +263,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() cell_frame_hold:ConnectCell(cell) if cell_frame_hold:Load() then end - if region:IsFullMeasureIncluded(cell_measure) then clef.set_measure_clef(cell_measure, cell_measure, cell_staff, clef_index) if not region:IsLastEndMeasure() then @@ -296,13 +276,10 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() cell_frame_hold:SaveNew() end end - - else local mid_measure_clefs = cell_frame_hold:CreateCellClefChanges() local new_mid_measure_clefs = finale.FCCellClefChanges() local mid_measure_clef = finale.FCCellClefChange() - if not mid_measure_clefs then mid_measure_clefs = finale.FCCellClefChanges() mid_measure_clef:SetClefIndex(cell_frame_hold.ClefIndex) @@ -311,7 +288,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() mid_measure_clefs:InsertCellClefChange(mid_measure_clef) mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.StartMeasure and region.StartMeasure ~= region.EndMeasure then for mid_clef in each(mid_measure_clefs) do @@ -327,10 +303,8 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() new_mid_measure_clefs:InsertCellClefChange(mid_measure_clef) new_mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.EndMeasure and region.StartMeasure ~= region.EndMeasure then - for mid_clef in each(mid_measure_clefs) do if mid_clef.MeasurePos == 0 then mid_clef:SetClefIndex(clef_index) @@ -343,17 +317,14 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end - mid_measure_clef:SetClefIndex(last_clef) mid_measure_clef:SetMeasurePos(region.EndMeasurePos) mid_measure_clef:Save() new_mid_measure_clefs:InsertCellClefChange(mid_measure_clef) new_mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.StartMeasure and region.StartMeasure == region.EndMeasure then local last_clef = cell:CalcClefIndexAt(region.EndMeasurePos) - for mid_clef in each(mid_measure_clefs) do if mid_clef.MeasurePos == 0 then if region.StartMeasurePos == 0 then @@ -394,14 +365,12 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end end - return clef end package.preload["library.layer"] = package.preload["library.layer"] or function() local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -434,7 +403,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -450,7 +418,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -489,12 +456,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4572,12 +4536,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4588,7 +4549,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4602,7 +4562,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4610,21 +4569,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4638,7 +4593,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4649,38 +4603,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4690,18 +4635,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4713,33 +4654,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4748,16 +4682,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4768,49 +4698,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4819,7 +4737,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4830,7 +4747,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4839,7 +4755,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4858,7 +4773,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4876,7 +4790,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4894,10 +4807,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4910,11 +4821,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4924,7 +4833,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4938,7 +4846,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4946,13 +4853,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4962,113 +4867,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -5077,171 +4956,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5277,7 +5114,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/deletion_chooser.lua b/dist/deletion_chooser.lua index 9d8a9541..c9fc0708 100644 --- a/dist/deletion_chooser.lua +++ b/dist/deletion_chooser.lua @@ -3538,12 +3538,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -3554,7 +3551,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -3568,7 +3564,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -3576,21 +3571,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -3604,7 +3595,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -3615,38 +3605,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -3656,18 +3637,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -3679,33 +3656,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -3714,16 +3684,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -3734,49 +3700,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -3785,7 +3739,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -3796,7 +3749,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -3805,7 +3757,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -3824,7 +3775,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -3842,7 +3792,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -3860,10 +3809,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -3876,11 +3823,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -3890,7 +3835,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -3904,7 +3848,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -3912,13 +3855,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -3928,113 +3869,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4043,171 +3958,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4243,7 +4116,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.utils"] = package.preload["library.utils"] or function() diff --git a/dist/document_options_as_json.lua b/dist/document_options_as_json.lua index 11a33fac..8c7be022 100644 --- a/dist/document_options_as_json.lua +++ b/dist/document_options_as_json.lua @@ -3401,12 +3401,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -3417,7 +3414,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -3431,7 +3427,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -3439,21 +3434,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -3467,7 +3458,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -3478,38 +3468,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -3519,18 +3500,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -3542,33 +3519,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -3577,16 +3547,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -3597,49 +3563,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -3648,7 +3602,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -3659,7 +3612,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -3668,7 +3620,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -3687,7 +3638,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -3705,7 +3655,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -3723,10 +3672,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -3739,11 +3686,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -3753,7 +3698,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -3767,7 +3711,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -3775,13 +3718,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -3791,113 +3732,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -3906,171 +3821,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4106,7 +3979,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["lunajson.decoder"] = package.preload["lunajson.decoder"] or function() diff --git a/dist/document_rename_pdfs.lua b/dist/document_rename_pdfs.lua index 8cc973cb..3a4af9ad 100644 --- a/dist/document_rename_pdfs.lua +++ b/dist/document_rename_pdfs.lua @@ -3401,12 +3401,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -3417,7 +3414,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -3431,7 +3427,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -3439,21 +3434,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -3467,7 +3458,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -3478,38 +3468,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -3519,18 +3500,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -3542,33 +3519,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -3577,16 +3547,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -3597,49 +3563,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -3648,7 +3602,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -3659,7 +3612,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -3668,7 +3620,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -3687,7 +3638,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -3705,7 +3655,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -3723,10 +3672,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -3739,11 +3686,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -3753,7 +3698,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -3767,7 +3711,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -3775,13 +3718,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -3791,113 +3732,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -3906,171 +3821,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4106,7 +3979,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.configuration"] = package.preload["library.configuration"] or function() diff --git a/dist/document_save_as_text.lua b/dist/document_save_as_text.lua index e3414891..87d360ea 100644 --- a/dist/document_save_as_text.lua +++ b/dist/document_save_as_text.lua @@ -4648,12 +4648,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4664,7 +4661,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4678,7 +4674,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4686,21 +4681,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4714,7 +4705,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4725,38 +4715,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4766,18 +4747,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4789,33 +4766,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4824,16 +4794,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4844,49 +4810,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4895,7 +4849,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4906,7 +4859,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4915,7 +4867,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4934,7 +4885,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4952,7 +4902,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4970,10 +4919,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4986,11 +4933,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -5000,7 +4945,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -5014,7 +4958,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -5022,13 +4965,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -5038,113 +4979,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -5153,171 +5068,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5353,7 +5226,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/gracenote_slash.lua b/dist/gracenote_slash.lua index c1d5d4d0..fc630e90 100644 --- a/dist/gracenote_slash.lua +++ b/dist/gracenote_slash.lua @@ -4210,12 +4210,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4226,7 +4223,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4240,7 +4236,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4248,21 +4243,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4276,7 +4267,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4287,38 +4277,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4328,18 +4309,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4351,33 +4328,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4386,16 +4356,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4406,49 +4372,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4457,7 +4411,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4468,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4477,7 +4429,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4496,7 +4447,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4514,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4532,10 +4481,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4548,11 +4495,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4562,7 +4507,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4576,7 +4520,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4584,13 +4527,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4600,113 +4541,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4715,171 +4630,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4915,7 +4788,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/hairpin_creator.lua b/dist/hairpin_creator.lua index 255d164e..37bc0698 100644 --- a/dist/hairpin_creator.lua +++ b/dist/hairpin_creator.lua @@ -4785,12 +4785,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4801,7 +4798,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4815,7 +4811,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4823,21 +4818,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4851,7 +4842,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4862,38 +4852,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4903,18 +4884,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4926,33 +4903,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4961,16 +4931,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4981,49 +4947,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -5032,7 +4986,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -5043,7 +4996,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -5052,7 +5004,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -5071,7 +5022,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -5089,7 +5039,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -5107,10 +5056,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -5123,11 +5070,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -5137,7 +5082,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -5151,7 +5095,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -5159,13 +5102,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -5175,113 +5116,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -5290,171 +5205,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5490,7 +5363,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/layer_clear_selective.lua b/dist/layer_clear_selective.lua index 23e6f344..7d8398d8 100644 --- a/dist/layer_clear_selective.lua +++ b/dist/layer_clear_selective.lua @@ -2,7 +2,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -35,7 +34,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -51,7 +49,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -90,12 +87,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4173,12 +4167,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4189,7 +4180,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4203,7 +4193,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4211,21 +4200,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4239,7 +4224,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4250,38 +4234,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4291,18 +4266,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4314,33 +4285,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4349,16 +4313,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4369,49 +4329,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4420,7 +4368,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4431,7 +4378,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4440,7 +4386,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4459,7 +4404,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4477,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4495,10 +4438,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4511,11 +4452,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4525,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4539,7 +4477,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4547,13 +4484,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4563,113 +4498,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4678,171 +4587,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4878,7 +4745,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/layer_hide.lua b/dist/layer_hide.lua index 02ed6ec9..0f06181a 100644 --- a/dist/layer_hide.lua +++ b/dist/layer_hide.lua @@ -2,7 +2,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -35,7 +34,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -51,7 +49,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -90,12 +87,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4173,12 +4167,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4189,7 +4180,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4203,7 +4193,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4211,21 +4200,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4239,7 +4224,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4250,38 +4234,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4291,18 +4266,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4314,33 +4285,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4349,16 +4313,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4369,49 +4329,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4420,7 +4368,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4431,7 +4378,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4440,7 +4386,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4459,7 +4404,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4477,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4495,10 +4438,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4511,11 +4452,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4525,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4539,7 +4477,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4547,13 +4484,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4563,113 +4498,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4678,171 +4587,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4878,7 +4745,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/layer_mute.lua b/dist/layer_mute.lua index 027df21b..071f024a 100644 --- a/dist/layer_mute.lua +++ b/dist/layer_mute.lua @@ -2,7 +2,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -35,7 +34,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -51,7 +49,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -90,12 +87,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4173,12 +4167,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4189,7 +4180,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4203,7 +4193,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4211,21 +4200,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4239,7 +4224,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4250,38 +4234,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4291,18 +4266,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4314,33 +4285,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4349,16 +4313,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4369,49 +4329,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4420,7 +4368,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4431,7 +4378,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4440,7 +4386,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4459,7 +4404,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4477,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4495,10 +4438,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4511,11 +4452,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4525,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4539,7 +4477,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4547,13 +4484,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4563,113 +4498,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4678,171 +4587,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4878,7 +4745,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/layers_swap_1_2.lua b/dist/layers_swap_1_2.lua index 1745702b..4121f622 100644 --- a/dist/layers_swap_1_2.lua +++ b/dist/layers_swap_1_2.lua @@ -2,7 +2,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -35,7 +34,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -51,7 +49,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -90,12 +87,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/dist/layers_swap_selective.lua b/dist/layers_swap_selective.lua index 1c6246d3..5bf8d01f 100644 --- a/dist/layers_swap_selective.lua +++ b/dist/layers_swap_selective.lua @@ -2,7 +2,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -35,7 +34,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -51,7 +49,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -90,12 +87,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4173,12 +4167,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4189,7 +4180,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4203,7 +4193,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4211,21 +4200,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4239,7 +4224,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4250,38 +4234,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4291,18 +4266,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4314,33 +4285,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4349,16 +4313,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4369,49 +4329,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4420,7 +4368,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4431,7 +4378,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4440,7 +4386,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4459,7 +4404,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4477,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4495,10 +4438,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4511,11 +4452,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4525,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4539,7 +4477,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4547,13 +4484,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4563,113 +4498,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4678,171 +4587,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4878,7 +4745,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/measure_span.lua b/dist/measure_span.lua index 0d5f0392..7036be75 100644 --- a/dist/measure_span.lua +++ b/dist/measure_span.lua @@ -4210,12 +4210,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4226,7 +4223,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4240,7 +4236,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4248,21 +4243,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4276,7 +4267,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4287,38 +4277,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4328,18 +4309,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4351,33 +4328,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4386,16 +4356,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4406,49 +4372,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4457,7 +4411,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4468,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4477,7 +4429,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4496,7 +4447,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4514,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4532,10 +4481,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4548,11 +4495,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4562,7 +4507,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4576,7 +4520,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4584,13 +4527,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4600,113 +4541,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4715,171 +4630,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4915,14 +4788,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.layer"] = package.preload["library.layer"] or function() local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -4955,7 +4826,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -4971,7 +4841,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -5010,12 +4879,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["library.note_entry"] = package.preload["library.note_entry"] or function() @@ -5326,10 +5192,8 @@ end package.preload["library.tie"] = package.preload["library.tie"] or function() local tie = {} - local note_entry = require('library.note_entry') - local equal_note = function(entry, target_note, for_tied_to, tie_must_exist) local found_note = entry:FindPitch(target_note) if not found_note or not tie_must_exist then @@ -5347,7 +5211,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return nil end - function tie.calc_tied_to(note, tie_must_exist) if not note then return nil @@ -5376,7 +5239,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return nil end - function tie.calc_tied_from(note, tie_must_exist) if not note then return nil @@ -5394,7 +5256,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end - function tie.calc_tie_span(note, for_tied_to, tie_must_exist) local start_measnum = (for_tied_to and note.Entry.Measure > 1) and note.Entry.Measure - 1 or note.Entry.Measure local end_measnum = for_tied_to and note.Entry.Measure or note.Entry.Measure + 1 @@ -5416,7 +5277,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return note_entry_layer, start_note, end_note end - function tie.calc_default_direction(note, for_tieend, tie_prefs) if for_tieend then if not note.TieBackwards then @@ -5437,16 +5297,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() - if note.NoteIndex == 0 then return finale.TIEMODDIR_UNDER end if note.NoteIndex == note.Entry.Count - 1 then return finale.TIEMODDIR_OVER end - local inner_default = 0 - if tie_prefs.ChordDirectionType ~= finale.TIECHORDDIR_STEMREVERSAL then if note.NoteIndex < math.floor(note.Entry.Count / 2) then inner_default = finale.TIEMODDIR_UNDER @@ -5520,17 +5377,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end end - return (stemdir > 0) and finale.TIEMODDIR_UNDER or finale.TIEMODDIR_OVER - end - local calc_layer_is_visible = function(staff, layer_number) local altnotation_layer = staff.AltNotationLayer if layer_number ~= altnotation_layer then return staff.AltShowOtherNotes end - local hider_altnotation_types = { finale.ALTSTAFF_BLANKNOTATION, finale.ALTSTAFF_SLASHBEATS, finale.ALTSTAFF_ONEBARREPEAT, finale.ALTSTAFF_TWOBARREPEAT, finale.ALTSTAFF_BLANKNOTATIONRESTS, } @@ -5540,10 +5393,8 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return false end end - return true end - local calc_other_layers_visible = function(entry) local staff = finale.FCCurrentStaffSpec() staff:LoadForEntry(entry) @@ -5564,7 +5415,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return false end - local layer_stem_direction = function(layer_prefs, entry) if layer_prefs.UseFreezeStemsTies then if layer_prefs.UseRestOffsetInMultiple then @@ -5579,7 +5429,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return 0 end - local layer_tie_direction = function(entry) local layer_prefs = finale.FCLayerPrefs() if not layer_prefs:Load(entry.LayerNumber - 1) then @@ -5592,7 +5441,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return 0 end - function tie.calc_direction(note, tie_mod, tie_prefs) @@ -5612,10 +5460,8 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() if note.Entry.FlipTie then return note.Entry:CalcStemUp() and finale.TIEMODDIR_OVER or finale.TIEMODDIR_UNDER end - return tie.calc_default_direction(note, not tie_mod:IsStartTie(), tie_prefs) end - local calc_is_end_of_system = function(note, for_pageview) if not note.Entry:Next() then local region = finale.FCMusicRegion() @@ -5636,7 +5482,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return false end - local has_nonaligned_2nd = function(entry) for note in each(entry) do if note:IsNonAligned2nd() then @@ -5646,7 +5491,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return false end - function tie.calc_connection_code(note, placement, direction, for_endpoint, for_tieend, for_pageview, tie_prefs) @@ -5697,7 +5541,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return finale.TIEMODCNCT_NONE end - local calc_placement_for_endpoint = function(note, tie_mod, tie_prefs, direction, stemdir, for_endpoint, end_note_slot, end_num_notes, end_upstem2nd, end_downstem2nd) local note_slot = end_note_slot and end_note_slot or note.NoteIndex local num_notes = end_num_notes and end_num_notes or note.Entry.Count @@ -5742,7 +5585,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return direction == finale.TIEMODDIR_UNDER and finale.TIEPLACE_UNDERINNER or finale.TIEPLACE_OVERINNER end - function tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -5818,16 +5660,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end - if start_placement == finale.TIEPLACE_OVERINNER or start_placement == finale.TIEPLACE_UNDERINNER then end_placement = start_placement elseif end_placement == finale.TIEPLACE_OVERINNER or end_placement == finale.TIEPLACE_UNDERINNER then start_placement = end_placement end - return start_placement, end_placement end - local calc_prefs_offset_for_endpoint = function(note, tie_prefs, tie_placement_prefs, placement, for_endpoint, for_tieend, for_pageview) local tie_ if for_endpoint then @@ -5841,7 +5680,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return tie_placement_prefs:GetHorizontalStart(placement), tie_placement_prefs:GetVerticalStart(placement) end - local activate_endpoint = function(note, tie_mod, placement, direction, for_endpoint, for_pageview, tie_prefs, tie_placement_prefs) local active_check_func = for_endpoint and tie_mod.IsEndPointActive or tie_mod.IsStartPointActive if active_check_func(tie_mod) then @@ -5855,7 +5693,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return true end - function tie.activate_endpoints(note, tie_mod, for_pageview, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -5871,13 +5708,11 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return lactivated or ractivated end - local calc_tie_length = function(note, tie_mod, for_pageview, direction, tie_prefs, tie_placement_prefs) local cell_metrics_start = finale.FCCellMetrics() local entry_metrics_start = finale.FCEntryMetrics() cell_metrics_start:LoadAtEntry(note.Entry) entry_metrics_start:Load(note.Entry) - local cell_metrics_end = finale.FCCellMetrics() local entry_metrics_end = finale.FCEntryMetrics() local note_entry_layer, start_note, end_note = tie.calc_tie_span(note, false, true) @@ -5887,20 +5722,16 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() entry_metrics_end:Load(end_note.Entry) end end - local lplacement, rplacement = tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) local horz_start = 0 local horz_end = 0 local incr_start = 0 local incr_end = 0 - local OUTER_NOTE_OFFSET_PCTG = 7.0 / 16.0 local INNER_INCREMENT = 6 - local staff_scaling = cell_metrics_start.StaffScaling / 10000.0 local horz_stretch = for_pageview and 1 or cell_metrics_start.HorizontalStretch / 10000.0 - if tie_mod:IsStartTie() then horz_start = entry_metrics_start:GetNoteLeftPosition(note.NoteIndex) / horz_stretch if lplacement == finale.TIEPLACE_OVERINNER or lplacement == finale.TIEPLACE_OVEROUTERSTEM or lplacement == finale.TIEPLACE_UNDERINNER then @@ -5912,7 +5743,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() else horz_start = (cell_metrics_start.MusicStartPos * staff_scaling) / horz_stretch end - if tie_mod:IsStartTie() and (not end_note or cell_metrics_start.StaffSystem ~= cell_metrics_end.StaffSystem) then local next_cell_metrics = finale.FCCellMetrics() local next_metrics_loaded = next_cell_metrics:LoadAtCell(finale.FCCell(note.Entry.Measure + 1, note.Entry.Staff)) @@ -5941,7 +5771,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() horz_end = horz_end + (entry_metrics_start:GetNoteWidth(note.NoteIndex) * (1.0 - OUTER_NOTE_OFFSET_PCTG)) end end - local start_offset = tie_mod.StartHorizontalPos if not tie_mod:IsStartPointActive() then start_offset = calc_prefs_offset_for_endpoint(note, tie_prefs, tie_placement_prefs, lplacement, false, not tie_mod:IsStartTie(), for_pageview) @@ -5950,7 +5779,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() if not tie_mod:IsEndPointActive() then end_offset = calc_prefs_offset_for_endpoint(note, tie_prefs, tie_placement_prefs, lplacement, true, not tie_mod:IsStartTie(), for_pageview) end - local tie_length = horz_end - horz_start tie_length = tie_length / staff_scaling @@ -5958,7 +5786,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return math.floor(tie_length + 0.5) end - function tie.calc_contour_index(note, tie_mod, for_pageview, direction, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -5978,7 +5805,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return finale.TCONTOURIDX_MEDIUM, tie_length end - local calc_inset_and_height = function(tie_prefs, tie_contour_prefs, length, contour_index, get_fixed_func, get_relative_func, get_height_func) @@ -6010,7 +5836,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return inset, height end - function tie.activate_contour(note, tie_mod, for_pageview, tie_prefs) if tie_mod:IsContourActive() then return false @@ -6031,7 +5856,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() tie_mod:ActivateContour(left_inset, left_height, right_inset, right_height, tie_prefs.FixedInsetStyle) return true end - return tie end function plugindef() diff --git a/dist/midi_note_values.lua b/dist/midi_note_values.lua index 19f4421c..95447832 100644 --- a/dist/midi_note_values.lua +++ b/dist/midi_note_values.lua @@ -4210,12 +4210,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4226,7 +4223,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4240,7 +4236,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4248,21 +4243,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4276,7 +4267,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4287,38 +4277,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4328,18 +4309,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4351,33 +4328,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4386,16 +4356,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4406,49 +4372,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4457,7 +4411,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4468,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4477,7 +4429,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4496,7 +4447,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4514,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4532,10 +4481,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4548,11 +4495,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4562,7 +4507,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4576,7 +4520,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4584,13 +4527,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4600,113 +4541,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4715,171 +4630,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4915,14 +4788,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.layer"] = package.preload["library.layer"] or function() local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -4955,7 +4826,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -4971,7 +4841,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -5010,12 +4879,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/dist/note_bariolage.lua b/dist/note_bariolage.lua index 17eb2858..80f6e46d 100644 --- a/dist/note_bariolage.lua +++ b/dist/note_bariolage.lua @@ -2,7 +2,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -35,7 +34,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -51,7 +49,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -90,12 +87,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["library.note_entry"] = package.preload["library.note_entry"] or function() diff --git a/dist/note_cluster_determinate.lua b/dist/note_cluster_determinate.lua index ee4c5c0a..e3a982e9 100644 --- a/dist/note_cluster_determinate.lua +++ b/dist/note_cluster_determinate.lua @@ -309,23 +309,17 @@ function plugindef() finaleplugin.Copyright = "©2019 Jacob Winkler" finaleplugin.AuthorEmail = "jacob.winkler@mac.com" finaleplugin.Version = "1.0" - finaleplugin.Date = "11/02/2019" finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/note_cluster_determinate.hash" + finaleplugin.Date = "11/02/2019" + finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/note_cluster_determinate.hash" return "Cluster - Determinate", "Cluster - Determinate", "Creates a determinate cluster." end - local note_entry = require("library.note_entry") - local region = finenv.Region() - local layer = {} local layer_one_note = {} local layer_two_note = {} - local measure = {} - local horizontal_offset = -20 - - local function process_notes(music_region) local stem_dir = {} @@ -333,13 +327,10 @@ local function process_notes(music_region) entry.FreezeStem = false table.insert(stem_dir, entry:CalcStemUp()) end - layer.copy(1, 2) layer.copy(1, 3) - local i = 1 local j = 1 - for note_entry in eachentrysaved(music_region) do local span = note_entry:CalcDisplacementRange(nil) local stem_direction = stem_dir[i] @@ -398,8 +389,6 @@ local function process_notes(music_region) end end end - - function hide_stems(entry, stem_direction) local stem = finale.FCCustomStemMod() stem:SetNoteEntry(entry) @@ -418,8 +407,6 @@ function hide_stems(entry, stem_direction) end entry:SetBeamBeat(true) end - - function layer.copy(source, destination) local region = finenv.Region() local start = region.StartMeasure @@ -427,7 +414,6 @@ function layer.copy(source, destination) local system_staves = finale.FCSystemStaves() system_staves:LoadAllForRegion(region) - source = source - 1 destination = destination - 1 for system_staff in each(system_staves) do @@ -440,32 +426,24 @@ function layer.copy(source, destination) noteentrylayerDest:Save() end end - - function delete_bottom_notes(entry) while entry.Count > 1 do local lowest_note = entry:CalcLowestNote(nil) note_entry.delete_note(lowest_note) end end - - function delete_top_notes(entry) while entry.Count > 1 do local highest_note = entry:CalcHighestNote(nil) note_entry.delete_note(highest_note) end end - - function delete_top_bottom_notes(entry) local highest_note = entry:CalcHighestNote(nil) note_entry.delete_note(highest_note) local lowest_note = entry:CalcLowestNote(nil) note_entry.delete_note(lowest_note) end - - function delete_middle_notes(entry) while entry.Count > 2 do local n = 1 @@ -480,8 +458,6 @@ function delete_middle_notes(entry) end end end - - local function create_cluster_line() local line_exists = false @@ -500,7 +476,6 @@ local function create_cluster_line() end end - if line_exists == false then local csld = finale.FCCustomSmartLineDef() csld.Horizontal = false @@ -513,8 +488,6 @@ local function create_cluster_line() end return my_line end - - local function create_short_cluster_line() local line_exists = false @@ -533,7 +506,6 @@ local function create_short_cluster_line() end end - if line_exists == false then local csld = finale.FCCustomSmartLineDef() csld.Horizontal = false @@ -546,18 +518,14 @@ local function create_short_cluster_line() end return my_line end - - function add_cluster_line(left_note, right_note, line_id) if left_note:IsNote() and left_note.Count == 1 and right_note:IsNote() then local smartshape = finale.FCSmartShape() local layer_one_highest = left_note:CalcHighestNote(nil) local note_width = layer_one_highest:CalcNoteheadWidth() local layer_one_note_y = layer_one_highest:CalcStaffPosition() - local layer_two_highest = right_note:CalcHighestNote(nil) local layer_two_note_y = layer_two_highest:CalcStaffPosition() - local top_pad = 0 local bottom_pad = 0 if left_note.Duration >= 2048 and left_note.Duration < 4096 then @@ -569,7 +537,6 @@ function add_cluster_line(left_note, right_note, line_id) end layer_one_note_y = (layer_one_note_y * 12) - top_pad layer_two_note_y = (layer_two_note_y * 12) + bottom_pad - smartshape.ShapeType = finale.SMARTSHAPE_CUSTOM smartshape.EntryBased = false smartshape.MakeHorizontal = false @@ -577,35 +544,28 @@ function add_cluster_line(left_note, right_note, line_id) smartshape.PresetShape = true smartshape.Visible = true smartshape.LineID = line_id - local left_segment = smartshape:GetTerminateSegmentLeft() left_segment:SetMeasure(left_note.Measure) left_segment:SetStaff(left_note.Staff) left_segment:SetMeasurePos(left_note.MeasurePos) left_segment:SetEndpointOffsetX(note_width / 2) left_segment:SetEndpointOffsetY(layer_one_note_y) - local right_segment = smartshape:GetTerminateSegmentRight() right_segment:SetMeasure(right_note.Measure) right_segment:SetStaff(right_note.Staff) right_segment:SetMeasurePos(right_note.MeasurePos) right_segment:SetEndpointOffsetX(note_width / 2) right_segment:SetEndpointOffsetY(layer_two_note_y) - smartshape:SaveNewEverything(nil, nil) end end - - function add_short_cluster_line(entry, short_lineID) if entry:IsNote() and entry.Count > 1 then local smartshape = finale.FCSmartShape() local left_note = entry:CalcHighestNote(nil) local left_note_y = left_note:CalcStaffPosition() * 12 + 12 - local right_note = entry:CalcLowestNote(nil) local right_note_y = right_note:CalcStaffPosition() * 12 - 12 - smartshape.ShapeType = finale.SMARTSHAPE_CUSTOM smartshape.EntryBased = false smartshape.MakeHorizontal = false @@ -613,31 +573,25 @@ function add_short_cluster_line(entry, short_lineID) smartshape.Visible = true smartshape.BeatAttached = true smartshape.LineID = short_lineID - local left_segment = smartshape:GetTerminateSegmentLeft() left_segment:SetMeasure(entry.Measure) left_segment:SetStaff(entry.Staff) left_segment:SetMeasurePos(entry.MeasurePos) left_segment:SetEndpointOffsetX(horizontal_offset) left_segment:SetEndpointOffsetY(left_note_y) - local right_segment = smartshape:GetTerminateSegmentRight() right_segment:SetMeasure(entry.Measure) right_segment:SetStaff(entry.Staff) right_segment:SetMeasurePos(entry.MeasurePos) right_segment:SetEndpointOffsetX(horizontal_offset) right_segment:SetEndpointOffsetY(right_note_y) - smartshape:SaveNewEverything(nil, nil) end end - local line_id = create_cluster_line() local short_lineID = create_short_cluster_line() - for add_staff = region:GetStartStaff(), region:GetEndStaff() do local count = 0 - for k in pairs(layer_one_note) do layer_one_note[k] = nil end @@ -647,13 +601,11 @@ for add_staff = region:GetStartStaff(), region:GetEndStaff() do for k in pairs(measure) do measure[k] = nil end - region:SetStartStaff(add_staff) region:SetEndStaff(add_staff) local measures = finale.FCMeasures() measures:LoadRegion(region) process_notes(region) - for entry in eachentrysaved(region) do if entry.LayerNumber == 1 then table.insert(layer_one_note, entry) @@ -663,14 +615,11 @@ for add_staff = region:GetStartStaff(), region:GetEndStaff() do table.insert(layer_two_note, entry) end end - for i = 1, count do add_short_cluster_line(layer_one_note[i], short_lineID) add_cluster_line(layer_one_note[i], layer_two_note[i], line_id) end end - - for note_entry in eachentrysaved(finenv.Region()) do if note_entry:IsNote() and note_entry.Count > 1 then for note in each(note_entry) do diff --git a/dist/noteheads_change_by_layer.lua b/dist/noteheads_change_by_layer.lua index 0631e276..1d3571fd 100644 --- a/dist/noteheads_change_by_layer.lua +++ b/dist/noteheads_change_by_layer.lua @@ -4153,12 +4153,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4169,7 +4166,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4183,7 +4179,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4191,21 +4186,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4219,7 +4210,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4230,38 +4220,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4271,18 +4252,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4294,33 +4271,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4329,16 +4299,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4349,49 +4315,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4400,7 +4354,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4411,7 +4364,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4420,7 +4372,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4439,7 +4390,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4457,7 +4407,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4475,10 +4424,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4491,11 +4438,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4505,7 +4450,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4519,7 +4463,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4527,13 +4470,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4543,113 +4484,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4658,171 +4573,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4858,7 +4731,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.utils"] = package.preload["library.utils"] or function() @@ -5161,7 +5033,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -5194,7 +5065,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -5210,7 +5080,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -5249,12 +5118,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/dist/notes_tie.lua b/dist/notes_tie.lua index 4d655981..ad975057 100644 --- a/dist/notes_tie.lua +++ b/dist/notes_tie.lua @@ -306,10 +306,8 @@ end package.preload["library.tie"] = package.preload["library.tie"] or function() local tie = {} - local note_entry = require('library.note_entry') - local equal_note = function(entry, target_note, for_tied_to, tie_must_exist) local found_note = entry:FindPitch(target_note) if not found_note or not tie_must_exist then @@ -327,7 +325,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return nil end - function tie.calc_tied_to(note, tie_must_exist) if not note then return nil @@ -356,7 +353,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return nil end - function tie.calc_tied_from(note, tie_must_exist) if not note then return nil @@ -374,7 +370,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end - function tie.calc_tie_span(note, for_tied_to, tie_must_exist) local start_measnum = (for_tied_to and note.Entry.Measure > 1) and note.Entry.Measure - 1 or note.Entry.Measure local end_measnum = for_tied_to and note.Entry.Measure or note.Entry.Measure + 1 @@ -396,7 +391,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return note_entry_layer, start_note, end_note end - function tie.calc_default_direction(note, for_tieend, tie_prefs) if for_tieend then if not note.TieBackwards then @@ -417,16 +411,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() - if note.NoteIndex == 0 then return finale.TIEMODDIR_UNDER end if note.NoteIndex == note.Entry.Count - 1 then return finale.TIEMODDIR_OVER end - local inner_default = 0 - if tie_prefs.ChordDirectionType ~= finale.TIECHORDDIR_STEMREVERSAL then if note.NoteIndex < math.floor(note.Entry.Count / 2) then inner_default = finale.TIEMODDIR_UNDER @@ -500,17 +491,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end end - return (stemdir > 0) and finale.TIEMODDIR_UNDER or finale.TIEMODDIR_OVER - end - local calc_layer_is_visible = function(staff, layer_number) local altnotation_layer = staff.AltNotationLayer if layer_number ~= altnotation_layer then return staff.AltShowOtherNotes end - local hider_altnotation_types = { finale.ALTSTAFF_BLANKNOTATION, finale.ALTSTAFF_SLASHBEATS, finale.ALTSTAFF_ONEBARREPEAT, finale.ALTSTAFF_TWOBARREPEAT, finale.ALTSTAFF_BLANKNOTATIONRESTS, } @@ -520,10 +507,8 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return false end end - return true end - local calc_other_layers_visible = function(entry) local staff = finale.FCCurrentStaffSpec() staff:LoadForEntry(entry) @@ -544,7 +529,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return false end - local layer_stem_direction = function(layer_prefs, entry) if layer_prefs.UseFreezeStemsTies then if layer_prefs.UseRestOffsetInMultiple then @@ -559,7 +543,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return 0 end - local layer_tie_direction = function(entry) local layer_prefs = finale.FCLayerPrefs() if not layer_prefs:Load(entry.LayerNumber - 1) then @@ -572,7 +555,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return 0 end - function tie.calc_direction(note, tie_mod, tie_prefs) @@ -592,10 +574,8 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() if note.Entry.FlipTie then return note.Entry:CalcStemUp() and finale.TIEMODDIR_OVER or finale.TIEMODDIR_UNDER end - return tie.calc_default_direction(note, not tie_mod:IsStartTie(), tie_prefs) end - local calc_is_end_of_system = function(note, for_pageview) if not note.Entry:Next() then local region = finale.FCMusicRegion() @@ -616,7 +596,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return false end - local has_nonaligned_2nd = function(entry) for note in each(entry) do if note:IsNonAligned2nd() then @@ -626,7 +605,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return false end - function tie.calc_connection_code(note, placement, direction, for_endpoint, for_tieend, for_pageview, tie_prefs) @@ -677,7 +655,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return finale.TIEMODCNCT_NONE end - local calc_placement_for_endpoint = function(note, tie_mod, tie_prefs, direction, stemdir, for_endpoint, end_note_slot, end_num_notes, end_upstem2nd, end_downstem2nd) local note_slot = end_note_slot and end_note_slot or note.NoteIndex local num_notes = end_num_notes and end_num_notes or note.Entry.Count @@ -722,7 +699,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return direction == finale.TIEMODDIR_UNDER and finale.TIEPLACE_UNDERINNER or finale.TIEPLACE_OVERINNER end - function tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -798,16 +774,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end - if start_placement == finale.TIEPLACE_OVERINNER or start_placement == finale.TIEPLACE_UNDERINNER then end_placement = start_placement elseif end_placement == finale.TIEPLACE_OVERINNER or end_placement == finale.TIEPLACE_UNDERINNER then start_placement = end_placement end - return start_placement, end_placement end - local calc_prefs_offset_for_endpoint = function(note, tie_prefs, tie_placement_prefs, placement, for_endpoint, for_tieend, for_pageview) local tie_ if for_endpoint then @@ -821,7 +794,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return tie_placement_prefs:GetHorizontalStart(placement), tie_placement_prefs:GetVerticalStart(placement) end - local activate_endpoint = function(note, tie_mod, placement, direction, for_endpoint, for_pageview, tie_prefs, tie_placement_prefs) local active_check_func = for_endpoint and tie_mod.IsEndPointActive or tie_mod.IsStartPointActive if active_check_func(tie_mod) then @@ -835,7 +807,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return true end - function tie.activate_endpoints(note, tie_mod, for_pageview, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -851,13 +822,11 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return lactivated or ractivated end - local calc_tie_length = function(note, tie_mod, for_pageview, direction, tie_prefs, tie_placement_prefs) local cell_metrics_start = finale.FCCellMetrics() local entry_metrics_start = finale.FCEntryMetrics() cell_metrics_start:LoadAtEntry(note.Entry) entry_metrics_start:Load(note.Entry) - local cell_metrics_end = finale.FCCellMetrics() local entry_metrics_end = finale.FCEntryMetrics() local note_entry_layer, start_note, end_note = tie.calc_tie_span(note, false, true) @@ -867,20 +836,16 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() entry_metrics_end:Load(end_note.Entry) end end - local lplacement, rplacement = tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) local horz_start = 0 local horz_end = 0 local incr_start = 0 local incr_end = 0 - local OUTER_NOTE_OFFSET_PCTG = 7.0 / 16.0 local INNER_INCREMENT = 6 - local staff_scaling = cell_metrics_start.StaffScaling / 10000.0 local horz_stretch = for_pageview and 1 or cell_metrics_start.HorizontalStretch / 10000.0 - if tie_mod:IsStartTie() then horz_start = entry_metrics_start:GetNoteLeftPosition(note.NoteIndex) / horz_stretch if lplacement == finale.TIEPLACE_OVERINNER or lplacement == finale.TIEPLACE_OVEROUTERSTEM or lplacement == finale.TIEPLACE_UNDERINNER then @@ -892,7 +857,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() else horz_start = (cell_metrics_start.MusicStartPos * staff_scaling) / horz_stretch end - if tie_mod:IsStartTie() and (not end_note or cell_metrics_start.StaffSystem ~= cell_metrics_end.StaffSystem) then local next_cell_metrics = finale.FCCellMetrics() local next_metrics_loaded = next_cell_metrics:LoadAtCell(finale.FCCell(note.Entry.Measure + 1, note.Entry.Staff)) @@ -921,7 +885,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() horz_end = horz_end + (entry_metrics_start:GetNoteWidth(note.NoteIndex) * (1.0 - OUTER_NOTE_OFFSET_PCTG)) end end - local start_offset = tie_mod.StartHorizontalPos if not tie_mod:IsStartPointActive() then start_offset = calc_prefs_offset_for_endpoint(note, tie_prefs, tie_placement_prefs, lplacement, false, not tie_mod:IsStartTie(), for_pageview) @@ -930,7 +893,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() if not tie_mod:IsEndPointActive() then end_offset = calc_prefs_offset_for_endpoint(note, tie_prefs, tie_placement_prefs, lplacement, true, not tie_mod:IsStartTie(), for_pageview) end - local tie_length = horz_end - horz_start tie_length = tie_length / staff_scaling @@ -938,7 +900,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return math.floor(tie_length + 0.5) end - function tie.calc_contour_index(note, tie_mod, for_pageview, direction, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -958,7 +919,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return finale.TCONTOURIDX_MEDIUM, tie_length end - local calc_inset_and_height = function(tie_prefs, tie_contour_prefs, length, contour_index, get_fixed_func, get_relative_func, get_height_func) @@ -990,7 +950,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return inset, height end - function tie.activate_contour(note, tie_mod, for_pageview, tie_prefs) if tie_mod:IsContourActive() then return false @@ -1011,7 +970,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() tie_mod:ActivateContour(left_inset, left_height, right_inset, right_height, tie_prefs.FixedInsetStyle) return true end - return tie end function plugindef() diff --git a/dist/rest_offsets.lua b/dist/rest_offsets.lua index 680d2947..96630674 100644 --- a/dist/rest_offsets.lua +++ b/dist/rest_offsets.lua @@ -4073,12 +4073,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4089,7 +4086,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4103,7 +4099,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4111,21 +4106,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4139,7 +4130,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4150,38 +4140,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4191,18 +4172,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4214,33 +4191,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4249,16 +4219,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4269,49 +4235,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4320,7 +4274,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4331,7 +4284,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4340,7 +4292,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4359,7 +4310,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4377,7 +4327,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4395,10 +4344,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4411,11 +4358,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4425,7 +4370,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4439,7 +4383,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4447,13 +4390,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4463,113 +4404,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4578,171 +4493,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4778,14 +4651,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.layer"] = package.preload["library.layer"] or function() local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -4818,7 +4689,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -4834,7 +4704,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -4873,12 +4742,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/dist/slur_selection.lua b/dist/slur_selection.lua index 1bc6e576..b1d2ac6d 100644 --- a/dist/slur_selection.lua +++ b/dist/slur_selection.lua @@ -146,7 +146,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -179,7 +178,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -195,7 +193,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -234,12 +231,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/dist/smufl_bravura_larger_noteheads.lua b/dist/smufl_bravura_larger_noteheads.lua index 3768046f..daa3150c 100644 --- a/dist/smufl_bravura_larger_noteheads.lua +++ b/dist/smufl_bravura_larger_noteheads.lua @@ -679,12 +679,11 @@ function plugindef() finaleplugin.Date = "4/18/2022" finaleplugin.Notes = [[ Replaces the noteheads in a 'Bravura' document with the larger glyphs included in the Stylistic Alternates category. These alternate glyphs (which are about 8% larger than the ones loaded by default) are the ones that the font is actually designed to use, and are the ones used by Dorico. For a discussion about these larger noteheads and why they are not used by default, see this thread in the MuseScore forum: https://musescore.org/en/node/68461 - ]] finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/smufl_bravura_larger_noteheads.hash" + ]] + finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/smufl_bravura_larger_noteheads.hash" return "Bravura: Large Noteheads", "Bravura: Large Noteheads", "Replaces noteheads in Bravura with the intended larger size." end - local library = require("library.general_library") - function bravura_large_noteheads() local default_music_font = library.get_default_music_font_name() if default_music_font == "Bravura" then @@ -697,5 +696,4 @@ function bravura_large_noteheads() musiccharacterprefs:Save() end end - bravura_large_noteheads() diff --git a/dist/smufl_maestro_wide_noteheads.lua b/dist/smufl_maestro_wide_noteheads.lua index 0eaa2ae3..e18923c7 100644 --- a/dist/smufl_maestro_wide_noteheads.lua +++ b/dist/smufl_maestro_wide_noteheads.lua @@ -679,12 +679,11 @@ function plugindef() finaleplugin.Date = "7/24/2022" finaleplugin.Notes = [[ Replaces the noteheads in a 'Finale Maestro' document with the 'Maestro Wide' glyphs included in the Alternates & Extras category. - ]] finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/smufl_maestro_wide_noteheads.hash" + ]] + finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/smufl_maestro_wide_noteheads.hash" return "Finale Maestro: Wide Notes", "Finale Maestro: Wide Notes", "Replaces noteheads in Finale Maestro with the wide variation." end - local library = require("library.general_library") - function maestro_wide_noteheads() local default_music_font = library.get_default_music_font_name() if default_music_font == "Finale Maestro" or default_music_font == "FinaleMaestro" then @@ -697,5 +696,4 @@ function maestro_wide_noteheads() musiccharacterprefs:Save() end end - maestro_wide_noteheads() \ No newline at end of file diff --git a/dist/staff_explode.lua b/dist/staff_explode.lua index abf9e76e..0794293b 100644 --- a/dist/staff_explode.lua +++ b/dist/staff_explode.lua @@ -1,9 +1,7 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() local clef = {} - local client = require("library.client") - local clef_map = { treble = 0, alto = 1, @@ -30,16 +28,12 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() tab_serif = 17 } - - function clef.get_cell_clef(measure, staff_number) local cell_clef = -1 local cell = finale.FCCell(measure, staff_number) local cell_frame_hold = finale.FCCellFrameHold() - cell_frame_hold:ConnectCell(cell) if cell_frame_hold:Load() then - if cell_frame_hold.IsClefList then cell_clef = cell_frame_hold:CreateFirstCellClefChange().ClefIndex else @@ -49,7 +43,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() return cell_clef end - function clef.get_default_clef(first_measure, last_measure, staff_number) local staff = finale.FCStaff() local cell_clef = clef.get_cell_clef(first_measure - 1, staff_number) @@ -62,10 +55,8 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() return cell_clef end - function clef.set_measure_clef(first_measure, last_measure, staff_number, clef_index) client.assert_supports("clef_change") - for measure = first_measure, last_measure do local cell = finale.FCCell(measure, staff_number) local cell_frame_hold = finale.FCCellFrameHold() @@ -84,18 +75,13 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end - function clef.restore_default_clef(first_measure, last_measure, staff_number) client.assert_supports("clef_change") - local default_clef = clef.get_default_clef(first_measure, last_measure, staff_number) - clef.set_measure_clef(first_measure, last_measure, staff_number, default_clef) - end - function clef.process_clefs(mid_clefs) local clefs = {} local new_mid_clefs = finale.FCCellClefChanges() @@ -103,13 +89,11 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() table.insert(clefs, mid_clef) end table.sort(clefs, function (k1, k2) return k1.MeasurePos < k2.MeasurePos end) - for k, mid_clef in ipairs(clefs) do new_mid_clefs:InsertCellClefChange(mid_clef) new_mid_clefs:SaveAllAsNew() end - for i = new_mid_clefs.Count - 1, 1, -1 do local later_clef_change = new_mid_clefs:GetItemAt(i) local earlier_clef_change = new_mid_clefs:GetItemAt(i - 1) @@ -124,17 +108,14 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end ::continue:: end - return new_mid_clefs end - function clef.clef_change(clef_type, region) local clef_index = clef_map[clef_type] local cell_frame_hold = finale.FCCellFrameHold() local last_clef local last_staff = -1 - for cell_measure, cell_staff in eachcell(region) do local cell = finale.FCCell(region.EndMeasure, cell_staff) if cell_staff ~= last_staff then @@ -145,7 +126,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() cell_frame_hold:ConnectCell(cell) if cell_frame_hold:Load() then end - if region:IsFullMeasureIncluded(cell_measure) then clef.set_measure_clef(cell_measure, cell_measure, cell_staff, clef_index) if not region:IsLastEndMeasure() then @@ -159,13 +139,10 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() cell_frame_hold:SaveNew() end end - - else local mid_measure_clefs = cell_frame_hold:CreateCellClefChanges() local new_mid_measure_clefs = finale.FCCellClefChanges() local mid_measure_clef = finale.FCCellClefChange() - if not mid_measure_clefs then mid_measure_clefs = finale.FCCellClefChanges() mid_measure_clef:SetClefIndex(cell_frame_hold.ClefIndex) @@ -174,7 +151,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() mid_measure_clefs:InsertCellClefChange(mid_measure_clef) mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.StartMeasure and region.StartMeasure ~= region.EndMeasure then for mid_clef in each(mid_measure_clefs) do @@ -190,10 +166,8 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() new_mid_measure_clefs:InsertCellClefChange(mid_measure_clef) new_mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.EndMeasure and region.StartMeasure ~= region.EndMeasure then - for mid_clef in each(mid_measure_clefs) do if mid_clef.MeasurePos == 0 then mid_clef:SetClefIndex(clef_index) @@ -206,17 +180,14 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end - mid_measure_clef:SetClefIndex(last_clef) mid_measure_clef:SetMeasurePos(region.EndMeasurePos) mid_measure_clef:Save() new_mid_measure_clefs:InsertCellClefChange(mid_measure_clef) new_mid_measure_clefs:SaveAllAsNew() end - if cell_frame_hold.Measure == region.StartMeasure and region.StartMeasure == region.EndMeasure then local last_clef = cell:CalcClefIndexAt(region.EndMeasurePos) - for mid_clef in each(mid_measure_clefs) do if mid_clef.MeasurePos == 0 then if region.StartMeasurePos == 0 then @@ -257,7 +228,6 @@ package.preload["library.clef"] = package.preload["library.clef"] or function() end end end - return clef end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4335,12 +4305,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4351,7 +4318,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4365,7 +4331,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4373,21 +4338,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4401,7 +4362,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4412,38 +4372,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4453,18 +4404,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4476,33 +4423,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4511,16 +4451,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4531,49 +4467,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4582,7 +4506,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4593,7 +4516,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4602,7 +4524,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4621,7 +4542,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4639,7 +4559,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4657,10 +4576,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4673,11 +4590,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4687,7 +4602,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4701,7 +4615,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4709,13 +4622,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4725,113 +4636,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4840,171 +4725,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5040,7 +4883,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.note_entry"] = package.preload["library.note_entry"] or function() @@ -5352,7 +5194,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -5385,7 +5226,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -5401,7 +5241,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -5440,12 +5279,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/dist/staff_rename.lua b/dist/staff_rename.lua index 7b46b1c6..fdbd419b 100644 --- a/dist/staff_rename.lua +++ b/dist/staff_rename.lua @@ -304,23 +304,17 @@ function plugindef() finaleplugin.MinJWLuaVersion = 0.63 finaleplugin.Notes = [[ USING THE 'STAFF RENAME' SCRIPT - This script creates a dialog containing the full and abbreviated names of all selected instruments, including multi-staff instruments such as organ or piano. This allows for quick renaming of staves, with far less mouse clicking than trying to rename them from the Score Manager. - If there is no selection, all staves will be loaded. - There are buttons for each instrument that will copy the full name into the abbreviated name field. - There is a popup at the bottom of the list that will automatically set all transposing instruments to show either the instrument and then the transposition (e.g. "Clarinet in Bb"), or the transposition and then the instrument (e.g. "Bb Clarinet"). - Speaking of the Bb Clarinet... Accidentals are displayed with square brackets, so the dialog will show "B[b] Clarinet". This is then converted into symbols using the appropriate Enigma tags. All other font info is retained. -]] finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/staff_rename.hash" +]] + finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/staff_rename.hash" return "Rename Staves", "Rename Staves", "Renames selected staves" end - local utils = require("library.utils") local configuration = require("library.configuration") - function staff_rename() local script_name = "rename_staves" local config = {use_doc_fonts = 1} @@ -363,7 +357,6 @@ function staff_rename() local form_0_names = {"Clarinet in B[b]", "Clarinet in A", "Clarinet in E[b]","Horn in F", "Trumpet in B[b]", "Trumpet in C", "Horn in E[b]", "Piccolo Trumpet in A", "Trumpet in D", "Cornet in E[b]", "Pennywhistle in D", "Pennywhistle in G", "Tin Whistle in B[b]", "Melody Sax in C"} local form_1_names = {"B[b] Clarinet", "A Clarinet", "E[b] Clarinet", "F Horn", "B[b] Trumpet", "C Trumpet", "E[b] Horn", "A Piccolo Trumpet", "D Trumpet", "E[b] Cornet", "D Pennywhistle", "G Pennywhistle", "B[b] Tin Whistle", "C Melody Sax"} - function enigma_to_accidental(str) str.LuaString = string.gsub(str.LuaString, "%^flat%(%)", "[b]") str.LuaString = string.gsub(str.LuaString, "%^natural%(%)", "[n]") @@ -371,14 +364,12 @@ function staff_rename() str:TrimEnigmaTags() return str end - function accidental_to_enigma(s) s.LuaString = string.gsub(s.LuaString, "%[b%]", "^flat()") s.LuaString = string.gsub(s.LuaString, "%[n%]", "^natural()") s.LuaString = string.gsub(s.LuaString, "%[%#%]", "^sharp()") return s end - for inst in each(multi_inst) do table.insert(multi_inst_grp, inst.GroupID) local grp = finale.FCGroup() @@ -386,7 +377,6 @@ function staff_rename() local str = grp:CreateFullNameString() local font = str:CreateLastFontInfo() enigma_to_accidental(str) - table.insert(multi_fullnames, str.LuaString) local font_enigma = finale.FCString() font_enigma = font:CreateEnigmaString(nil) @@ -410,7 +400,6 @@ function staff_rename() table.insert(multi_staves, multi_staff) multi_staff = {} end - local sysstaves = finale.FCSystemStaves() local region = finale.FCMusicRegion() region = finenv.Region() @@ -418,11 +407,9 @@ function staff_rename() region:SetFullDocument() end sysstaves:LoadAllForRegion(region) - for sysstaff in each(sysstaves) do for i,j in pairs(multi_staves) do - for k,l in pairs(multi_staves[i]) do if multi_staves[i][k] == sysstaff.Staff and multi_staves[i][k] ~= 0 then local staff = finale.FCStaff() @@ -450,7 +437,6 @@ function staff_rename() end end - local staff = finale.FCStaff() staff:Load(sysstaff.Staff) local str = staff:CreateFullNameString() @@ -472,7 +458,6 @@ function staff_rename() table.insert(autonumber_style, staff.AutoNumberingStyle) ::done:: end - function dialog(title) local row_h = 20 local row_count = 1 @@ -524,7 +509,6 @@ function staff_rename() ctrl:SetText(str) return ctrl end - local autonumber_style_list = {"Instrument 1, 2, 3", "Instrument I, II, II", "1st, 2nd, 3rd Instrument", "Instrument A, B, C", "1., 2., 3. Instrument"} local auto_x_width = 40 @@ -576,10 +560,8 @@ function staff_rename() str.LuaString = forms[i] form_select:AddString(str) end - local doc_fonts_check = add_ctrl(dialog, "checkbox", "Use Document Fonts", col[2], row[row_count + 3], row_h, col_w, 0, 0) doc_fonts_check:SetCheck(config.use_doc_fonts) - local hardcode_autonumber_btn = add_ctrl(dialog, "button", "Hardcode Autonumbers", col[3] + auto_x_width, row[row_count + 3], row_h, col_w, 0, 0) dialog:CreateOkButton() @@ -640,7 +622,6 @@ function staff_rename() end end - function callback(ctrl) if ctrl:GetControlID() == form_select:GetControlID() then local form = form_select:GetSelectedItem() @@ -653,13 +634,11 @@ function staff_rename() search = form_0_names replace = form_1_names end - for a,b in pairs(search) do search[a] = string.gsub(search[a], "%[", "%%[") search[a] = string.gsub(search[a], "%]", "%%]") replace[a] = string.gsub(replace[a], "%%", "") end - for i,j in pairs(fullnames) do edit_fullname[i]:GetText(str) for k,l in pairs(search) do @@ -674,7 +653,6 @@ function staff_rename() edit_abbname[i]:SetText(str) end end - for i, j in pairs(edit_fullname) do if ctrl:GetControlID() == copy_button[i]:GetControlID() then edit_fullname[i]:GetText(str) @@ -693,7 +671,6 @@ function staff_rename() master_autonumber_popup:SetSelectedItem(5) end end - if ctrl:GetControlID() == copy_all:GetControlID() then for i,j in pairs(edit_fullname) do edit_fullname[i]:GetText(str) @@ -723,9 +700,7 @@ function staff_rename() hardcode_autonumbers() end end - dialog:RegisterHandleCommand(callback) - if dialog:ExecuteModal(nil) == finale.EXECMODAL_OK then config.use_doc_fonts = doc_fonts_check:GetCheck() configuration.save_user_settings(script_name, config) @@ -798,5 +773,4 @@ function staff_rename() end dialog("Rename Staves") end - staff_rename() diff --git a/dist/staff_split_layers.lua b/dist/staff_split_layers.lua index 6b309235..717b0cfb 100644 --- a/dist/staff_split_layers.lua +++ b/dist/staff_split_layers.lua @@ -307,7 +307,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -340,7 +339,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -356,7 +354,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -395,12 +392,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end package.preload["mixin.FCMControl"] = package.preload["mixin.FCMControl"] or function() @@ -4478,12 +4472,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4494,7 +4485,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4508,7 +4498,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4516,21 +4505,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4544,7 +4529,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4555,38 +4539,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4596,18 +4571,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4619,33 +4590,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4654,16 +4618,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4674,49 +4634,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4725,7 +4673,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4736,7 +4683,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4745,7 +4691,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4764,7 +4709,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4782,7 +4726,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4800,10 +4743,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4816,11 +4757,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4830,7 +4769,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4844,7 +4782,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4852,13 +4789,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4868,113 +4803,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4983,171 +4892,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5183,7 +5050,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/ties_remove_dangling.lua b/dist/ties_remove_dangling.lua index c6c00cea..9c1e13de 100644 --- a/dist/ties_remove_dangling.lua +++ b/dist/ties_remove_dangling.lua @@ -306,10 +306,8 @@ end package.preload["library.tie"] = package.preload["library.tie"] or function() local tie = {} - local note_entry = require('library.note_entry') - local equal_note = function(entry, target_note, for_tied_to, tie_must_exist) local found_note = entry:FindPitch(target_note) if not found_note or not tie_must_exist then @@ -327,7 +325,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return nil end - function tie.calc_tied_to(note, tie_must_exist) if not note then return nil @@ -356,7 +353,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return nil end - function tie.calc_tied_from(note, tie_must_exist) if not note then return nil @@ -374,7 +370,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end - function tie.calc_tie_span(note, for_tied_to, tie_must_exist) local start_measnum = (for_tied_to and note.Entry.Measure > 1) and note.Entry.Measure - 1 or note.Entry.Measure local end_measnum = for_tied_to and note.Entry.Measure or note.Entry.Measure + 1 @@ -396,7 +391,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return note_entry_layer, start_note, end_note end - function tie.calc_default_direction(note, for_tieend, tie_prefs) if for_tieend then if not note.TieBackwards then @@ -417,16 +411,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() - if note.NoteIndex == 0 then return finale.TIEMODDIR_UNDER end if note.NoteIndex == note.Entry.Count - 1 then return finale.TIEMODDIR_OVER end - local inner_default = 0 - if tie_prefs.ChordDirectionType ~= finale.TIECHORDDIR_STEMREVERSAL then if note.NoteIndex < math.floor(note.Entry.Count / 2) then inner_default = finale.TIEMODDIR_UNDER @@ -500,17 +491,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end end - return (stemdir > 0) and finale.TIEMODDIR_UNDER or finale.TIEMODDIR_OVER - end - local calc_layer_is_visible = function(staff, layer_number) local altnotation_layer = staff.AltNotationLayer if layer_number ~= altnotation_layer then return staff.AltShowOtherNotes end - local hider_altnotation_types = { finale.ALTSTAFF_BLANKNOTATION, finale.ALTSTAFF_SLASHBEATS, finale.ALTSTAFF_ONEBARREPEAT, finale.ALTSTAFF_TWOBARREPEAT, finale.ALTSTAFF_BLANKNOTATIONRESTS, } @@ -520,10 +507,8 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return false end end - return true end - local calc_other_layers_visible = function(entry) local staff = finale.FCCurrentStaffSpec() staff:LoadForEntry(entry) @@ -544,7 +529,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return false end - local layer_stem_direction = function(layer_prefs, entry) if layer_prefs.UseFreezeStemsTies then if layer_prefs.UseRestOffsetInMultiple then @@ -559,7 +543,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return 0 end - local layer_tie_direction = function(entry) local layer_prefs = finale.FCLayerPrefs() if not layer_prefs:Load(entry.LayerNumber - 1) then @@ -572,7 +555,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return 0 end - function tie.calc_direction(note, tie_mod, tie_prefs) @@ -592,10 +574,8 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() if note.Entry.FlipTie then return note.Entry:CalcStemUp() and finale.TIEMODDIR_OVER or finale.TIEMODDIR_UNDER end - return tie.calc_default_direction(note, not tie_mod:IsStartTie(), tie_prefs) end - local calc_is_end_of_system = function(note, for_pageview) if not note.Entry:Next() then local region = finale.FCMusicRegion() @@ -616,7 +596,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return false end - local has_nonaligned_2nd = function(entry) for note in each(entry) do if note:IsNonAligned2nd() then @@ -626,7 +605,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return false end - function tie.calc_connection_code(note, placement, direction, for_endpoint, for_tieend, for_pageview, tie_prefs) @@ -677,7 +655,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return finale.TIEMODCNCT_NONE end - local calc_placement_for_endpoint = function(note, tie_mod, tie_prefs, direction, stemdir, for_endpoint, end_note_slot, end_num_notes, end_upstem2nd, end_downstem2nd) local note_slot = end_note_slot and end_note_slot or note.NoteIndex local num_notes = end_num_notes and end_num_notes or note.Entry.Count @@ -722,7 +699,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return direction == finale.TIEMODDIR_UNDER and finale.TIEPLACE_UNDERINNER or finale.TIEPLACE_OVERINNER end - function tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -798,16 +774,13 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end end - if start_placement == finale.TIEPLACE_OVERINNER or start_placement == finale.TIEPLACE_UNDERINNER then end_placement = start_placement elseif end_placement == finale.TIEPLACE_OVERINNER or end_placement == finale.TIEPLACE_UNDERINNER then start_placement = end_placement end - return start_placement, end_placement end - local calc_prefs_offset_for_endpoint = function(note, tie_prefs, tie_placement_prefs, placement, for_endpoint, for_tieend, for_pageview) local tie_ if for_endpoint then @@ -821,7 +794,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return tie_placement_prefs:GetHorizontalStart(placement), tie_placement_prefs:GetVerticalStart(placement) end - local activate_endpoint = function(note, tie_mod, placement, direction, for_endpoint, for_pageview, tie_prefs, tie_placement_prefs) local active_check_func = for_endpoint and tie_mod.IsEndPointActive or tie_mod.IsStartPointActive if active_check_func(tie_mod) then @@ -835,7 +807,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return true end - function tie.activate_endpoints(note, tie_mod, for_pageview, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -851,13 +822,11 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return lactivated or ractivated end - local calc_tie_length = function(note, tie_mod, for_pageview, direction, tie_prefs, tie_placement_prefs) local cell_metrics_start = finale.FCCellMetrics() local entry_metrics_start = finale.FCEntryMetrics() cell_metrics_start:LoadAtEntry(note.Entry) entry_metrics_start:Load(note.Entry) - local cell_metrics_end = finale.FCCellMetrics() local entry_metrics_end = finale.FCEntryMetrics() local note_entry_layer, start_note, end_note = tie.calc_tie_span(note, false, true) @@ -867,20 +836,16 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() entry_metrics_end:Load(end_note.Entry) end end - local lplacement, rplacement = tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) local horz_start = 0 local horz_end = 0 local incr_start = 0 local incr_end = 0 - local OUTER_NOTE_OFFSET_PCTG = 7.0 / 16.0 local INNER_INCREMENT = 6 - local staff_scaling = cell_metrics_start.StaffScaling / 10000.0 local horz_stretch = for_pageview and 1 or cell_metrics_start.HorizontalStretch / 10000.0 - if tie_mod:IsStartTie() then horz_start = entry_metrics_start:GetNoteLeftPosition(note.NoteIndex) / horz_stretch if lplacement == finale.TIEPLACE_OVERINNER or lplacement == finale.TIEPLACE_OVEROUTERSTEM or lplacement == finale.TIEPLACE_UNDERINNER then @@ -892,7 +857,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() else horz_start = (cell_metrics_start.MusicStartPos * staff_scaling) / horz_stretch end - if tie_mod:IsStartTie() and (not end_note or cell_metrics_start.StaffSystem ~= cell_metrics_end.StaffSystem) then local next_cell_metrics = finale.FCCellMetrics() local next_metrics_loaded = next_cell_metrics:LoadAtCell(finale.FCCell(note.Entry.Measure + 1, note.Entry.Staff)) @@ -921,7 +885,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() horz_end = horz_end + (entry_metrics_start:GetNoteWidth(note.NoteIndex) * (1.0 - OUTER_NOTE_OFFSET_PCTG)) end end - local start_offset = tie_mod.StartHorizontalPos if not tie_mod:IsStartPointActive() then start_offset = calc_prefs_offset_for_endpoint(note, tie_prefs, tie_placement_prefs, lplacement, false, not tie_mod:IsStartTie(), for_pageview) @@ -930,7 +893,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() if not tie_mod:IsEndPointActive() then end_offset = calc_prefs_offset_for_endpoint(note, tie_prefs, tie_placement_prefs, lplacement, true, not tie_mod:IsStartTie(), for_pageview) end - local tie_length = horz_end - horz_start tie_length = tie_length / staff_scaling @@ -938,7 +900,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return math.floor(tie_length + 0.5) end - function tie.calc_contour_index(note, tie_mod, for_pageview, direction, tie_prefs) if not tie_prefs then tie_prefs = finale.FCTiePrefs() @@ -958,7 +919,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() end return finale.TCONTOURIDX_MEDIUM, tie_length end - local calc_inset_and_height = function(tie_prefs, tie_contour_prefs, length, contour_index, get_fixed_func, get_relative_func, get_height_func) @@ -990,7 +950,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() return inset, height end - function tie.activate_contour(note, tie_mod, for_pageview, tie_prefs) if tie_mod:IsContourActive() then return false @@ -1011,7 +970,6 @@ package.preload["library.tie"] = package.preload["library.tie"] or function() tie_mod:ActivateContour(left_inset, left_height, right_inset, right_height, tie_prefs.FixedInsetStyle) return true end - return tie end function plugindef() @@ -1022,15 +980,13 @@ function plugindef() finaleplugin.Version = "1.0.1" finaleplugin.Date = "2022-08-26" finaleplugin.RequireSelection = true - finaleplugin.AuthorEmail = "jacob.winkler@mac.com" finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/ties_remove_dangling.hash" + finaleplugin.AuthorEmail = "jacob.winkler@mac.com" + finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/ties_remove_dangling.hash" return "Ties: Remove Dangling", "Ties: Remove Dangling", "Removes dangling ties (ties that go nowhere)." end - local tie = require("library.tie") - local music_region = finale.FCMusicRegion() music_region:SetCurrentSelection() - for working_staff = music_region:GetStartStaff(), music_region:GetEndStaff() do for layer_num = 0, 3, 1 do local current_note diff --git a/dist/transpose_by_step.lua b/dist/transpose_by_step.lua index 585a6add..0510d5d4 100644 --- a/dist/transpose_by_step.lua +++ b/dist/transpose_by_step.lua @@ -4437,12 +4437,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4453,7 +4450,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4467,7 +4463,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4475,21 +4470,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4503,7 +4494,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4514,38 +4504,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4555,18 +4536,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4578,33 +4555,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4613,16 +4583,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4633,49 +4599,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4684,7 +4638,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4695,7 +4648,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4704,7 +4656,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4723,7 +4674,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4741,7 +4691,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4759,10 +4708,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4775,11 +4722,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4789,7 +4734,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4803,7 +4747,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4811,13 +4754,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4827,113 +4768,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4942,171 +4857,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5142,7 +5015,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/transpose_chromatic.lua b/dist/transpose_chromatic.lua index de1f4cc3..8e45d0a1 100644 --- a/dist/transpose_chromatic.lua +++ b/dist/transpose_chromatic.lua @@ -4742,12 +4742,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4758,7 +4755,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4772,7 +4768,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4780,21 +4775,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4808,7 +4799,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4819,38 +4809,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4860,18 +4841,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4883,33 +4860,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4918,16 +4888,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4938,49 +4904,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4989,7 +4943,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -5000,7 +4953,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -5009,7 +4961,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -5028,7 +4979,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -5046,7 +4996,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -5064,10 +5013,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -5080,11 +5027,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -5094,7 +5039,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -5108,7 +5052,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -5116,13 +5059,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -5132,113 +5073,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -5247,171 +5162,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -5447,7 +5320,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end function plugindef() diff --git a/dist/tuplet_state.lua b/dist/tuplet_state.lua index 174e169b..4118eed7 100644 --- a/dist/tuplet_state.lua +++ b/dist/tuplet_state.lua @@ -4210,12 +4210,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( - - local utils = require("library.utils") local library = require("library.general_library") - local mixin_public = {} local mixin_private = {} @@ -4226,7 +4223,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( local mixin_props = setmetatable({}, {__mode = "k"}) - local reserved_props = { MixinReady = function(class_name) return true end, MixinClass = function(class_name) return class_name end, @@ -4240,7 +4236,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( __disabled = function(class_name) return mixin_classes[class_name].Disabled and utils.copy_table(mixin_classes[class_name].Disabled) or {} end, } - local instance_reserved_props = { MixinReady = true, MixinClass = true, @@ -4248,21 +4243,17 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( MixinBase = true, } - local mixin = setmetatable({}, { __newindex = function(t, k, v) end, __index = function(t, k) if mixin_public[k] then return mixin_public[k] end - mixin_private.load_mixin_class(k) if not mixin_classes[k] then return nil end - mixin_public[k] = setmetatable({}, { __newindex = function(tt, kk, vv) end, __index = function(tt, kk) local value - if mixin_lookup[k].Methods[kk] then value = mixin_private.create_fluid_proxy(mixin_lookup[k].Methods[kk]) elseif mixin_classes[k].StaticMethods and mixin_classes[k].StaticMethods[kk] then @@ -4276,7 +4267,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( elseif reserved_props[kk] then value = reserved_props[kk](k) end - return value end, __call = function(_, ...) @@ -4287,38 +4277,29 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end }) - return mixin_public[k] end }) - function mixin_private.is_fc_class_name(class_name) return type(class_name) == "string" and not mixin_private.is_fcm_class_name(class_name) and not mixin_private.is_fcx_class_name(class_name) and (class_name:match("^FC%u") or class_name:match("^__FC%u")) and true or false end - function mixin_private.is_fcm_class_name(class_name) return type(class_name) == "string" and (class_name:match("^FCM%u") or class_name:match("^__FCM%u")) and true or false end - function mixin_private.is_fcx_class_name(class_name) return type(class_name) == "string" and class_name:match("^FCX%u") and true or false end - function mixin_private.fcm_to_fc_class_name(class_name) return string.gsub(class_name, "FCM", "FC", 1) end - function mixin_private.fc_to_fcm_class_name(class_name) return string.gsub(class_name, "FC", "FCM", 1) end - function mixin_private.assert_valid_property_name(name, error_level, suffix) if type(name) ~= "string" then error("Mixin method and property names must be strings" .. suffix, error_level) end - suffix = suffix or "" - if name:sub(-2) == "__" then error("Mixin methods and properties cannot end in a double underscore" .. suffix, error_level) elseif name:sub(1, 5):lower() == "mixin" then @@ -4328,18 +4309,14 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - function mixin_private.try_load_module(name) local success, result = pcall(function(c) return require(c) end, name) - if not success and not result:match("module '[^']-' not found") then error(result, 0) end - return success, result end - local find_ancestor_with_prop find_ancestor_with_prop = function(class, attr, prop) if class[attr] and class[attr][prop] then @@ -4351,33 +4328,26 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return find_ancestor_with_prop(mixin_classes[class.Parent], attr, prop) end - function mixin_private.load_mixin_class(class_name, create_lookup) if mixin_classes[class_name] then return end - local is_fcm = mixin_private.is_fcm_class_name(class_name) - if not is_fcm and not mixin_private.is_fcx_class_name(class_name) then return end - local is_personal_mixin = false local success local result - if finenv.TrustedMode == nil or finenv.TrustedMode == finenv.TrustedModeType.USER_TRUSTED then success, result = mixin_private.try_load_module("personal_mixin." .. class_name) end - if success then is_personal_mixin = true else success, result = mixin_private.try_load_module("mixin." .. class_name) end - if not success then if is_fcm and finale[mixin_private.fcm_to_fc_class_name(class_name)] then @@ -4386,16 +4356,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return end end - local error_prefix = (is_personal_mixin and "personal_" or "") .. "mixin." .. class_name - if type(result) ~= "table" then error("Mixin '" .. error_prefix .. "' is not a table.", 0) end - local class = {Class = class_name} - local function has_attr(attr, attr_type) if result[attr] == nil then return false @@ -4406,49 +4372,37 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return true end - has_attr("Parent", "string") - if is_fcm then class.Parent = library.get_parent_class(mixin_private.fcm_to_fc_class_name(class_name)) - if class.Parent then class.Parent = mixin_private.fc_to_fcm_class_name(class.Parent) - mixin_private.load_mixin_class(class.Parent) end - else if not result.Parent then error("Mixin '" .. error_prefix .. "' does not have a parent class defined.", 0) end - if not mixin_private.is_fcm_class_name(result.Parent) and not mixin_private.is_fcx_class_name(result.Parent) then error("Mixin parent must be an FCM or FCX class name, '" .. result.Parent .. "' given (" .. error_prefix .. ".Parent)", 0) end - mixin_private.load_mixin_class(result.Parent) - if not mixin_classes[result.Parent] then error("Unable to load mixin '" .. result.Parent .. "' as parent of '" .. error_prefix .. "'", 0) end - class.Parent = result.Parent - class.Base = mixin_classes[result.Parent].Base or result.Parent end - local lookup = class.Parent and utils.copy_table(mixin_lookup[class.Parent]) or {Methods = {}, Properties = {}, Disabled = {}, FCMInits = {}} - if has_attr("Init", "function") and is_fcm then table.insert(lookup.FCMInits, result.Init) end @@ -4457,7 +4411,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.FCMInits = nil end - if has_attr("Disabled", "table") then class.Disabled = {} for _, v in pairs(result.Disabled) do @@ -4468,7 +4421,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Properties[v] = nil end end - local function find_property_name_clash(name, attr_to_check) for _, attr in pairs(attr_to_check) do if attr == "StaticMethods" or (lookup[attr] and lookup[attr][nane]) then @@ -4477,7 +4429,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - if has_attr("Methods", "table") then class.Methods = {} for k, v in pairs(result.Methods) do @@ -4496,7 +4447,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( lookup.Methods[k] = v end end - if has_attr("StaticMethods", "table") then class.StaticMethods = {} for k, v in pairs(result.StaticMethods) do @@ -4514,7 +4464,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( class.Methods[k] = v end end - if has_attr("Properties", "table") then class.Properties = {} for k, v in pairs(result.Properties) do @@ -4532,10 +4481,8 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( if not v.Get and not v.Set then error("A mixin property descriptor must have at least a 'Get' or 'Set' attribute (" .. error_prefix .. ".Properties." .. k .. ")", 0) end - class.Properties[k] = {} lookup.Properties[k] = lookup.Properties[k] or {} - for kk, vv in pairs(v) do if kk ~= "Get" and kk ~= "Set" then error("A mixin property descriptor can only have 'Get' and 'Set' attributes (" .. error_prefix .. ".Properties." .. k .. ")", 0) @@ -4548,11 +4495,9 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - mixin_lookup[class_name] = lookup mixin_classes[class_name] = class end - function mixin_private.create_method_reflection(class_name, attr) local t = {} if mixin_classes[class_name][attr] then @@ -4562,7 +4507,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end return t end - function mixin_private.create_property_reflection(class_name, attr) local t = {} if mixin_classes[class_name].Properties then @@ -4576,7 +4520,6 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end - local function fluid_proxy(t, ...) local n = select("#", ...) @@ -4584,13 +4527,11 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return t end - for i = 1, n do mixin_private.enable_mixin(select(i, ...)) end return ... end - local function proxy(t, ...) local n = select("#", ...) @@ -4600,113 +4541,87 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( return ... end - function mixin_private.create_fluid_proxy(func) return function(t, ...) return fluid_proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - function mixin_private.create_proxy(func) return function(t, ...) return proxy(t, utils.call_and_rethrow(2, func, t, ...)) end end - - function mixin_private.enable_mixin(object, fcm_class_name) if mixin_props[object] or not library.is_finale_object(object) then return object end - mixin_private.apply_mixin_foundation(object) fcm_class_name = fcm_class_name or mixin_private.fc_to_fcm_class_name(library.get_class_name(object)) - mixin_private.load_mixin_class(fcm_class_name) mixin_props[object] = {MixinClass = fcm_class_name} - for _, v in ipairs(mixin_lookup[fcm_class_name].FCMInits) do v(object) end - return object end - function mixin_private.apply_mixin_foundation(object) if object.MixinReady then return end - local meta = getmetatable(object) - local original_index = meta.__index local original_newindex = meta.__newindex - meta.__index = function(t, k) if k == "MixinReady" then return true end - if not mixin_props[t] then return original_index(t, k) end - local class = mixin_props[t].MixinClass local prop - if type(k) == "string" and k:sub(-2) == "__" then prop = original_index(t, k:sub(1, -3)) - elseif mixin_lookup[class].Properties[k] and mixin_lookup[class].Properties[k].Get then prop = utils.call_and_rethrow(2, mixin_lookup[class].Properties[k].Get, t) - elseif mixin_props[t][k] ~= nil then prop = utils.copy_table(mixin_props[t][k]) - elseif mixin_lookup[class].Methods[k] then prop = mixin_lookup[class].Methods[k] - elseif instance_reserved_props[k] then prop = reserved_props[k](class) - else prop = original_index(t, k) end - if type(prop) == "function" then return mixin_private.create_fluid_proxy(prop) end - return prop end - meta.__newindex = function(t, k, v) if not mixin_props[t] then return original_newindex(t, k, v) end - local class = mixin_props[t].MixinClass - if mixin_lookup[class].Disabled[k] or reserved_props[k] then error("No writable member '" .. tostring(k) .. "'", 2) end - if mixin_lookup[class].Properties[k] then if mixin_lookup[class].Properties[k].Set then return mixin_lookup[class].Properties[k].Set(t, v) @@ -4715,171 +4630,129 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end - if type(k) ~= "string" then mixin_props[t][k] = v return end - if k:sub(-2) == "__" then k = k:sub(1, -3) return original_newindex(t, k, v) end - mixin_private.assert_valid_property_name(k, 3) - local type_v_original = type(original_index(t, k)) local type_v = type(v) local is_mixin_method = mixin_lookup[class].Methods[k] and true or false - if type_v_original == "nil" then - if is_mixin_method and not (type_v == "function" or type_v == "nil") then error("A mixin method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return - elseif type_v_original == "function" then if not (type_v == "function" or type_v == "nil") then error("A Finale PDK method cannot be overridden with a property.", 2) end - mixin_props[t][k] = v return end - return original_newindex(t, k, v) end end - function mixin_private.subclass(object, class_name) if not library.is_finale_object(object) then error("Object is not a finale object.", 2) end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name) then error(class_name .. " is not a subclass of " .. object.MixinClass, 2) end - return object end - function mixin_private.subclass_helper(object, class_name, suppress_errors) if not object.MixinClass then if suppress_errors then return false end - error("Object is not mixin-enabled.", 2) end - if not mixin_private.is_fcx_class_name(class_name) then if suppress_errors then return false end - error("Mixins can only be subclassed with an FCX class.", 2) end - if object.MixinClass == class_name then return true end - mixin_private.load_mixin_class(class_name) - if not mixin_classes[class_name] then if suppress_errors then return false end - error("Mixin '" .. class_name .. "' not found.", 2) end - if mixin_private.is_fcm_class_name(mixin_classes[class_name].Parent) and mixin_classes[class_name].Parent ~= object.MixinClass then return false end - if mixin_classes[class_name].Parent ~= object.MixinClass then if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, mixin_classes[class_name].Parent) then return false end end - mixin_props[object].MixinClass = class_name - if mixin_classes[class_name].Disabled then for k, _ in pairs(mixin_classes[class_name].Disabled) do mixin_props[object][k] = nil end end - if mixin_classes[class_name].Init then utils.call_and_rethrow(2, mixin_classes[class_name].Init, object) end - return true end - function mixin_private.create_fcm(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - return mixin_private.enable_mixin(utils.call_and_rethrow(2, finale[mixin_private.fcm_to_fc_class_name(class_name)], ...)) end - function mixin_private.create_fcx(class_name, ...) mixin_private.load_mixin_class(class_name) if not mixin_classes[class_name] then return nil end - local object = mixin_private.create_fcm(mixin_classes[class_name].Base, ...) - if not object then return nil end - if not utils.call_and_rethrow(2, mixin_private.subclass_helper, object, class_name, false) then return nil end - return object end - mixin_public.is_fc_class_name = mixin_private.is_fc_class_name - mixin_public.is_fcm_class_name = mixin_private.is_fcm_class_name - mixin_public.is_fcx_class_name = mixin_private.is_fcx_class_name - mixin_public.fc_to_fcm_class_name = mixin_private.fc_to_fcm_class_name - mixin_public.fcm_to_fc_class_name = mixin_private.fcm_to_fc_class_name - mixin_public.subclass = mixin_private.subclass - function mixin_public.UI() return mixin_private.enable_mixin(finenv.UI(), "FCMUI") end - function mixin_public.eachentry(region, layer) local measure = region.StartMeasure local slotno = region:GetStartSlot() @@ -4915,14 +4788,12 @@ package.preload["library.mixin"] = package.preload["library.mixin"] or function( end end end - return mixin end package.preload["library.layer"] = package.preload["library.layer"] or function() local layer = {} - function layer.copy(region, source_layer, destination_layer, clone_articulations) local start = region.StartMeasure local stop = region.EndMeasure @@ -4955,7 +4826,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.clear(region, layer_to_clear) layer_to_clear = layer_to_clear - 1 local start = region.StartMeasure @@ -4971,7 +4841,6 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - function layer.swap(region, swap_a, swap_b) swap_a = swap_a - 1 @@ -5010,12 +4879,9 @@ package.preload["library.layer"] = package.preload["library.layer"] or function( end end - - function layer.max_layers() return finale.FCLayerPrefs.GetMaxLayers and finale.FCLayerPrefs.GetMaxLayers() or 4 end - return layer end function plugindef() diff --git a/docs/library/clef.md b/docs/library/clef.md index ba99295b..11b9ddc3 100644 --- a/docs/library/clef.md +++ b/docs/library/clef.md @@ -1,5 +1,5 @@ # Clef - + A library of general clef utility functions. ## Functions @@ -19,9 +19,7 @@ clef.get_cell_clef(measure, staff_number) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/clef.lua#L46) - -Gets the clef for any cell. - +Gets the clef for any cell. | Input | Type | Description | | ----- | ---- | ----------- | @@ -40,9 +38,7 @@ clef.get_default_clef(first_measure, last_measure, staff_number) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/clef.lua#L73) - -Gets the default clef for any staff for a specific region. - +Gets the default clef for any staff for a specific region. | Input | Type | Description | | ----- | ---- | ----------- | @@ -62,9 +58,7 @@ clef.set_measure_clef(first_measure, last_measure, staff_number, clef_index) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/clef.lua#L95) - -Sets the clefs of of a range measures. - +Sets the clefs of of a range measures. | Input | Type | Description | | ----- | ---- | ----------- | @@ -81,9 +75,7 @@ clef.restore_default_clef(first_measure, last_measure, staff_number) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/clef.lua#L125) - -Restores the default clef for any staff for a specific region. - +Restores the default clef for any staff for a specific region. | Input | Type | Description | | ----- | ---- | ----------- | @@ -99,10 +91,9 @@ clef.process_clefs(mid_clefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/clef.lua#L159) - -Processes a table of clef changes and returns them in order, without duplicates. - -:(FCCellClefChanges) +Processes a table of clef changes and returns them in order, without duplicates. + +:(FCCellClefChanges) | Input | Type | Description | | ----- | ---- | ----------- | @@ -116,10 +107,9 @@ clef.clef_change(clef) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/clef.lua#L199) - -Inserts a clef change in the selected region. - -@ region FCMusicRegion The region to change. +Inserts a clef change in the selected region. + +@ region FCMusicRegion The region to change. | Input | Type | Description | | ----- | ---- | ----------- | diff --git a/docs/library/layer.md b/docs/library/layer.md index 55a2781c..c09e91ca 100644 --- a/docs/library/layer.md +++ b/docs/library/layer.md @@ -15,9 +15,7 @@ layer.copy(region, source_layer, destination_layer, clone_articulations) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/layer.lua#L16) - -Duplicates the notes from the source layer to the destination. The source layer remains untouched. - +Duplicates the notes from the source layer to the destination. The source layer remains untouched. | Input | Type | Description | | ----- | ---- | ----------- | @@ -34,9 +32,7 @@ layer.clear(region, layer_to_clear) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/layer.lua#L56) - -Clears all entries from a given layer. - +Clears all entries from a given layer. | Input | Type | Description | | ----- | ---- | ----------- | @@ -51,9 +47,7 @@ layer.swap(region, swap_a, swap_b) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/layer.lua#L80) - -Swaps the entries from two different layers (e.g. 1-->2 and 2-->1). - +Swaps the entries from two different layers (e.g. 1-->2 and 2-->1). | Input | Type | Description | | ----- | ---- | ----------- | @@ -69,9 +63,7 @@ layer.max_layers() [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/layer.lua#L126) - -Return the maximum number of layers available in the current document. - +Return the maximum number of layers available in the current document. | Return type | Description | | ----------- | ----------- | diff --git a/docs/library/mixin.md b/docs/library/mixin.md index d806ec7d..bd736433 100644 --- a/docs/library/mixin.md +++ b/docs/library/mixin.md @@ -1,283 +1,277 @@ # Mixin - -The Mixin library enables Finale objects to be modified with additional methods and properties to simplify the process of writing plugins. It provides two methods of formally defining mixins: `FCM` and `FCX` mixins. As an added convenience, the library also automatically applies a fluid interface to mixin methods where possible. - -## The `mixin` Namespace -Mixin-enabled objects can be created from the `mixin` namespace, which functions in the same way as the `finale` namespace. To create a mixin-enabled version of a Finale object, simply add an `M` to the class name after the `FC` and call it from the `mixin` namespace. -```lua --- Include the mixin namespace as well as any helper functions -local mixin = require("library.mixin") - --- Create mixin-enabled FCString -local str = mixin.FCMString() - --- Create mixin-enabled FCCustomLuaWindow -local dialog = mixin.FCMCustomLuaWindow() -``` - -## Adding Methods or Properties to Finale Objects -The mixin library allows methods and properties to be added to Finale objects in two ways: - -1) Predefined `FCM` or `FCX` mixins which can be accessed from the `mixin` namespace or returned from other mixin methods. For example: -```lua -local mixin = require("library.mixin") - --- Loads a mixin-enabled FCCustomLuaWindow object and applies any methods or properties from the FCMCustomLuaWindow mixin and its parents -local dialog = mixin.FCMCustomLuaWindow() - --- Creates an FCMCustomLuaWindow object and applies the FCXMyCustomDialog mixin, along with any parent mixins -local mycustomdialog = mixin.FCXMyCustomDialog() -``` -*For more information about `FCM` and `FCX` mixins, see the next section and the mixin templates further down the page* - -2) Setting them on an object in the same way as a table. For example: - -```lua -local mixin = require("library.mixin") -local str = mixin.FCMString() - --- Add a new property -str.MyCustomProperty = "Hello World" - --- Add a new method -function str:AlertMyCustomProperty() - finenv.UI():AlertInfo(self.MyCustomProperty, "My Custom Property") -end - --- Execute the new method -str:AlertMyCustomProperty() -``` - -Regardless of which approach is used, the following principles apply: -- New methods can be added or existing methods can be overridden. -- New properties can be added but existing properties from the underlying `FC` object retain their original behaviour (ie if they are writable or read-only, and what types they can be). -- The original `FC` method can always be accessed by appending a trailing underscore to the method name (eg `control:GetWidth_()`). -- In keeping with the above, method and property names cannot end in an underscore. Setting a method or property name ending with an underscore will trigger an error. -- Methods or properties beginning with `Mixin` are reserved for internal use and cannot be set. -- The constructor cannot be overridden or changed in any way. - - -## `FCM` and `FCX` Mixins & Class Hierarchy - -### `FCM` Mixins -`FCM` mixins are modified `FC` classes. The name of each `FCM` mixin corresponds to the `FC` class that it extends. For example `__FCBase` -> `__FCMBase`, `FCControl` -> `FCMControl`, `FCCustomLuaWindow` -> `FCMCustomLuaWindow`, etc etc - -`FCM` mixins are mainly intended to enhance core functionality, by fixing bugs, expanding method signatures (eg allowing a method to accept a regular Lua string instead of an `FCString`) and providing additional convenience methods to simplify the process of writing plugins. - -To maximise compatibility and to simplify migration, `FCM` mixins retain as much backwards compatibility as possible with standard code using `FC` classes, but there may be a very small number of breaking changes. These will be marked in the documentation. - -*Note that `FCM` mixins are optional. If an `FCM` mixin does not exist in the `mixin` folder, a mixin-enabled Finale object will still be created (ie able to be modified and with a fluid interface). It just won't have any new or overridden methods.* - -### `FCX` Mixins -`FCX` mixins are customised `FC` objects. With no restrictions and no requirement for backwards compatibility, `FCX` mixins are intended to create highly specialised functionality that is built off an existing `FCM` object. - -The name of an `FCX` mixin can be anythng, as long as it begins with `FCX` followed by an uppercase letter. - -### Mixin Class Hierarchy -With mixins, the new inheritance tree looks like this: - -``` - ________ - / \ - __FCBase | __FCMBase - | | | - V | V - FCControl | FCMControl - | | | - V | V -FCCtrlEdit | FCMCtrlEdit - | | | - \_______/ --- - | - V - FCXCtrlMeasurementEdit -``` - -`FCM` mixins share a parellel heirarchy with the `FC` classes, but as they are applied on top of an existing `FC` object, they come afterwards in the tree. `FCX` mixins are applied on top of `FCM` classes and any subsequent `FCX` mixins continue the tree in a linear a fashion downwards. - -### Special Properties -The `mixin` library adds several read-only properties to mixin-enabled Finale objects. These are: -- **`MixinClass`** *`[string]`* - The mixin class name. -- **`MixinParent`** *`[?string]`* - The name of the parent mixin (for `__FCMBase` this will be `nil`). -- **`MixinBase`** *`[?string]`* - *FCX only.* The class name of the underlying `FCM` object on which it is based. -- **`Init`** *`[?function]`* - *Optional.* The mixin's `Init` meta-method or `nil` if it doesn't have one. As this is intended to be called internally, it is only available statically via the `mixin` namespace. -- **`MixinReady`** *`[true]`* - *Internal.* A flag for determining which `FC` classes have had their metatatables modified. - - -## Automatic Mixin Enabling -All `FC` objects that are returned from mixin methods are automatically upgraded to a mixin-enabled `FCM` object. This includes objects returned from methods inherited from the underlying `FC` object. - - -## Accessing Mixin Methods Statically -All methods from `FCM` and `FCX` mixins can be accessed statically through the `mixin` namespace. -```lua -local mixin = require("library.mixin") -local str = mixin.FCXString() - --- Standard instance method call -str:SetLuaString("hello world") - --- Accessing an instance method statically -mixin.FCXString.PrintString(str, "goodbye world") - --- Accessing a static method -mixin.FCXString.PrintHelloWorld() -``` - - -## Fluid Interface (aka Method Chaining) -Any method on a mixin-enabled Finale object that returns zero values (returning `nil` still counts as a value) will have a fluid interface automatically applied by the library. This means that instead of returning nothing, the method will return `self`. - -For example, this was the previous way of creating an edit control: -```lua -local dialog = finale.FCCustomLuaWindow() -dialog:SetWidth(100) -dialog:SetHeight(100) -local edit = dialog:CreateEdit(0, 0) -edit:SetWidth(25) -edit:SetMeasurement(12, finale.MEASUREMENTUNIT_DEFAULT) -``` - -With the fluid interface, the code above can be shortened to this: -```lua -local mixin = require("library.mixin") -local dialog = mixin.FCMCustomLuaWindow():SetWidth(100):SetHeight(100) - -local edit = dialog:CreateEdit(0, 0):SetWidth(25):SetMeasurementInteger(12, finale.MEASUREMENTUNIT_DEFAULT) -``` - -Alternatively, the example above can be respaced in the following way: - -```lua -local mixin = require("library.mixin") -local dialog = mixin.FCMCustomLuaWindow() - :SetWidth(100) - :SetHeight(100) -local edit = dialog:CreateEdit(0, 0) - :SetWidth(25) - :SetMeasurementInteger(12, finale.MEASUREMENTUNIT_DEFAULT) -``` - -## Creating Mixins -General points for creating mixins: -- Place mixins in a Lua file named after the mixin in the `mixin` or `personal_mixin` folder (eg `__FCMBase.lua`, `FCXMyCustomDialog.lua`, etc). There can only be one mixin per file. -- All mixins must return a table with two values (see the templates below for examples): -- - A `meta` table of information about the `mixin` and meta-methods. -- - A `public` table with public properties and methods -- The `Init` meta-method is called after the object has been constructed, so all public methods will be available. -- If you need to guarantee that a method call won't refer to an overridden method, use a static call (eg `mixin.FCMControl.GetText(self)`). - -### `meta` Properties -The `meta` table can contain the following properties and methods: -- **Init** *(optional)* - An initializing method which should accept one argument, `self`. -- **Parent** *(FCX only, required)* - The name of the parent of an `FCX` mixin. If not set or the parent cannot be loaded, an error will be thrown. - -### Creating `FCM` Mixins -Points to remember when creating `FCM` mixins: -- The filename of an `FCM` mixin must correspond exactly to the `FC` class that it extends (ie `__FCBase` -> `__FCMBase.lua`, `FCNote` -> `FCMNote.lua`). Since `FCM` mixins are optional, a misspelled filename will simply result in the mixin not being loaded, without any errors. -- `FCM` mixins can be defined for any class in the PDK, including parent classes that can't be directly accessed (eg `__FCMBase`, `FCControl`). Use these clases if you need to add functionality that will be inherited by all child classes. - -Below is a basic template for creating an `FCM` mixin. Replace the example methods with -```lua --- Include the mixin namespace and helper methods (include any additional libraries below) -local mixin = require("library.mixin") -local mixin_helper = require("library.mixin_helper") - --- Table for storing private data for this mixin -local private = setmetatable({}, {__mode = "k"}) - --- Meta information and public methods and properties -local meta = {} -local public = {} - --- Example initializer (remove this if not needed). -function meta:Init() - -- Create private mixin storage and initialise private properties - private[self] = private[self] or { - ExamplePrivateProperty = "hello world", - } -end - --- Define all methods here (remove/replace examples as needed) - --- Example public instance method (use a colon) -function public:SetExample(value) - -- Ensure argument is the correct type for testing - -- The argument number is 2 because when using a colon in the method signature, it will automatically be passed `self` as the first argument. - mixin_helper.assert_argument_type(2, value, "string") - - private[self].ExamplePrivateProperty = value -end - --- Example public static method (note the use of a dot instead of a colon) -function public.GetMagicNumber() - return 7 -end - --- Return meta information and public methods/properties back to the mixin library -return {meta, public} -``` - -### Creating `FCX` Mixins -Points to remember when creating `FCX` mixins: -- The name of an `FCX` mixin must be in Pascal case (just like the `FC` classes), beginning with `FCX`. For example `FCXMyCustomDialog`, `FCXCtrlMeasurementEdit`, `FCXCtrlPageSizePopup`, etc -- The parent class must be declared, which can be either an `FCM` or `FCX` class. If it is an `FCM` class, it must be a concrete class (ie one that can be instantiated, like `FCMCtrlEdit`) and not an abstract parent class (ie not `FCMControl`). - - -Below is a template for creating an `FCX` mixin. It is almost identical to defining an `FCM` mixin but there are a couple of important differences. -```lua --- Include the mixin namespace and helper methods (include any additional libraries below) -local mixin = require("library.mixin") -local mixin_helper = require("library.mixin_helper") - --- Table for storing private data for this mixin -local private = setmetatable({}, {__mode = "k"}) - --- Meta information and public methods and properties -local meta = {} -local public = {} - --- FCX mixins must declare their parent class (change as needed) -meta.Parent = "FCMString" - --- Example initializer (remove this if not needed). -function meta:Init() - -- Create private mixin storage and initialise private properties - private[self] = private[self] or { - Counter = 0, - } -end - ---- --- Define all methods here (remove/replace examples as needed) ---- - --- Example public instance method (use a colon) -function public:IncrementCounter() - private[self].Counter = private[self].Counter + 1 -end - - --- Example public static method (use a dot) -function public.GetHighestCounter() - local highest = 0 - - for _, v in pairs(private) do - if v.Counter < highest then - highest = v.Counter - end - end - - return highest -end - --- Return meta information and public methods/properties back to the mixin library -return {meta, public} -``` - -## Personal Mixins -If you've written mixins for your personal use and don't want to submit them to the Finale Lua repository, you can place them in a folder called `personal_mixin`, next to the `mixin` folder. - + +The Mixin library enables Finale objects to be modified with additional methods and properties to simplify the process of writing plugins. It provides two methods of formally defining mixins: `FCM` and `FCX` mixins. As an added convenience, the library also automatically applies a fluid interface to mixin methods where possible. + +## The `mixin` Namespace +Mixin-enabled objects can be created from the `mixin` namespace, which functions in the same way as the `finale` namespace. To create a mixin-enabled version of a Finale object, simply add an `M` to the class name after the `FC` and call it from the `mixin` namespace. +```lua +-- Include the mixin namespace as well as any helper functions +local mixin = require("library.mixin") + +-- Create mixin-enabled FCString +local str = mixin.FCMString() + +-- Create mixin-enabled FCCustomLuaWindow +local dialog = mixin.FCMCustomLuaWindow() +``` + +## Adding Methods or Properties to Finale Objects +The mixin library allows methods and properties to be added to Finale objects in two ways: + +1) Predefined `FCM` or `FCX` mixins which can be accessed from the `mixin` namespace or returned from other mixin methods. For example: +```lua +local mixin = require("library.mixin") + +-- Loads a mixin-enabled FCCustomLuaWindow object and applies any methods or properties from the FCMCustomLuaWindow mixin and its parents +local dialog = mixin.FCMCustomLuaWindow() + +-- Creates an FCMCustomLuaWindow object and applies the FCXMyCustomDialog mixin, along with any parent mixins +local mycustomdialog = mixin.FCXMyCustomDialog() +``` +*For more information about `FCM` and `FCX` mixins, see the next section and the mixin templates further down the page* + +2) Setting them on an object in the same way as a table. For example: + +```lua +local mixin = require("library.mixin") +local str = mixin.FCMString() + +-- Add a new property +str.MyCustomProperty = "Hello World" + +-- Add a new method +function str:AlertMyCustomProperty() + finenv.UI():AlertInfo(self.MyCustomProperty, "My Custom Property") +end + +-- Execute the new method +str:AlertMyCustomProperty() +``` + +Regardless of which approach is used, the following principles apply: +- New methods can be added or existing methods can be overridden. +- New properties can be added but existing properties from the underlying `FC` object retain their original behaviour (ie if they are writable or read-only, and what types they can be). +- The original `FC` method can always be accessed by appending a trailing underscore to the method name (eg `control:GetWidth_()`). +- In keeping with the above, method and property names cannot end in an underscore. Setting a method or property name ending with an underscore will trigger an error. +- Methods or properties beginning with `Mixin` are reserved for internal use and cannot be set. +- The constructor cannot be overridden or changed in any way. + +## `FCM` and `FCX` Mixins & Class Hierarchy + +### `FCM` Mixins +`FCM` mixins are modified `FC` classes. The name of each `FCM` mixin corresponds to the `FC` class that it extends. For example `__FCBase` -> `__FCMBase`, `FCControl` -> `FCMControl`, `FCCustomLuaWindow` -> `FCMCustomLuaWindow`, etc etc + +`FCM` mixins are mainly intended to enhance core functionality, by fixing bugs, expanding method signatures (eg allowing a method to accept a regular Lua string instead of an `FCString`) and providing additional convenience methods to simplify the process of writing plugins. + +To maximise compatibility and to simplify migration, `FCM` mixins retain as much backwards compatibility as possible with standard code using `FC` classes, but there may be a very small number of breaking changes. These will be marked in the documentation. + +*Note that `FCM` mixins are optional. If an `FCM` mixin does not exist in the `mixin` folder, a mixin-enabled Finale object will still be created (ie able to be modified and with a fluid interface). It just won't have any new or overridden methods.* + +### `FCX` Mixins +`FCX` mixins are customised `FC` objects. With no restrictions and no requirement for backwards compatibility, `FCX` mixins are intended to create highly specialised functionality that is built off an existing `FCM` object. + +The name of an `FCX` mixin can be anythng, as long as it begins with `FCX` followed by an uppercase letter. + +### Mixin Class Hierarchy +With mixins, the new inheritance tree looks like this: + +``` + ________ + / \ + __FCBase | __FCMBase + | | | + V | V + FCControl | FCMControl + | | | + V | V +FCCtrlEdit | FCMCtrlEdit + | | | + \_______/ --- + | + V + FCXCtrlMeasurementEdit +``` + +`FCM` mixins share a parellel heirarchy with the `FC` classes, but as they are applied on top of an existing `FC` object, they come afterwards in the tree. `FCX` mixins are applied on top of `FCM` classes and any subsequent `FCX` mixins continue the tree in a linear a fashion downwards. + +### Special Properties +The `mixin` library adds several read-only properties to mixin-enabled Finale objects. These are: +- **`MixinClass`** *`[string]`* - The mixin class name. +- **`MixinParent`** *`[?string]`* - The name of the parent mixin (for `__FCMBase` this will be `nil`). +- **`MixinBase`** *`[?string]`* - *FCX only.* The class name of the underlying `FCM` object on which it is based. +- **`Init`** *`[?function]`* - *Optional.* The mixin's `Init` meta-method or `nil` if it doesn't have one. As this is intended to be called internally, it is only available statically via the `mixin` namespace. +- **`MixinReady`** *`[true]`* - *Internal.* A flag for determining which `FC` classes have had their metatatables modified. + +## Automatic Mixin Enabling +All `FC` objects that are returned from mixin methods are automatically upgraded to a mixin-enabled `FCM` object. This includes objects returned from methods inherited from the underlying `FC` object. + +## Accessing Mixin Methods Statically +All methods from `FCM` and `FCX` mixins can be accessed statically through the `mixin` namespace. +```lua +local mixin = require("library.mixin") +local str = mixin.FCXString() + +-- Standard instance method call +str:SetLuaString("hello world") + +-- Accessing an instance method statically +mixin.FCXString.PrintString(str, "goodbye world") + +-- Accessing a static method +mixin.FCXString.PrintHelloWorld() +``` + +## Fluid Interface (aka Method Chaining) +Any method on a mixin-enabled Finale object that returns zero values (returning `nil` still counts as a value) will have a fluid interface automatically applied by the library. This means that instead of returning nothing, the method will return `self`. + +For example, this was the previous way of creating an edit control: +```lua +local dialog = finale.FCCustomLuaWindow() +dialog:SetWidth(100) +dialog:SetHeight(100) +local edit = dialog:CreateEdit(0, 0) +edit:SetWidth(25) +edit:SetMeasurement(12, finale.MEASUREMENTUNIT_DEFAULT) +``` + +With the fluid interface, the code above can be shortened to this: +```lua +local mixin = require("library.mixin") +local dialog = mixin.FCMCustomLuaWindow():SetWidth(100):SetHeight(100) + +local edit = dialog:CreateEdit(0, 0):SetWidth(25):SetMeasurementInteger(12, finale.MEASUREMENTUNIT_DEFAULT) +``` + +Alternatively, the example above can be respaced in the following way: + +```lua +local mixin = require("library.mixin") +local dialog = mixin.FCMCustomLuaWindow() + :SetWidth(100) + :SetHeight(100) +local edit = dialog:CreateEdit(0, 0) + :SetWidth(25) + :SetMeasurementInteger(12, finale.MEASUREMENTUNIT_DEFAULT) +``` + +## Creating Mixins +General points for creating mixins: +- Place mixins in a Lua file named after the mixin in the `mixin` or `personal_mixin` folder (eg `__FCMBase.lua`, `FCXMyCustomDialog.lua`, etc). There can only be one mixin per file. +- All mixins must return a table with two values (see the templates below for examples): +- - A `meta` table of information about the `mixin` and meta-methods. +- - A `public` table with public properties and methods +- The `Init` meta-method is called after the object has been constructed, so all public methods will be available. +- If you need to guarantee that a method call won't refer to an overridden method, use a static call (eg `mixin.FCMControl.GetText(self)`). + +### `meta` Properties +The `meta` table can contain the following properties and methods: +- **Init** *(optional)* - An initializing method which should accept one argument, `self`. +- **Parent** *(FCX only, required)* - The name of the parent of an `FCX` mixin. If not set or the parent cannot be loaded, an error will be thrown. + +### Creating `FCM` Mixins +Points to remember when creating `FCM` mixins: +- The filename of an `FCM` mixin must correspond exactly to the `FC` class that it extends (ie `__FCBase` -> `__FCMBase.lua`, `FCNote` -> `FCMNote.lua`). Since `FCM` mixins are optional, a misspelled filename will simply result in the mixin not being loaded, without any errors. +- `FCM` mixins can be defined for any class in the PDK, including parent classes that can't be directly accessed (eg `__FCMBase`, `FCControl`). Use these clases if you need to add functionality that will be inherited by all child classes. + +Below is a basic template for creating an `FCM` mixin. Replace the example methods with +```lua +-- Include the mixin namespace and helper methods (include any additional libraries below) +local mixin = require("library.mixin") +local mixin_helper = require("library.mixin_helper") + +-- Table for storing private data for this mixin +local private = setmetatable({}, {__mode = "k"}) + +-- Meta information and public methods and properties +local meta = {} +local public = {} + +-- Example initializer (remove this if not needed). +function meta:Init() + -- Create private mixin storage and initialise private properties + private[self] = private[self] or { + ExamplePrivateProperty = "hello world", + } +end + +-- Define all methods here (remove/replace examples as needed) + +-- Example public instance method (use a colon) +function public:SetExample(value) + -- Ensure argument is the correct type for testing + -- The argument number is 2 because when using a colon in the method signature, it will automatically be passed `self` as the first argument. + mixin_helper.assert_argument_type(2, value, "string") + + private[self].ExamplePrivateProperty = value +end + +-- Example public static method (note the use of a dot instead of a colon) +function public.GetMagicNumber() + return 7 +end + +-- Return meta information and public methods/properties back to the mixin library +return {meta, public} +``` + +### Creating `FCX` Mixins +Points to remember when creating `FCX` mixins: +- The name of an `FCX` mixin must be in Pascal case (just like the `FC` classes), beginning with `FCX`. For example `FCXMyCustomDialog`, `FCXCtrlMeasurementEdit`, `FCXCtrlPageSizePopup`, etc +- The parent class must be declared, which can be either an `FCM` or `FCX` class. If it is an `FCM` class, it must be a concrete class (ie one that can be instantiated, like `FCMCtrlEdit`) and not an abstract parent class (ie not `FCMControl`). + +Below is a template for creating an `FCX` mixin. It is almost identical to defining an `FCM` mixin but there are a couple of important differences. +```lua +-- Include the mixin namespace and helper methods (include any additional libraries below) +local mixin = require("library.mixin") +local mixin_helper = require("library.mixin_helper") + +-- Table for storing private data for this mixin +local private = setmetatable({}, {__mode = "k"}) + +-- Meta information and public methods and properties +local meta = {} +local public = {} + +-- FCX mixins must declare their parent class (change as needed) +meta.Parent = "FCMString" + +-- Example initializer (remove this if not needed). +function meta:Init() + -- Create private mixin storage and initialise private properties + private[self] = private[self] or { + Counter = 0, + } +end + +--- +-- Define all methods here (remove/replace examples as needed) +--- + +-- Example public instance method (use a colon) +function public:IncrementCounter() + private[self].Counter = private[self].Counter + 1 +end + +-- Example public static method (use a dot) +function public.GetHighestCounter() + local highest = 0 + + for _, v in pairs(private) do + if v.Counter < highest then + highest = v.Counter + end + end + + return highest +end + +-- Return meta information and public methods/properties back to the mixin library +return {meta, public} +``` + +## Personal Mixins +If you've written mixins for your personal use and don't want to submit them to the Finale Lua repository, you can place them in a folder called `personal_mixin`, next to the `mixin` folder. + Personal mixins take precedence over public mixins, so if a mixin with the same name exists in both folders, the one in the `personal_mixin` folder will be used. ## Functions @@ -299,9 +293,7 @@ mixin.is_fc_class_name(class_name) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L940) - -Checks if a class name is an `FC` class name. - +Checks if a class name is an `FC` class name. | Input | Type | Description | | ----- | ---- | ----------- | @@ -319,9 +311,7 @@ mixin.is_fcm_class_name(class_name) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L950) - -Checks if a class name is an `FCM` class name. - +Checks if a class name is an `FCM` class name. | Input | Type | Description | | ----- | ---- | ----------- | @@ -339,9 +329,7 @@ mixin.is_fcx_class_name(class_name) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L960) - -Checks if a class name is an `FCX` class name. - +Checks if a class name is an `FCX` class name. | Input | Type | Description | | ----- | ---- | ----------- | @@ -359,9 +347,7 @@ mixin.fc_to_fcm_class_name(class_name) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L970) - -Converts an `FC` class name to an `FCM` class name. - +Converts an `FC` class name to an `FCM` class name. | Input | Type | Description | | ----- | ---- | ----------- | @@ -379,9 +365,7 @@ mixin.fcm_to_fc_class_name(class_name) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L980) - -Converts an `FCM` class name to an `FC` class name. - +Converts an `FCM` class name to an `FC` class name. | Input | Type | Description | | ----- | ---- | ----------- | @@ -399,12 +383,10 @@ mixin.subclass(object, class_name) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L994) - -Takes a mixin-enabled finale object and migrates it to an `FCX` subclass. Any conflicting property or method names will be overwritten. - -If the object is not mixin-enabled or the current `MixinClass` is not a parent of `class_name`, then an error will be thrown. -If the current `MixinClass` is the same as `class_name`, this function will do nothing. - +Takes a mixin-enabled finale object and migrates it to an `FCX` subclass. Any conflicting property or method names will be overwritten. + +If the object is not mixin-enabled or the current `MixinClass` is not a parent of `class_name`, then an error will be thrown. +If the current `MixinClass` is the same as `class_name`, this function will do nothing. | Input | Type | Description | | ----- | ---- | ----------- | @@ -423,9 +405,7 @@ mixin.UI() [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L1003) - -Returns a mixin enabled UI object from `finenv.UI` - +Returns a mixin enabled UI object from `finenv.UI` | Return type | Description | | ----------- | ----------- | @@ -439,9 +419,7 @@ mixin.eachentry(region, layer) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/mixin.lua#L1016) - -A modified version of the JW/RGPLua `eachentry` function that allows items to be stored and used outside of a loop. - +A modified version of the JW/RGPLua `eachentry` function that allows items to be stored and used outside of a loop. | Input | Type | Description | | ----- | ---- | ----------- | diff --git a/docs/library/tie.md b/docs/library/tie.md index fd5666e7..2fda5fd6 100644 --- a/docs/library/tie.md +++ b/docs/library/tie.md @@ -1,6 +1,6 @@ # Tie - -This library encapsulates Finale's behavior for initializing FCTieMod endpoints, + +This library encapsulates Finale's behavior for initializing FCTieMod endpoints, as well as providing other useful information about ties. ## Functions @@ -24,13 +24,12 @@ tie.calc_tied_to(note) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L41) - -Calculates the note that the input note could be (or is) tied to. -For this function to work correctly across barlines, the input note -must be from an instance of FCNoteEntryLayer that contains both the -input note and the tied-to note. - -@ [tie_must_exist] if true, only returns a note if the tie already exists. +Calculates the note that the input note could be (or is) tied to. +For this function to work correctly across barlines, the input note +must be from an instance of FCNoteEntryLayer that contains both the +input note and the tied-to note. + +@ [tie_must_exist] if true, only returns a note if the tie already exists. | Input | Type | Description | | ----- | ---- | ----------- | @@ -48,13 +47,12 @@ tie.calc_tied_from(note) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L81) - -Calculates the note that the input note could be (or is) tied from. -For this function to work correctly across barlines, the input note -must be from an instance of FCNoteEntryLayer that contains both the -input note and the tied-from note. - -@ [tie_must_exist] if true, only returns a note if the tie already exists. +Calculates the note that the input note could be (or is) tied from. +For this function to work correctly across barlines, the input note +must be from an instance of FCNoteEntryLayer that contains both the +input note and the tied-from note. + +@ [tie_must_exist] if true, only returns a note if the tie already exists. | Input | Type | Description | | ----- | ---- | ----------- | @@ -72,22 +70,20 @@ tie.calc_tie_span(note, for_tied_to, tie_must_exist) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L123) - -Calculates the (potential) start and end notes for a tie, given an input note. The -input note can be from anywhere, including from the `eachentry()` iterator functions. -The function returns 3 values: - -- A FCNoteLayerEntry containing both the start and and notes (if they exist). -You must maintain the lifetime of this variable as long as you are referencing either -of the other two values. -- The potential or actual start note of the tie (taken from the FCNoteLayerEntry above). -- The potential or actual end note of the tie (taken from the FCNoteLayerEntry above). - -Be very careful about modifying the return values from this function. If you do it within -an iterator loop from `eachentry()` or `eachentrysaved()` you could end up overwriting your changes -with stale data from the iterator loop. You may discover that this function is more useful -for gathering information than for modifying the values it returns. - +Calculates the (potential) start and end notes for a tie, given an input note. The +input note can be from anywhere, including from the `eachentry()` iterator functions. +The function returns 3 values: + +- A FCNoteLayerEntry containing both the start and and notes (if they exist). +You must maintain the lifetime of this variable as long as you are referencing either +of the other two values. +- The potential or actual start note of the tie (taken from the FCNoteLayerEntry above). +- The potential or actual end note of the tie (taken from the FCNoteLayerEntry above). + +Be very careful about modifying the return values from this function. If you do it within +an iterator loop from `eachentry()` or `eachentrysaved()` you could end up overwriting your changes +with stale data from the iterator loop. You may discover that this function is more useful +for gathering information than for modifying the values it returns. | Input | Type | Description | | ----- | ---- | ----------- | @@ -109,11 +105,9 @@ tie.calc_default_direction(note, for_tieend, tie_prefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L156) - -Calculates the default direction of a tie based on context and FCTiePrefs but ignoring multi-voice -and multi-layer overrides. It also does not take into account the direction being overridden in -FCTieMods. Use tie.calc_direction to calculate the actual current tie direction. - +Calculates the default direction of a tie based on context and FCTiePrefs but ignoring multi-voice +and multi-layer overrides. It also does not take into account the direction being overridden in +FCTieMods. Use tie.calc_direction to calculate the actual current tie direction. | Input | Type | Description | | ----- | ---- | ----------- | @@ -133,11 +127,9 @@ tie.calc_direction(note, tie_mod, tie_prefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L343) - -Calculates the current direction of a tie based on context and FCTiePrefs, taking into account multi-voice -and multi-layer overrides. It also takes into account if the direction has been overridden in -FCTieMods. - +Calculates the current direction of a tie based on context and FCTiePrefs, taking into account multi-voice +and multi-layer overrides. It also takes into account if the direction has been overridden in +FCTieMods. | Input | Type | Description | | ----- | ---- | ----------- | @@ -157,10 +149,8 @@ tie.calc_connection_code(note, placement, direction, for_endpoint, for_tieend, f [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L411) - -Calculates the correct connection code for activating a Tie Placement Start Point or End Point -in FCTieMod. - +Calculates the correct connection code for activating a Tie Placement Start Point or End Point +in FCTieMod. | Input | Type | Description | | ----- | ---- | ----------- | @@ -184,9 +174,7 @@ tie.calc_placement(note, tie_mod, for_pageview, direction, tie_prefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L519) - -Calculates the current placement of a tie based on context and FCTiePrefs. - +Calculates the current placement of a tie based on context and FCTiePrefs. | Input | Type | Description | | ----- | ---- | ----------- | @@ -209,10 +197,8 @@ tie.activate_endpoints(note, tie_mod, for_pageview, tie_prefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L643) - -Activates the placement endpoints of the input tie_mod and initializes them with their -default values. If an endpoint is already activated, that endpoint is not touched. - +Activates the placement endpoints of the input tie_mod and initializes them with their +default values. If an endpoint is already activated, that endpoint is not touched. | Input | Type | Description | | ----- | ---- | ----------- | @@ -233,9 +219,7 @@ tie.calc_contour_index(note, tie_mod, for_pageview, direction, tie_prefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L758) - -Calculates the current contour index of a tie based on context and FCTiePrefs. - +Calculates the current contour index of a tie based on context and FCTiePrefs. | Input | Type | Description | | ----- | ---- | ----------- | @@ -258,13 +242,11 @@ tie.activate_contour(note, tie_mod, for_pageview, tie_prefs) [View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/tie.lua#L824) - -Activates the contour fields of the input tie_mod and initializes them with their -default values. If the contour fields are already activated, nothing is changed. Note -that for interpolated Medium span types, the interpolated values may not be identical -to those calculated by Finale, but they should be close enough to make no appreciable -visible difference. - +Activates the contour fields of the input tie_mod and initializes them with their +default values. If the contour fields are already activated, nothing is changed. Note +that for interpolated Medium span types, the interpolated values may not be identical +to those calculated by Finale, but they should be close enough to make no appreciable +visible difference. | Input | Type | Description | | ----- | ---- | ----------- | diff --git a/hash/clef_change.hash b/hash/clef_change.hash index cbc7579f..c820ae97 100644 --- a/hash/clef_change.hash +++ b/hash/clef_change.hash @@ -1 +1 @@ -059f3279485a91ff18a1bfbdb1b90a04561270e58f6464366fe2f1fb346d5354fac958302ff12968a2cbd152d52347514a71255b176e2e552d141bd77af0111d clef_change.lua +0e5bd2422c27ae4cbc9b38d52bd6f75e7de2f4d9933a30af33be4ea2bdbbae7744bd5a31fbafde3106cef2432a89ac593b47c9f651fd6b7d3e4e07f75b14ce96 clef_change.lua diff --git a/hash/cross_staff_offset.hash b/hash/cross_staff_offset.hash index 7872586c..fd61fb31 100644 --- a/hash/cross_staff_offset.hash +++ b/hash/cross_staff_offset.hash @@ -1 +1 @@ -2a20cfc29bba0dad06baefebc66c34095737478f3c891fe378a9dcfe17a51987706bd7f979dcbf7ead983b42be0420001569b24b3b63fdc74cb9119c044c469a cross_staff_offset.lua +c3655cc92f3e027637c64971297a509221e1fdf8de279027e06251a8477f9f82f08b6883c22e5a532afee6599d061b3e551dca57dfe7b102fd932613dd593563 cross_staff_offset.lua diff --git a/hash/cue_notes_create.hash b/hash/cue_notes_create.hash index 13c2cbc8..ad1cb9ad 100644 --- a/hash/cue_notes_create.hash +++ b/hash/cue_notes_create.hash @@ -1 +1 @@ -742ea314e00259f252102b5bd1cbbdfe5fc42283fa79779864500b82199429b9f9decf2c3370daf7ec5e2ed511dca4dcfb398d283867e3c1c7f070fa9ce3c65c cue_notes_create.lua +f14b98195320f69e7b16f85178a8373b9a76b433c8721ae8c28d71e62578201d8274131b79d3ae001d81fce3bcc030ba26a97ac4b694be653e3685d84d66823a cue_notes_create.lua diff --git a/hash/deletion_chooser.hash b/hash/deletion_chooser.hash index 66bc8722..daa0c6a7 100644 --- a/hash/deletion_chooser.hash +++ b/hash/deletion_chooser.hash @@ -1 +1 @@ -0ebb17b859c96bbf0b94e6f78a55fcf21be41a8c0cc4033122da9e104c9c2cd3f43f75ab5aae4e2285f2ed1da30daf0d1b311806a9e74585706513147199cff5 deletion_chooser.lua +bb4a610c2fd999a12a33af140869c186336d785f969e67f3cb69642841b0ad9e5eda636960119bb9949609d197c5535c906c0a338b342abc18aa348af88b9234 deletion_chooser.lua diff --git a/hash/document_options_as_json.hash b/hash/document_options_as_json.hash index cb1119bc..e584add3 100644 --- a/hash/document_options_as_json.hash +++ b/hash/document_options_as_json.hash @@ -1 +1 @@ -ef91b32a8ef6928b67882e87b46b2ab17733c41bcc325ccdb314c366d44370dfde5f10855b4a76fb96d0d936b72205c5c56f9cd1183efca84c53c9226f0e1661 document_options_as_json.lua +054c5bb17d59b15fd9ceafd91627f0ad3388b80edc57d7bdd809d902a6758667b1936edfe9900df930a9f046b339a544648b1841136df1f3e7bdbe9dfe06838e document_options_as_json.lua diff --git a/hash/document_rename_pdfs.hash b/hash/document_rename_pdfs.hash index b43b985a..34f5190b 100644 --- a/hash/document_rename_pdfs.hash +++ b/hash/document_rename_pdfs.hash @@ -1 +1 @@ -71f7e1d83f77006e50f043512cce5fb53ba260b72288233a6dd46c79e8421a436db14efd1f58efc4cc17bacad004380f5d02b545afa7162bf0cef6294470ce1f document_rename_pdfs.lua +9958c22f6697c4ecf1a1d937fad73644d806922f49b54aca3684e65203d3a65cf8b811bef12498e1620a438a415ebe46675278615dfa3d115a42894c49ecfa6e document_rename_pdfs.lua diff --git a/hash/document_save_as_text.hash b/hash/document_save_as_text.hash index d8c8ea97..4d2919b5 100644 --- a/hash/document_save_as_text.hash +++ b/hash/document_save_as_text.hash @@ -1 +1 @@ -613c4c52d78d4adf7e6d1134b6cf45b74b6df38332d1dd585eca687d861e2e139270f5a4adfbb8172539db1a56caaf3ce06b93ee4e775c56956cbcb6d3114403 document_save_as_text.lua +cc93257b15e7f75cb7189bf67af60511f4f2cf1cf5a4a73d60259a040dda3fb8cac2efd3e0f3f38654db33aefbffd718cb100fa132ab49233ec5eca217803dd1 document_save_as_text.lua diff --git a/hash/gracenote_slash.hash b/hash/gracenote_slash.hash index 4f8289ce..35072588 100644 --- a/hash/gracenote_slash.hash +++ b/hash/gracenote_slash.hash @@ -1 +1 @@ -ee06cbc3bd761968988bed81248b558c7b2f78efacbe101190fe515d547dd9a49466ff142264089bf6158a273d270d913b33f8ad46a811b9945c865916492c80 gracenote_slash.lua +3fde3c3d0166cac30bb6f3ce984ad546fbb66bbffca61d957d8feb34559316557c5e8b762a3d4dd553794168f3bba3d95a71ada202b4cbdc8fbe3245d183ba86 gracenote_slash.lua diff --git a/hash/hairpin_creator.hash b/hash/hairpin_creator.hash index b71c73a4..d17e97c4 100644 --- a/hash/hairpin_creator.hash +++ b/hash/hairpin_creator.hash @@ -1 +1 @@ -31fbb2e21fa315760f53383ce53ed985e175423c60b869b4f5ef5874b5d7b1287d09fb00192f4f4b8caf429ba9ff9f27fad64a176ba32c9f5bf19b830089050e hairpin_creator.lua +0c62556cbcef67dc5e26d3180b06fa9aebf381184b954043aa8a8937ac16b13e09914d180d55b18765c093254eb59dd6c965cd0817c28019736bd527f8d5beb2 hairpin_creator.lua diff --git a/hash/layer_clear_selective.hash b/hash/layer_clear_selective.hash index 26133c35..43cfc3e5 100644 --- a/hash/layer_clear_selective.hash +++ b/hash/layer_clear_selective.hash @@ -1 +1 @@ -59440e14e8150e1d568a4d8b1ab1a661d07f33bb5a1406d13c6226dbf7072e04878f8610b978cf065865657e3860678ac9080b5616eceaa85c8791286832e2d0 layer_clear_selective.lua +bdb79b89359e1b795c3cd4f92851bc6a8a72ebd3bb67e1c52724ae3d1afd462782b7b944bffea9a00d353245b9ebc62aa5a423a087fcfe72ab3d79dba360e15c layer_clear_selective.lua diff --git a/hash/layer_hide.hash b/hash/layer_hide.hash index 26dd24c1..83be02ea 100644 --- a/hash/layer_hide.hash +++ b/hash/layer_hide.hash @@ -1 +1 @@ -71f428dad10b97dd887be599dd03358ecd5c8cb7a59cbb9bcf505952770160d958a10802cd047b2e81ddfc1c9ee336a1fb3854110f7979ce5117129c24b5b308 layer_hide.lua +a61f96c915be48443862398317cfea4fbf9ea8109aa42b2bae513c9687c6fbb5c87bec0ede611b5af0f0e2db3049fa3ca36fea519c8b766cba04cfbaacb3c35f layer_hide.lua diff --git a/hash/layer_mute.hash b/hash/layer_mute.hash index ee08d2fc..0e1f0389 100644 --- a/hash/layer_mute.hash +++ b/hash/layer_mute.hash @@ -1 +1 @@ -308520afb8edb5b612be2e429fbdf2c552822a47ee0e98afd13d9ff14d4432ca2fe53c446564bcedea3a1e21ff199f492d7830b6c169b01bdee32cde07512ee1 layer_mute.lua +111384795dc502a2932937ec37ff591fab70cc952d9a4e60dd4ce5ee6c21129c702854384193c8e1e081643aa5adfdedc26e52090318d9024b41bdb31646bd05 layer_mute.lua diff --git a/hash/layers_swap_1_2.hash b/hash/layers_swap_1_2.hash index 8433dbde..2dea4e9b 100644 --- a/hash/layers_swap_1_2.hash +++ b/hash/layers_swap_1_2.hash @@ -1 +1 @@ -980a733370f4a1c9225760b52262fe0590f4c22582b66a51ecfbca49205deca412f403af45ddf252bd6c25d145e0b61c60d407d4da1658cbf21c2dee6216caaa layers_swap_1_2.lua +9f739e113a8cb5439708b91fb66c29137279536ebfbd7ccf23fae6094ac3e79738b32e23f2c99b49a7f36e8f7f3a14fdcc0c92b83b33185c842419b603021edd layers_swap_1_2.lua diff --git a/hash/layers_swap_selective.hash b/hash/layers_swap_selective.hash index 8bccb352..b4d5e798 100644 --- a/hash/layers_swap_selective.hash +++ b/hash/layers_swap_selective.hash @@ -1 +1 @@ -9907be9b007d4db9cd54aa8a36332ebf6bff8539f89cfbcff3f7260d903bed9183365106463647a31720e0c0b21fa1cc13c0e575383bda69cafb16cbb2d54559 layers_swap_selective.lua +ba730070cd7570f495ed5d2a4b2d5bb071069b10f4e171cc7e81437110e959ba946486d007260aac54b2199cf97ef8b6196002b14db39a2e668d73a58c1daab3 layers_swap_selective.lua diff --git a/hash/measure_span.hash b/hash/measure_span.hash index 15a6188f..5e9442f4 100644 --- a/hash/measure_span.hash +++ b/hash/measure_span.hash @@ -1 +1 @@ -444a92ea77e11c80bf9849d23fb9786cafbdbe0604c97313258d3e7163341511dad9c74e28afb62a550e176e525b959084128f53b478cf92615de97c03e7e278 measure_span.lua +bc24fcc9ecf773a5bf0a24a9c072a618d4af937b814967d225e19d6759553f0c22ec185b3f2ed08b2c0d0685a78ffea273ee7d6c2f98b01eabee184ee5e7c568 measure_span.lua diff --git a/hash/midi_note_values.hash b/hash/midi_note_values.hash index 5060eba9..b7bc1517 100644 --- a/hash/midi_note_values.hash +++ b/hash/midi_note_values.hash @@ -1 +1 @@ -4623496ab77d5db1c59d0c9366a05887a3abd5b03ac8b1aa50f34db66e7e403aaa1e6336d3fb440df82df9ba976d705b145b7e3613613c8107e2f605dc7982db midi_note_values.lua +319e55446ab9493eb01588c31712c259292fad49952236d85ed8687c0b85287c12b856e05994397c49f7ee10fccb59dfcc6545b49eb076bb82f83f0a084422aa midi_note_values.lua diff --git a/hash/note_bariolage.hash b/hash/note_bariolage.hash index d9571915..e8b5072a 100644 --- a/hash/note_bariolage.hash +++ b/hash/note_bariolage.hash @@ -1 +1 @@ -c40b24b1065030cd665a39714ee36435d5780a2874cb0fb92754b8c8dafe85a98ed37b3c05faa212539130e03f72709913703f154bb2d8e8a9198e05546bff3d note_bariolage.lua +0d9076e16b543c3ba89295567618d523fd5f66395579db62d948c12013314b495a21f196223cb204be028a8f9649e621f0cf3cae6eb58484d3f511195ed3407b note_bariolage.lua diff --git a/hash/note_cluster_determinate.hash b/hash/note_cluster_determinate.hash index f95130d5..622c2b82 100644 --- a/hash/note_cluster_determinate.hash +++ b/hash/note_cluster_determinate.hash @@ -1 +1 @@ -3e35689c85ca06525404cd94664e6db77b3855078a91ff8456a048b09434d74bf97a8eec6d73a6853075de6ad4707f2f1cc5dbe4679a49e8ea0aefdfa16910ce note_cluster_determinate.lua +a7a03765d2a07b9e47cdf9912fa6acab275413918efe372d1c3597b175e3ecc55205a6042708354db79844346823f22d39655e321a8802206cb1dfc3927f2b2d note_cluster_determinate.lua diff --git a/hash/noteheads_change_by_layer.hash b/hash/noteheads_change_by_layer.hash index 4c198aae..45666943 100644 --- a/hash/noteheads_change_by_layer.hash +++ b/hash/noteheads_change_by_layer.hash @@ -1 +1 @@ -f91f369e0eb56e73fbb6f7291e4ce09f5749d636cafb4c591cd920277c16f85b0c7e8493b513d82830b19e5d7bb8ca59f7b649cfe43a714abf125ec23cc621ce noteheads_change_by_layer.lua +23b43fcff7aa1647f95e21ca266e2d34e6247d7420d31d4067c83de748f5fc8d3c7cdbc3df8e8d6ffb5f8e9a30253ef37f71ed680042501fc7531c900e1f8a8d noteheads_change_by_layer.lua diff --git a/hash/notes_tie.hash b/hash/notes_tie.hash index 7125a0df..8d32b3a9 100644 --- a/hash/notes_tie.hash +++ b/hash/notes_tie.hash @@ -1 +1 @@ -a043d2ad8000ec8de667abd7ca10e3aaf4fbab536c796d7b85e95903e447aafd07c02d33a3b825cc45d07962308517ddb8f2d968d858f20b87a282f66ec1ab76 notes_tie.lua +c7fb07cb9ea06a1037671f3b6432c37ac9014c4b2b649accabe4d7897112be9c11761487462a90d12ae84a3888b27ab96b7d9d1636852b28226e107a7ad5c4e8 notes_tie.lua diff --git a/hash/rest_offsets.hash b/hash/rest_offsets.hash index 3cd8c457..40e54c87 100644 --- a/hash/rest_offsets.hash +++ b/hash/rest_offsets.hash @@ -1 +1 @@ -656a9ecabe0f3ad5135cc559e464beb8994f4cc6bca7e18788cc37532b1346da5813fb665bc42ee6be4a89d4b47307e1aedac7dbb7a0c5c56522a48877f1a33c rest_offsets.lua +dc66b74d80b88e6468dec3b544572f9dc9849ccb84c585cab5923c45fedbbb63102f4e0675f007d8bd02e12a5419f7d246de4526b63dc210f68b7e953a1d664e rest_offsets.lua diff --git a/hash/slur_selection.hash b/hash/slur_selection.hash index 8d6e84df..b419ca5b 100644 --- a/hash/slur_selection.hash +++ b/hash/slur_selection.hash @@ -1 +1 @@ -313ccc0495339c0b8c82f18a3bd06977504d8e7762fe080f379bba2383950555e91fb3fc4ca023d8da9a384480581a071f14a69726ba68e940d205d6500fc24c slur_selection.lua +813eaac9c3b0069496bf7ba5119838fbadd242d2040075f9f00dd04badfa032cf523d79b55f6982b92be48010dedfbfcace18cdafd93f0b21bac019d23091b73 slur_selection.lua diff --git a/hash/smufl_bravura_larger_noteheads.hash b/hash/smufl_bravura_larger_noteheads.hash index afef236b..fd48a67f 100644 --- a/hash/smufl_bravura_larger_noteheads.hash +++ b/hash/smufl_bravura_larger_noteheads.hash @@ -1 +1 @@ -d0b81cbb8df7ca35e923b05c51e57bde585e32054bffa156c613f832cb01775e9c473c8bed6697bbd20ebb4022f360960e5c925a60c275080b560118dd3ab8d1 smufl_bravura_larger_noteheads.lua +82ba56d67e37a1c057177b3096f68080c60762f8bba32a4b2e98ba31756628ceda0af320e04af12c75a72bcdc012c9e5671b4680148fc90f86f7b3c0d89d75df smufl_bravura_larger_noteheads.lua diff --git a/hash/smufl_maestro_wide_noteheads.hash b/hash/smufl_maestro_wide_noteheads.hash index d8b113a6..f281f6b1 100644 --- a/hash/smufl_maestro_wide_noteheads.hash +++ b/hash/smufl_maestro_wide_noteheads.hash @@ -1 +1 @@ -db398f69add26dc597b68481ff089c3f47dd79ff31144a9c061acb246237881d5d20bd11305ef4b55b07e8b27c265ff94db5834fe302ba075b8d17a10b62d56f smufl_maestro_wide_noteheads.lua +41144229e39498b065f0210c6a42975cdf2983692f51a0ff362ffae8d2127e58ae580e194b7c8b5f2f4f7402a6043ccfe793ded8fbd3bbaade54d3dda80a044e smufl_maestro_wide_noteheads.lua diff --git a/hash/staff_explode.hash b/hash/staff_explode.hash index bbf8e07b..92685620 100644 --- a/hash/staff_explode.hash +++ b/hash/staff_explode.hash @@ -1 +1 @@ -88ce8e3ddc1d580dcdb49365ec170e2a1832b33938a9340c0397d06c2cf797918c77f27f1a5f5b774733f8eb77a2aea87d1d789b17dbbbabf4fa72254ce1e4ef staff_explode.lua +35b897878dae6cec61e72b79f19db1342584cf2aec724e9ef7f7f9ec53228de2b71beec00b6eef23fe8437e7cf3c4557cfcfc44babbb4642a82dc3c340b760bd staff_explode.lua diff --git a/hash/staff_rename.hash b/hash/staff_rename.hash index 4a7ec2f5..bb3e12ab 100644 --- a/hash/staff_rename.hash +++ b/hash/staff_rename.hash @@ -1 +1 @@ -fa507934c44f3c7fd652e7d8797d9b380335e5193a52815232df0e3d5d388fe2cebaf2609ac7ebcebca7433004657df78aa6b72a5a0a006f725e8058c518c646 staff_rename.lua +b78b1fe2fbe50841015bc9080e922dcc8026885f989d3ab5ded10e6b0fb4877c25a12f6c71a329cede8856b02f70ccec98ac180ef02d768705d049ebcbe40acb staff_rename.lua diff --git a/hash/staff_split_layers.hash b/hash/staff_split_layers.hash index 2b73bb64..5fb93e03 100644 --- a/hash/staff_split_layers.hash +++ b/hash/staff_split_layers.hash @@ -1 +1 @@ -df3db310bdb0b1ffe993fe7566311b62c8ab93e9b9fa3cbd0def9705f7de88cc284557abdd0b6277b9baaf1a849c7e7867dcf598bff4e44e240baaff30d93563 staff_split_layers.lua +8a6cff197e36f4de1103d1b0d0302317948098d307f79f0b49e92f785e898157e1f838e93c30eb3ae5ad53f02e601ec519a379b12aac5e60c62c16ddc5c672dd staff_split_layers.lua diff --git a/hash/ties_remove_dangling.hash b/hash/ties_remove_dangling.hash index bdf73261..84cb5a64 100644 --- a/hash/ties_remove_dangling.hash +++ b/hash/ties_remove_dangling.hash @@ -1 +1 @@ -511c84e05b87f2d6e6f8f021ff2924a352a6a55aa2a64c8d6718cb725e45dabd5569eb154f8606df6b00b19c4c3c9dac7a2867fc18d12187ef39ce8d41f0c79a ties_remove_dangling.lua +2a12a64a590372d293bc5416f13849bac133b2de75ef57b79d5070a11c8163b835c389d1464aa727f9668ae050d6b281ff51a2087af55961df9baeaed05a5cf0 ties_remove_dangling.lua diff --git a/hash/transpose_by_step.hash b/hash/transpose_by_step.hash index af3ad4e2..1e657e2c 100644 --- a/hash/transpose_by_step.hash +++ b/hash/transpose_by_step.hash @@ -1 +1 @@ -f6fa1d271d46009f6a1de7e21f76afcf5a137654b5a49f4aeb564e2d5584fac80e70142d1c5dafb63546df0f3bdb7028127fcd9c542d060b2cf05d52b97d271c transpose_by_step.lua +01def15e38157d9968875d948930a60640a4fcf6975db996e0a2536771905961f0392b1a88f05de79e8b0a6ff25935bc8f99fa3a04d367154e8df2e09aa4cdef transpose_by_step.lua diff --git a/hash/transpose_chromatic.hash b/hash/transpose_chromatic.hash index 7bc71074..131480f1 100644 --- a/hash/transpose_chromatic.hash +++ b/hash/transpose_chromatic.hash @@ -1 +1 @@ -e6371ed370ecf15f5bf4f1f46250b622ab2890c54dd6035683e5d370c05bd1505402ae3d95845c2b0f6b20e33f7eb924a6318b8e6f2d8d984572f04b8b4077b2 transpose_chromatic.lua +df2eab74ef88404706bbf2e33d54bfebf8ed8084e943196614d019c24f1e0d999cf1d49892861d0a2caedb153ab4e95cfe8ce4299b43f7cec190d80e708ba429 transpose_chromatic.lua diff --git a/hash/tuplet_state.hash b/hash/tuplet_state.hash index 987d1252..53c36412 100644 --- a/hash/tuplet_state.hash +++ b/hash/tuplet_state.hash @@ -1 +1 @@ -1a66ae049ddc391749c3c827e51f563addff4e8d809e8b0b206cf7217dca88df80ad1e9720c954588f488d9c1028e935435ed96c976bdc56a54f1619284d2493 tuplet_state.lua +d99ae040dd128fc84115f54d110b927055f4ae646e082e2c5528dbd7c5c64f9fb048ffa4dc6634408919adc1f036a19833375dd74fd45d19fe425c34dc3e6a96 tuplet_state.lua