@@ -181,6 +181,7 @@ Below is a basic template for creating an `FCM` mixin. Replace the example metho
181181``` lua
182182-- Include the mixin namespace and helper methods (include any additional libraries below)
183183local mixin = require (" library.mixin" )
184+ local mixin_helper = require (" library.mixin_helper" )
184185
185186-- Table for storing private data for this mixin
186187local private = setmetatable ({}, {__mode = " k" })
203204function public :SetExample (value )
204205 -- Ensure argument is the correct type for testing
205206 -- The argument number is 2 because when using a colon in the method signature, it will automatically be passed `self` as the first argument.
206- mixin . assert_argument ( value , " string" , 2 )
207+ mixin_helper . assert_argument_type ( 2 , value , " string" )
207208
208209 private [self ].ExamplePrivateProperty = value
209210end
@@ -227,6 +228,7 @@ Below is a template for creating an `FCX` mixin. It is almost identical to defin
227228``` lua
228229-- Include the mixin namespace and helper methods (include any additional libraries below)
229230local mixin = require (" library.mixin" )
231+ local mixin_helper = require (" library.mixin_helper" )
230232
231233-- Table for storing private data for this mixin
232234local private = setmetatable ({}, {__mode = " k" })
@@ -280,155 +282,146 @@ Personal mixins take precedence over public mixins, so if a mixin with the same
280282
281283## Functions
282284
285+ - [ is_fc_class_name(class_name)] ( #is_fc_class_name )
286+ - [ is_fcm_class_name(class_name)] ( #is_fcm_class_name )
287+ - [ is_fcx_class_name(class_name)] ( #is_fcx_class_name )
288+ - [ fc_to_fcm_class_name(class_name)] ( #fc_to_fcm_class_name )
289+ - [ fcm_to_fc_class_name(class_name)] ( #fcm_to_fc_class_name )
283290- [ subclass(object, class_name)] ( #subclass )
284- - [ is_instance_of(object, class_name)] ( #is_instance_of )
285- - [ assert_argument(value, expected_type, argument_number)] ( #assert_argument )
286- - [ force_assert_argument(value, expected_type, argument_number)] ( #force_assert_argument )
287- - [ assert(condition, message, no_level)] ( #assert )
288- - [ force_assert(condition, message, no_level)] ( #force_assert )
289291- [ UI()] ( #ui )
290292- [ eachentry(region, layer)] ( #eachentry )
291293
292- ### subclass
294+ ### is_fc_class_name
293295
294296``` lua
295- mixin .subclass ( object , class_name )
297+ mixin .is_fc_class_name ( class_name )
296298```
297299
298- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L850 )
300+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L740 )
299301
300302
301- Takes a mixin-enabled finale object and migrates it to an ` FCX ` subclass. Any conflicting property or method names will be overwritten.
302-
303- If the object is not mixin-enabled or the current ` MixinClass ` is not a parent of ` class_name ` , then an error will be thrown.
304- If the current ` MixinClass ` is the same as ` class_name ` , this function will do nothing.
303+ Checks if a class name is an ` FC ` class name.
305304
306305
307306| Input | Type | Description |
308307| ----- | ---- | ----------- |
309- | ` object ` | ` __FCMBase ` | |
310- | ` class_name ` | ` string ` | FCX class name. |
308+ | ` class_name ` | ` string ` | |
311309
312310| Return type | Description |
313311| ----------- | ----------- |
314- | `__ FCMBase \\ | nil ` | The object that was passed with mixin applied. |
312+ | ` boolean ` | |
315313
316- ### is_instance_of
314+ ### is_fcm_class_name
317315
318316``` lua
319- mixin .is_instance_of ( object , class_name )
317+ mixin .is_fcm_class_name ( class_name )
320318```
321319
322- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L866 )
320+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L750 )
323321
324322
325- Checks if an object is an instance of a class.
326- Conditions:
327- - Parent cannot be instance of child.
328- - ` FC ` object cannot be an instance of an ` FCM ` or ` FCX ` class
329- - ` FCM ` object cannot be an instance of an ` FCX ` class
330- - ` FCX ` object cannot be an instance of an ` FC ` class
323+ Checks if a class name is an ` FCM ` class name.
331324
332325
333326| Input | Type | Description |
334327| ----- | ---- | ----------- |
335- | ` object ` | ` __FCBase ` | Any finale object, including mixin enabled objects. |
336- | ` class_name ` | ` string ` | An ` FC ` , ` FCM ` , or ` FCX ` class name. Can be the name of a parent class. |
328+ | ` class_name ` | ` string ` | |
337329
338330| Return type | Description |
339331| ----------- | ----------- |
340332| ` boolean ` | |
341333
342- ### assert_argument
334+ ### is_fcx_class_name
343335
344336``` lua
345- mixin .assert_argument ( value , expected_type , argument_number )
337+ mixin .is_fcx_class_name ( class_name )
346338```
347339
348- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L937 )
349-
350-
351- Asserts that an argument to a mixin method is the expected type(s). This should only be used within mixin methods as the function name will be inserted automatically.
340+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L760 )
352341
353- NOTE: For performance reasons, this function will only assert if in debug mode (ie ` finenv.DebugEnabled == true ` ). If assertions are always required, use ` force_assert_argument ` instead.
354342
355- If not a valid type, will throw a bad argument error at the level above where this function is called.
356- Types can be Lua types (eg ` string ` , ` number ` , ` bool ` , etc), finale class (eg ` FCString ` , ` FCMeasure ` , etc), or mixin class (eg ` FCMString ` , ` FCMMeasure ` , etc)
357- Parent classes cannot be specified as this function does not examine the class hierarchy.
358-
359- Note that mixin classes may satisfy the condition for the underlying ` FC ` class.
360- For example, if the expected type is ` FCString ` , an ` FCMString ` object will pass the test, but an ` FCXString ` object will not.
361- If the expected type is ` FCMString ` , an ` FCXString ` object will pass the test but an ` FCString ` object will not.
343+ Checks if a class name is an ` FCX ` class name.
362344
363345
364346| Input | Type | Description |
365347| ----- | ---- | ----------- |
366- | ` value ` | ` mixed ` | The value to test. |
367- | ` expected_type ` | ` string\|table ` | If there are multiple valid types, pass a table of strings. |
368- | ` argument_number ` | ` number ` | The REAL argument number for the error message (self counts as #1 ). |
348+ | ` class_name ` | ` string ` | |
369349
370- ### force_assert_argument
350+ | Return type | Description |
351+ | ----------- | ----------- |
352+ | ` boolean ` | |
353+
354+ ### fc_to_fcm_class_name
371355
372356``` lua
373- mixin .force_assert_argument ( value , expected_type , argument_number )
357+ mixin .fc_to_fcm_class_name ( class_name )
374358```
375359
376- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L973 )
360+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L770 )
377361
378362
379- The same as ` assert_argument ` except this function always asserts, regardless of whether debug mode is enabled .
363+ Converts an ` FC ` class name to an ` FCM ` class name .
380364
381365
382366| Input | Type | Description |
383367| ----- | ---- | ----------- |
384- | ` value ` | ` mixed ` | The value to test. |
385- | ` expected_type ` | ` string\|table ` | If there are multiple valid types, pass a table of strings. |
386- | ` argument_number ` | ` number ` | The REAL argument number for the error message (self counts as #1 ). |
368+ | ` class_name ` | ` string ` | |
387369
388- ### assert
370+ | Return type | Description |
371+ | ----------- | ----------- |
372+ | ` string ` | |
373+
374+ ### fcm_to_fc_class_name
389375
390376``` lua
391- mixin .assert ( condition , message , no_level )
377+ mixin .fcm_to_fc_class_name ( class_name )
392378```
393379
394- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L985 )
380+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L780 )
395381
396382
397- Asserts a condition in a mixin method. If the condition is false, an error is thrown one level above where this function is called.
398- Only asserts when in debug mode. If assertion is required on all executions, use ` force_assert ` instead
383+ Converts an ` FCM ` class name to an ` FC ` class name.
399384
400385
401386| Input | Type | Description |
402387| ----- | ---- | ----------- |
403- | ` condition ` | ` any ` | Can be any value or expression. If a function, it will be called (with zero arguments) and the result will be tested. |
404- | ` message ` | ` string ` | The error message. |
405- | ` no_level ` (optional) | ` boolean ` | If true, error will be thrown with no level (ie level 0) |
388+ | ` class_name ` | ` string ` | |
406389
407- ### force_assert
390+ | Return type | Description |
391+ | ----------- | ----------- |
392+ | ` string ` | |
393+
394+ ### subclass
408395
409396``` lua
410- mixin .force_assert ( condition , message , no_level )
397+ mixin .subclass ( object , class_name )
411398```
412399
413- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L1004 )
400+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L794 )
414401
415402
416- The same as ` assert ` except this function always asserts, regardless of whether debug mode is enabled.
403+ Takes a mixin-enabled finale object and migrates it to an ` FCX ` subclass. Any conflicting property or method names will be overwritten.
404+
405+ If the object is not mixin-enabled or the current ` MixinClass ` is not a parent of ` class_name ` , then an error will be thrown.
406+ If the current ` MixinClass ` is the same as ` class_name ` , this function will do nothing.
417407
418408
419409| Input | Type | Description |
420410| ----- | ---- | ----------- |
421- | ` condition ` | ` any ` | Can be any value or expression. |
422- | ` message ` | ` string ` | The error message. |
423- | ` no_level ` (optional) | ` boolean ` | If true, error will be thrown with no level (ie level 0) |
411+ | ` object ` | ` __FCMBase ` | |
412+ | ` class_name ` | ` string ` | FCX class name. |
413+
414+ | Return type | Description |
415+ | ----------- | ----------- |
416+ | `__ FCMBase\\ | nil` | The object that was passed with mixin applied. |
424417
425418### UI
426419
427420``` lua
428421mixin .UI ()
429422```
430423
431- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L1019 )
424+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L803 )
432425
433426
434427Returns a mixin enabled UI object from ` finenv.UI `
@@ -444,7 +437,7 @@ Returns a mixin enabled UI object from `finenv.UI`
444437mixin .eachentry (region , layer )
445438```
446439
447- [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L1032 )
440+ [ View source] ( https://github.com/finale-lua/lua-scripts/tree/master/src/library/mixin.lua#L816 )
448441
449442
450443A modified version of the JW/RGPLua ` eachentry ` function that allows items to be stored and used outside of a loop.
0 commit comments