12.6.7.3 CPP0002 - 네이티브 마셜링 타입과 함수 클로저(Native Marshalling Types and Function Closures)

12.6.7.3 CPP0002 - 네이티브 마셜링 타입과 함수 클로저(Native Marshalling Types and Function Closures)

설명(Description)

:cpp.ValueType 또는 :cpp.PointerType으로 주석 처리된 extern 클래스의 멤버 함수는 직접 호출만 가능하며, 이러한 멤버 함수에서 클로저를 만들려고 하면 이 오류를 생성합니다.

예제(Examples)

다음 예제들은 CPP0002를 생성합니다.

@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;

    function bar():Void;
}

function main() {
    final f = new Foo();
    final c = f.bar; // CPP0002

    c();
}
@:semantics(value)
@:cpp.PointerType
extern class Foo {
    static function allocate():Foo;
    function bar():Void;
}

function main() {
    final f = Foo.allocate();
    final c = f.bar; // CPP0002

    c();
}

출처: CPP0002 - Native Marshalling Types and Function Closures

더 알아보기