function copyingValidatorFunction()

in src/plugins/copying-type-safety.ts [35:71]


function copyingValidatorFunction(
  supportsValueSemantics: boolean,
  attributes: ObjectSpec.Attribute[],
): ObjC.Function {
  return {
    comments: [
      {
        content:
          '// This unused function ensures that all object fields conform to NSCopying.',
      },
      {
        content:
          '// The -copy method is implemented on NSObject, and throws an exception at runtime.',
      },
    ],
    name: 'RMCopyingValidatorFunction',
    parameters: [],
    returnType: {
      type: null,
      modifiers: [],
    },
    code: attributes
      .filter((attribute) =>
        shouldValidateNSCopyingConformanceOfAttribute(
          supportsValueSemantics,
          attribute,
        ),
      )
      .map(
        (attribute) =>
          `id<NSCopying> ${attribute.name}_must_conform_to_NSCopying __unused = (${attribute.type.reference})nil;`,
      ),
    isPublic: false,
    isInline: false,
    compilerAttributes: ['__attribute__((unused))'],
  };
}