Java Code Examples for org.bytedeco.javacpp.Pointer#isNull()

The following examples show how to use org.bytedeco.javacpp.Pointer#isNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractTF_Buffer.java    From java with Apache License 2.0 5 votes vote down vote up
/**
 * Calls TF_NewBufferFromString(), and registers a deallocator.
 * @return TF_Buffer created, or null if proto is null or empty. Do not call TF_DeleteBuffer() on it.
 */
public static TF_Buffer newBufferFromString(Pointer proto) {
    if (proto == null || proto.isNull() || proto.limit() == 0) {
        return null;
    }
    TF_Buffer b = TF_NewBufferFromString(proto, proto.limit());
    if (b != null) {
        b.deallocator(new DeleteDeallocator(b));
    }
    return b;
}
 
Example 2
Source File: PythonObject.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
public boolean isNone() {
    if (nativePythonObject == null || Pointer.isNull(nativePythonObject)) {
        return true;
    }
    try (PythonGC _ = PythonGC.pause()) {
        PythonObject type = Python.type(this);
        boolean ret = Python.type(this).toString().equals("<class 'NoneType'>") && toString().equals("None");
        Py_DecRef(type.nativePythonObject);
        return ret;
    }
}
 
Example 3
Source File: PythonGC.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private void addObject(PythonObject pythonObject) {
    if (!active) return;
    if (Pointer.isNull(pythonObject.getNativePythonObject()))return;
    if (alreadyRegistered(pythonObject.getNativePythonObject())) {
        return;
    }
    objects.add(pythonObject.getNativePythonObject());
}
 
Example 4
Source File: Graph.java    From java with Apache License 2.0 4 votes vote down vote up
private static void requireHandle(Pointer handle) {
  if (handle == null || handle.isNull()) {
    throw new IllegalStateException("close() has been called on the Graph");
  }
}
 
Example 5
Source File: Session.java    From java with Apache License 2.0 4 votes vote down vote up
private static void requireHandle(Pointer handle) {
  if (handle == null || handle.isNull()) {
    throw new IllegalStateException("close() has been called on the Session");
  }
}
 
Example 6
Source File: GraphOperationBuilder.java    From java with Apache License 2.0 4 votes vote down vote up
private static void requireHandle(Pointer handle) {
  if (handle == null || handle.isNull()) {
    throw new IllegalStateException("Operation has already been built");
  }
}
 
Example 7
Source File: GraphOperation.java    From java with Apache License 2.0 4 votes vote down vote up
private static void requireHandle(Pointer handle) {
  if (handle == null || handle.isNull()) {
    throw new IllegalStateException("close() has been called on the Graph this Operation was a part of");
  }
}