nitro-codegen
Version:
The code-generator for react-native-nitro-modules.
48 lines (44 loc) • 1.13 kB
text/typescript
import type { Language } from '../../getPlatformSpecs.js'
import { getForwardDeclaration } from '../c++/getForwardDeclaration.js'
import type { SourceFile, SourceImport } from '../SourceFile.js'
import type { Type, TypeKind } from './Type.js'
export class MapType implements Type {
get canBePassedByReference(): boolean {
// It's a shared_ptr<..>, no ref.
return true
}
get kind(): TypeKind {
return 'map'
}
getCode(language: Language): string {
switch (language) {
case 'c++':
return 'std::shared_ptr<AnyMap>'
case 'swift':
return 'AnyMapHolder'
case 'kotlin':
return 'AnyMap'
default:
throw new Error(
`Language ${language} is not yet supported for MapType!`
)
}
}
getExtraFiles(): SourceFile[] {
return []
}
getRequiredImports(): SourceImport[] {
return [
{
name: 'NitroModules/AnyMap.hpp',
forwardDeclaration: getForwardDeclaration(
'class',
'AnyMap',
'NitroModules'
),
language: 'c++',
space: 'system',
},
]
}
}