Skip to content

Mixin Method Builder

Method Annotations vs. Parameter Annotations

The following methods build out annotations that apply to the method being built:

  • methodBuilder:inject()
  • methodBuilder:modifyArg()
  • methodBuilder:modifyArgs()
  • methodBuilder:modifyExpressionValue()
  • methodBuilder:modifyReturnValue()
  • methodBuilder:wrapMethod()
  • methodBuilder:custom()
  • methodBuilder:expression()
  • methodBuilder:definition()

Most of these functions represent injector annotations. Only one injector annotation can be provided per-method. The exceptions to this are expression() and definition(), which can be provided more than once per method.

The following methods build out sugar annotations that apply to parameters that are appended to the end of the parameter list of the method being built:

  • methodBuilder:localref()
  • methodBuilder:share()
  • methodBuilder:cancellable()

methodBuilder:inject(annotation)

Creates an @Inject annotation.

For more information see:

Parameters

  1. annotation - table: An annotation table that matches the @Inject annotation.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:modifyArg(annotation, targetType)

Creates a @ModifyArg annotation.

For more information see Mixin Cheatsheet - @ModifyArg.

Parameters

  1. annotation - table: An annotation table that matches the @ModifyArg annotation.
  2. targetType - string: A type descriptor string of the argument being modified.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:modifyArgs(annotation)

Creates a @ModifyArgs annotation.

For more information see Mixin Cheatsheet - @ModifyArgs.

Parameters

  1. annotation - table: An annotation table that matches the @ModifyArgs annotation.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:modifyExpressionValue(annotation, targetType)

Creates a @ModifyExpressionValue annotation.

For more information see MixinExtras - ModifyExpressionValue

Parameters

  1. annotation - table: An annotation table that matches the @ModifyExpressionValue annotation.
  2. targetType - string: A type descriptor string of the argument being modified.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:modifyReturnValue(annotation)

Creates a @ModifyReturnValue annotation.

For more information see MixinExtras - ModifyReturnValue

Parameters

  1. annotation - table: An annotation table that matches the @ModifyReturnValue annotation.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:wrapMethod(annotation)

Creates a @WrapMethod annotation.

For more information see MixinExtras - WrapMethod

Parameters

  1. annotation - table: An annotation table that matches the @WrapMethod annotation.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:custom(annotation, annotationType, methodDescriptor, parameterTypes, returnType)

Creates a custom injector annotation.

Parameters

  1. annotation - table: An annotation table that matches the given annotationType.
  2. annotationType - userdata [class]: The annotation class to be used.
  3. methodDescriptor - string: The target method's descriptor string.
  4. parameterTypes - table<string>: The parameters of the injector method. These may differ from the target method's descriptor.
  5. returnType - string: The return type of the injector method. This may differ from the target method's descriptor.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:expression(annotation)

Creates an @Expression annotation. This method does not produce an injector annotation and may be used multiple times within an inject method.

For more information see MixinExtras - Expressions

Parameters

  1. annotation - table: An annotation table that matches the @Expression annotation.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuilder:definition(annotation)

Creates a @Definition annotation. This method does not produce an injector annotation and may be used multiple times within an inject method.

For more information see MixinExtras - Expressions

Parameters

  1. annotation - table: An annotation table that matches the @Definition annotation.

Returns

  • userdata [instance]: The mixin method builder this annotation is being applied to.

methodBuidler:localref(type, annotation, mutable)

Creates a parameter with a @Local annotation.

See MixinExtras Wiki - Local for more information.

Parameters

  1. type - string: A type descriptor string of the parameter.
  2. annotation - table?: An optional annotation table that matches the @Local annotation.
  3. mutable - boolean?: Whether this parameter should be mutable.

WARNING

Setting mutable to true changes the parameter's type from the one passed in type to one from the LocalRef family.

Returns

  • userdata [instance]: The mixin method builder this parameter annotation is being applied to.

methodBuidler:share(type, annotation)

Creates a parameter with a @Share annotation.

See MixinExtras Wiki - Share for more information.

Parameters

  1. type - string: A type descriptor string of the parameter.
  2. annotation - table?: An optional annotation table that matches the @Share annotation.

Returns

  • userdata [instance]: The mixin method builder this parameter annotation is being applied to.

methodBuidler:cancellable()

Creates a parameter with a @Cancellable annotation.

See MixinExtras Wiki - Cancellable for more information.

Returns

  • userdata [instance]: The mixin method builder this parameter annotation is being applied to.