pyConvertDynamic function Null safety

Pointer<PyObject> pyConvertDynamic (
  1. Object? o
)

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

Pointer<PyObject> pyConvertDynamic(Object? o) {
  if (o == null) {
    return dartpyc.Py_None;
  } else if (o is bool) {
    if (o) {
      return dartpyc.Py_True;
    } else {
      return dartpyc.Py_False;
    }
  } else if (o is int) {
    return pyConvertInt(o);
  } else if (o is double) {
    return pyConvertDouble(o);
  } else if (o is String) {
    throw UnimplementedError();
  } else if (o is List) {
    throw UnimplementedError();
  } else if (o is Map) {
    throw UnimplementedError();
  }
  throw UnimplementedError();
}