mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
7baeabe0e4
https://github.com/dart-lang/co19/issues/1090 TEST=Standard tryjobs, all changes are in test code only. Change-Id: Ie73174447ab165827335652cf035f85b7510ab55 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201564 Commit-Queue: Alexander Thomas <athom@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
30 lines
891 B
Dart
30 lines
891 B
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// @dart = 2.9
|
|
|
|
import 'dart:ffi';
|
|
|
|
import "package:expect/expect.dart";
|
|
import "package:ffi/ffi.dart";
|
|
|
|
class COMObject extends Struct {
|
|
Pointer<IntPtr> lpVtbl;
|
|
|
|
// This should not be interpreted as a native field.
|
|
Pointer<IntPtr> get vtable => Pointer.fromAddress(lpVtbl.value);
|
|
}
|
|
|
|
void main() {
|
|
Expect.equals(sizeOf<Pointer>(), sizeOf<COMObject>());
|
|
|
|
final comObjectPointer = calloc<COMObject>();
|
|
final vTablePointer = calloc<IntPtr>();
|
|
vTablePointer.value = 1234;
|
|
final comObject = comObjectPointer.ref;
|
|
comObject.lpVtbl = vTablePointer;
|
|
Expect.equals(1234, comObject.vtable.address);
|
|
calloc.free(comObjectPointer);
|
|
calloc.free(vTablePointer);
|
|
}
|