pyConvertDynamic function
Converts a Dart object to the python equivalent
The caller of this function takes ownership of the python object and must call Py_DecRef after they are done with it.
Implementation
PyObjAllocated pyConvertDynamic(Object? o) {
if (o == null) {
return PyObjAllocated.noAllocation(dartpyc.Py_None);
} else if (o is bool) {
if (o) {
return PyObjAllocated.noAllocation(dartpyc.Py_True);
} else {
return PyObjAllocated.noAllocation(dartpyc.Py_False);
}
} else if (o is int) {
return PyObjAllocated.noAllocation(o.asPyInt);
} else if (o is double) {
return PyObjAllocated.noAllocation(o.asPyFloat);
} else if (o is String) {
return o.asPyBytes();
} else if (o is List) {
throw UnimplementedError();
} else if (o is Map) {
throw UnimplementedError();
}
throw UnimplementedError();
}