Change which method to be a property and return an enum type.
Old code using which() will still work since the enum type has a __call__ method.
This commit is contained in:
@@ -6,17 +6,6 @@ T fixMaybe(::kj::Maybe<T> val) {
|
||||
KJ_IF_MAYBE(new_val, val) {
|
||||
return *new_val;
|
||||
} else {
|
||||
throw std::invalid_argument("member was null");
|
||||
throw std::invalid_argument("Member was null.");
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const char * getEnumString(T & val) {
|
||||
|
||||
auto maybe_val = val.which();
|
||||
KJ_IF_MAYBE(new_val, maybe_val) {
|
||||
return new_val->getProto().getName().cStr();;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,7 @@ from cpython.ref cimport PyObject
|
||||
|
||||
cdef extern from "../helpers/fixMaybe.h":
|
||||
EnumSchema.Enumerant fixMaybe(Maybe[EnumSchema.Enumerant]) except +reraise_kj_exception
|
||||
char * getEnumString(DynamicStruct.Reader val)
|
||||
char * getEnumString(DynamicStruct_Builder val)
|
||||
char * getEnumString(Request val)
|
||||
StructSchema.Field fixMaybe(Maybe[StructSchema.Field]) except +reraise_kj_exception
|
||||
|
||||
cdef extern from "../helpers/capabilityHelper.h":
|
||||
# PyPromise evalLater(EventLoop &, PyObject * func)
|
||||
|
||||
Reference in New Issue
Block a user