NativeScript / NativeScript/ios
Question on declarations generation
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 150
- フォーク
- 43
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 22
説明
Hello and thanks for your work.
I have a question regarding the generation of ios typescript declarations hoping to be in the right place.
We're using a robovm based toolchain to build a native library for iOS from Java-code. This toolchain emits header files in the following (shortened) form:
@protocol Option
-(NSString *) optionId;
-(NSString *) type;
@end
typedef NSObject<Option> Option;
@protocol Info
-(NSArray<NSObject<Option> *> *) getOptions;
@end
typedef NSObject<Info> Info;
the (shortened) declarations in ios.d.ts are
interface Option {
optionId(): string;
type(): string;
}
declare var Option: {
prototype: Option;
};
interface Info {
getOptions(): NSArray<NSObject>;
}
declare var Info: {
prototype: Info;
};
You may notice that the returned Array of getOptions is typed with NSObject instead of Option, which is the reason for this writing.
In fact are all argument- and return- types of functions which are defined by our headers typed with NSObject instead of the type which it should be.
After digging a while i understand that the types are evaluated in that function
https://github.com/NativeScript/ios/blob/main/metadata-generator/src/TypeScript/DefinitionWriter.cpp#L862
which might be wrong since it's been a while that i read some cpp code.
I assume that this codes falls back to NSObject if it cannot determine the correct type.
Note, that if i manually adjust the types in ios.d.ts everything works fine.
So basically my questions:
- Are our input (the header files) missing something or do they have to be different soemhow to get beter outcomes?
- If not would it be possible to patch the generator?
- Am i totally wrong here?
Cheers and again thanks for your work.
legion
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
metadata-generator/src/TypeScript/DefinitionWriter.cpp の862行目付近から始め、ここに示されている Objective-C ヘッダー宣言および生成された ios.d.ts と、その型評価を比較してください。入力ヘッダーを変更する必要があるのか、それともジェネレーターがプロトコル型を失っているのかを判断してください。完了の判断は、明確な診断と、NSObject ではなく引数型および戻り値型が正しく保持されていることによって示されます。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- cpp, objective-c, typescript
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100