我无法理解:"为什么要这样保证?"
这是自定义本机函数的包装dart/runtime/vm/native_entry.cc:
它适用于想要写入的Dart程序员native extensions.
void NativeEntry::NativeCallWrapper(Dart_NativeArguments args,
Dart_NativeFunction func) {
CHECK_STACK_ALIGNMENT;
VERIFY_ON_TRANSITION;
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
Isolate* isolate = arguments->isolate();
ApiState* state = isolate->api_state();
ASSERT(state != NULL);
ApiLocalScope* current_top_scope = state->top_scope();
ApiLocalScope* scope = state->reusable_scope();
TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func));
if (scope == NULL) {
scope = new ApiLocalScope(current_top_scope,
isolate->top_exit_frame_info());
ASSERT(scope != NULL);
} else {
scope->Reinit(isolate,
current_top_scope,
isolate->top_exit_frame_info());
state->set_reusable_scope(NULL);
}
state->set_top_scope(scope); // New scope is now the top scope.
func(args);
ASSERT(current_top_scope == scope->previous());
state->set_top_scope(current_top_scope); // Reset …Run Code Online (Sandbox Code Playgroud) 随着服务器端部分变得更加复杂,开发人员将需要利用现有软件.那么,Dart是否支持与本机库(特别是C库)的接口?
Dart支持与本机库接口(参考:http://www.dartlang.org/articles/native-extensions-for-standalone-dart-vm/).有一些不错的库可用于套接字通信,与数据库连接和处理文件系统.除非桌面GUI应用程序,我没有看到任何理由不能用作通用语言.Dart被用作通用语言(包括性能)的优点/缺点是什么?
samples_extension与C库链接工作正常但是C++库呢?
我有一个基于类的C++库我想用作本机扩展,所以我们有例如: -
class Connect {
open(...);
....
}
Run Code Online (Sandbox Code Playgroud)
在C++中,我想在Dart中使用类似的类.
看看dart_api.h和dart_native_api.h,我不清楚如何从C++到Dart来回传递类指针,以及如何调用它们上的方法并将其与Dart类实例联系起来.ResolveName如何使用connection-> open()类型调用,或者我们是否以完全不同的方式执行此操作.
如何从C ++代码调用Dart方法?我想尝试在应用程序中将Dart用作脚本语言。