react-native-macos/Libraries/Blob
Ramanpreet Nara f37093319b Start using getConstants
Summary:
TurboModules depend on a getConstants method. Existing ObjectiveC modules do not have this method. Therefore, I moved the contents of `constantsToExport` to `getConstants` and then had `constantsToExports` call `getConstants`.

facebook
Since all NativeModules will eventually need to be migrated to the TurboModule system, I didn't restrict this to just the NativeModules in Marketplace.

```
const fs = require('fs');

if (process.argv.length < 3) {
    throw new Error('Expected a file containing a list of native modules as the third param');
}

function read(filename) {
    return fs.readFileSync(filename, 'utf8');
}

const nativeModuleFilenames = read(process.argv[2]).split('\n').filter(Boolean);

nativeModuleFilenames.forEach((fileName) => {
    if (fileName.endsWith('.h')) {
        return;
    }

    const absPath = `${process.env.HOME}/${fileName}`;
    const fileSource = read(absPath);

    if (/(\n|^)-\s*\((.+)\)getConstants/.test(fileSource)) {
        return;
    }

    const constantsToExportRegex = /(\n|^)-\s*\((.+)\)constantsToExport/;
    const result = constantsToExportRegex.exec(fileSource);

    if (result == null) {
        throw new Error(`Didn't find a constantsToExport function inside NativeModule ${fileName}`);
    }

    const returnType = result[2];

    const newFileSource = fileSource.replace(
        constantsToExportRegex,
        '$1- ($2)constantsToExport\n' +
        '{\n' +
        `  return ${returnType.includes('ModuleConstants') ? '($2)' : ''}[self getConstants];\n` +
        '}\n' +
        '\n' +
        '- ($2)getConstants'
    );

    fs.writeFileSync(absPath, newFileSource);
});
```

```
> xbgs -l ')constantsToExport'
```

Reviewed By: fkgozali

Differential Revision: D13951197

fbshipit-source-id: 394a319d42aff466c56a3d748e17c335307a8f47
2019-02-04 17:46:56 -08:00
..
RCTBlob.xcodeproj Update Xcode projects (#19574) 2018-06-19 23:48:12 -07:00
__mocks__ Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
__tests__ Flesh out the URL polyfill a bit more (#22901) 2019-01-16 05:31:55 -08:00
Blob.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
BlobManager.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
BlobRegistry.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
BlobTypes.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
File.js Use `invariant` instead of `fbjs/lib/invariant` 2018-12-03 00:07:02 -08:00
FileReader.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBlobManager.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTBlobManager.mm Start using getConstants 2019-02-04 17:46:56 -08:00
RCTFileReaderModule.h Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
RCTFileReaderModule.m Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
URL.js Flesh out the URL polyfill a bit more (#22901) 2019-01-16 05:31:55 -08:00