use of org.cafebabepy.runtime.object.java.PyJavaFunctionObject in project cafebabepy by cafebabepy.
the class AbstractAbstractCafeBabePyAny method defineClassMember.
private void defineClassMember(Class<?> clazz) {
// Check duplicate
Set<String> defineClassMemberNamesSet = new HashSet<>();
for (Method method : clazz.getMethods()) {
// Same class method only
if (clazz != method.getDeclaringClass()) {
continue;
}
DefinePyFunction definePyFunction = method.getAnnotation(DefinePyFunction.class);
if (definePyFunction == null) {
continue;
}
if (defineClassMemberNamesSet.contains(definePyFunction.name())) {
throw new CafeBabePyException("Duplicate '" + definePyFunction.name() + "' function");
}
PyJavaFunctionObject f = new PyJavaFunctionObject(getRuntime(), this, definePyFunction.name(), method);
if (__call__.equals(f.getName())) {
f.getScope().put(__call__, f);
}
getScope().put(f.getName(), f);
defineClassMemberNamesSet.add(definePyFunction.name());
}
}
Aggregations