問題タブ [metaobject]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c - Metaobject compiler for C
I need write a metaobject compiler for C (like a MOC in Qt). I will add to *.c source own keywords and mechanisms (like slots/signals in Qt).
I'll represent this work in three stages:
- Writing C-code with own constructions
- Parsing and generation of new source file without own constructions using metaobject compiler.
- Compilation of file from stage 2 using, for example, GCC.
So, I have questions about second stage. MOC will be a pure C lexical analyzer/syntax analyzer with addition of analysing my constructions, right? Whether there are such pure C analyzers in the free access? Whether really to build in them parsing of my code? And generally, I think in the correct direction?
groovy - 複数のオブジェクトからのメタメソッドの Groovy コピー/結合
私は2つのクラスを持っています。実行時に、あるオブジェクトのメソッドを別のオブジェクトに「複製」したいと考えています。これは可能ですか?左シフトを使用して失敗した試みを以下に示します。
(注:同じ結果で currMethod.clone() も試しました。)
リクエストごとに、目標/ユースケースに関する背景を追加しています:
これは、標準的な機能タイプのユース ケースに非常によく似ています。要約すると、すべてのクライアント環境 (50 ~ 100) に適用されるクラスに多くのメソッドがあります。これらを適用して、特定のデフォルトの順序でデータを処理します。これらのメソッドのそれぞれは、クライアント固有のメソッド (同じメソッド名で存在する場合) によってオーバーライドされる可能性があり、上記のアプローチを使用してメソッドセットを「調整」するというアイデアがありました。クライアント環境名に基づいて、メソッドを動的にオーバーライドする方法が必要です。
注: メタクラスでメソッドをオーバーライドすることは非常に標準的です (または、それが驚くべき機能が存在する理由です)。そして、メソッドが String currMethod = "{x-> x+1}" のようなテキストとして存在する場合に機能する場合は、this.metaClass."$currMethodName" = currMethod と言うだけです。この場合の私の課題は、メソッドがコンパイルされ、どこかでテキストとして定義されるのではなく、別のクラスに存在することです。
すべてのカスタム メソッドをビルド時にクライアント固有のクラスにコンパイルする目的は、計算ごとに実行時にこれらの動的メソッドをコンパイルするコストを回避することでした。ビルド時間。この方法では、クライアント固有のコードのみをそれぞれのクライアントに展開することもできます。マスター クラスで他のすべてのクライアントの計算は必要ありません。
それが理にかなっていることを願っています。
Jeremie B の提案に対する新しいアプローチ:
実行時に名前で実装する特性を選択する必要があるため、次のように機能します。