I'm trying to port over a node.js native abstraction to dart as a native extension. The node.js nan also happens to be using the v8 namespace, which I'm not terribly familiar with.
The [incomplete] code snippet in particular that I'm having trouble with would be this:
NAN_METHOD(TestFunction) {
NanScope();
String::Utf8Value file(args[0]->ToString());
int i = 0;
Local<Array> argv_ = Local<Array>::Cast(args[1]);
int argc = argv_->Length();
int argl = argc + 1 + 1;
char **argv = new char*[argl];
argv[0] = strdup(*file);
argv[argl-1] = NULL;
for (; i < argc; i++) {
String::Utf8Value arg(argv_->Get(NanNew<Integer>(i))->ToString());
argv[i+1] = strdup(*arg);
Strings and Integers are fairly straightforward, but the equivalent functions in dart_api.h for Arrays don't seem to exist so I'm a bit stuck. This is what I have so far:
void TestFunction(Dart_NativeArguments args) {
Dart_EnterScope();
uint8_t* file;
intptr_t f_length = 0;
Dart_StringToUTF8(Dart_GetNativeArgument(args, 0), &file, &f_length);
int i = 0;
intptr_t a_length;
Dart_Handle a_list;
Dart_handle a_handle;
a_list = Dart_GetNativeArgument(args, 1);
a_handle = Dart_ListLength(list, &a_length);
v8::Array::Get
isDart_ListGetAt
.You would want to write something like this: