fixed formatting 2
This commit is contained in:
parent
dccec876c5
commit
ed68a7b749
@ -25,82 +25,90 @@ import static org.lwjgl.system.APIUtil.*;
|
||||
|
||||
public final class CLUtil {
|
||||
|
||||
/** Maps OpenCL error token values to their String representations. */
|
||||
private static final Map<Integer, String> CL_ERROR_TOKENS = apiClassTokens(
|
||||
new BiPredicate<Field, Integer>() {
|
||||
private final List<String> EXCLUDE = Arrays.asList("CL_DEVICE_TYPE_ALL", "CL_BUILD_NONE", "CL_BUILD_ERROR", "CL_BUILD_IN_PROGRESS");
|
||||
/**
|
||||
* Maps OpenCL error token values to their String representations.
|
||||
*/
|
||||
private static final Map<Integer, String> CL_ERROR_TOKENS = apiClassTokens(
|
||||
new BiPredicate<Field, Integer>() {
|
||||
private final List<String> EXCLUDE = Arrays.asList("CL_DEVICE_TYPE_ALL", "CL_BUILD_NONE", "CL_BUILD_ERROR", "CL_BUILD_IN_PROGRESS");
|
||||
|
||||
@Override
|
||||
public boolean test(Field field, Integer value) {
|
||||
return value < 0 && !EXCLUDE.contains(field.getName()); // OpenCL errors have negative values.
|
||||
}
|
||||
},
|
||||
null,
|
||||
CL10.class,
|
||||
apiOptionalClass("org.lwjgl.opencl.CL10GL"),
|
||||
CL11.class,
|
||||
CL12.class,
|
||||
CL20.class,
|
||||
apiOptionalClass("org.lwjgl.opencl.APPLEGLSharing"),
|
||||
INTELAccelerator.class,
|
||||
apiOptionalClass("org.lwjgl.opencl.KHRGLSharing"),
|
||||
apiOptionalClass("org.lwjgl.opencl.KHREGLEvent"),
|
||||
apiOptionalClass("org.lwjgl.opencl.KHREGLImage"),
|
||||
KHRICD.class
|
||||
/*, EXTDeviceFission.class*/
|
||||
);
|
||||
@Override
|
||||
public boolean test(Field field, Integer value) {
|
||||
return value < 0 && !EXCLUDE.contains(field.getName()); // OpenCL errors have negative values.
|
||||
}
|
||||
},
|
||||
null,
|
||||
CL10.class,
|
||||
apiOptionalClass("org.lwjgl.opencl.CL10GL"),
|
||||
CL11.class,
|
||||
CL12.class,
|
||||
CL20.class,
|
||||
apiOptionalClass("org.lwjgl.opencl.APPLEGLSharing"),
|
||||
INTELAccelerator.class,
|
||||
apiOptionalClass("org.lwjgl.opencl.KHRGLSharing"),
|
||||
apiOptionalClass("org.lwjgl.opencl.KHREGLEvent"),
|
||||
apiOptionalClass("org.lwjgl.opencl.KHREGLImage"),
|
||||
KHRICD.class
|
||||
/*, EXTDeviceFission.class*/
|
||||
);
|
||||
|
||||
private CLUtil() {}
|
||||
private CLUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the {@code errcode} present in the current position of the specified {@code errcode_ret} buffer and throws an {@link OpenCLException} if it's not
|
||||
* equal to {@link CL10#CL_SUCCESS}.
|
||||
*
|
||||
* @param errcode_ret the {@code errcode} buffer
|
||||
*
|
||||
* @throws OpenCLException
|
||||
*/
|
||||
public static void checkCLError(ByteBuffer errcode_ret) {
|
||||
checkCLError(errcode_ret.getInt(errcode_ret.position()));
|
||||
}
|
||||
/**
|
||||
* Checks the {@code errcode} present in the current position of the
|
||||
* specified {@code errcode_ret} buffer and throws an
|
||||
* {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}.
|
||||
*
|
||||
* @param errcode_ret the {@code errcode} buffer
|
||||
*
|
||||
* @throws OpenCLException
|
||||
*/
|
||||
public static void checkCLError(ByteBuffer errcode_ret) {
|
||||
checkCLError(errcode_ret.getInt(errcode_ret.position()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the {@code errcode} present in the current position of the specified {@code errcode_ret} buffer and throws an {@link OpenCLException} if it's not
|
||||
* equal to {@link CL10#CL_SUCCESS}.
|
||||
*
|
||||
* @param errcode_ret the {@code errcode} buffer
|
||||
*
|
||||
* @throws OpenCLException
|
||||
*/
|
||||
public static void checkCLError(IntBuffer errcode_ret) {
|
||||
checkCLError(errcode_ret.get(errcode_ret.position()));
|
||||
}
|
||||
/**
|
||||
* Checks the {@code errcode} present in the current position of the
|
||||
* specified {@code errcode_ret} buffer and throws an
|
||||
* {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}.
|
||||
*
|
||||
* @param errcode_ret the {@code errcode} buffer
|
||||
*
|
||||
* @throws OpenCLException
|
||||
*/
|
||||
public static void checkCLError(IntBuffer errcode_ret) {
|
||||
checkCLError(errcode_ret.get(errcode_ret.position()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the specified {@code errcode} and throws an {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}.
|
||||
*
|
||||
* @param errcode the {@code errcode} to check
|
||||
*
|
||||
* @throws OpenCLException
|
||||
*/
|
||||
public static void checkCLError(int errcode) {
|
||||
if ( errcode != CL_SUCCESS )
|
||||
throw new OpenCLException(getErrcodeName(errcode));
|
||||
}
|
||||
/**
|
||||
* Checks the specified {@code errcode} and throws an
|
||||
* {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}.
|
||||
*
|
||||
* @param errcode the {@code errcode} to check
|
||||
*
|
||||
* @throws OpenCLException
|
||||
*/
|
||||
public static void checkCLError(int errcode) {
|
||||
if (errcode != CL_SUCCESS) {
|
||||
throw new OpenCLException(getErrcodeName(errcode));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the token name of the specified {@code errcode}.
|
||||
*
|
||||
* @param errcode the {@code errcode}
|
||||
*
|
||||
* @return the {@code errcode} token name
|
||||
*/
|
||||
public static String getErrcodeName(int errcode) {
|
||||
String errname = CL_ERROR_TOKENS.get(errcode);
|
||||
if ( errname == null )
|
||||
errname = apiUnknownToken(errcode);
|
||||
/**
|
||||
* Returns the token name of the specified {@code errcode}.
|
||||
*
|
||||
* @param errcode the {@code errcode}
|
||||
*
|
||||
* @return the {@code errcode} token name
|
||||
*/
|
||||
public static String getErrcodeName(int errcode) {
|
||||
String errname = CL_ERROR_TOKENS.get(errcode);
|
||||
if (errname == null) {
|
||||
errname = apiUnknownToken(errcode);
|
||||
}
|
||||
|
||||
return errname;
|
||||
}
|
||||
return errname;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,181 +16,200 @@ import static org.lwjgl.system.Pointer.*;
|
||||
/**
|
||||
* Base class for OpenCL object information queries.
|
||||
* <p/>
|
||||
* All methods require the object being queried (a pointer value) and the integer parameter name.
|
||||
* All methods require the object being queried (a pointer value) and the
|
||||
* integer parameter name.
|
||||
*
|
||||
* @see Info
|
||||
*/
|
||||
abstract class InfoQuery {
|
||||
|
||||
protected abstract int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret);
|
||||
protected abstract int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret);
|
||||
|
||||
InfoQuery() {
|
||||
}
|
||||
InfoQuery() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}, converted to a boolean.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's boolean value
|
||||
*/
|
||||
boolean getBoolean(long object, int param_name) {
|
||||
return getInt(object, param_name) != 0;
|
||||
}
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}, converted
|
||||
* to a boolean.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's boolean value
|
||||
*/
|
||||
boolean getBoolean(long object, int param_name) {
|
||||
return getInt(object, param_name) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's int value
|
||||
*/
|
||||
int getInt(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, 4L, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.intValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}),
|
||||
* {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's int value
|
||||
*/
|
||||
int getInt(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, 4L, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.intValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the long value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's long value
|
||||
*/
|
||||
long getLong(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, 8L, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.longValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the long value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}),
|
||||
* {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's long value
|
||||
*/
|
||||
long getLong(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, 8L, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.longValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pointer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's pointer value
|
||||
*/
|
||||
long getPointer(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, POINTER_SIZE, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.pointerValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the pointer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or
|
||||
* 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's pointer value
|
||||
*/
|
||||
long getPointer(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, POINTER_SIZE, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.pointerValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the pointer list for the specified {@code param_name} into {@code target}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
* @param target the buffer in which to put the returned pointer list
|
||||
*
|
||||
* @return how many pointers were actually returned
|
||||
*/
|
||||
int getPointers(long object, int param_name, PointerBuffer target) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address());
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return (int)(__buffer.pointerValue(0) >> POINTER_SHIFT);
|
||||
}
|
||||
/**
|
||||
* Writes the pointer list for the specified {@code param_name} into
|
||||
* {@code target}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or
|
||||
* 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
* @param target the buffer in which to put the returned pointer list
|
||||
*
|
||||
* @return how many pointers were actually returned
|
||||
*/
|
||||
int getPointers(long object, int param_name, PointerBuffer target) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address());
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return (int) (__buffer.pointerValue(0) >> POINTER_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, param_name, __buffer);
|
||||
return __buffer.stringValueASCII(0, bytes);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be ASCII encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, param_name, __buffer);
|
||||
return __buffer.stringValueASCII(0, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.stringValueASCII(0, param_value_size);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be ASCII encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.stringValueASCII(0, param_value_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, param_name, __buffer);
|
||||
return __buffer.stringValueUTF8(0, bytes);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be UTF-8 encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, param_name, __buffer);
|
||||
return __buffer.stringValueUTF8(0, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.stringValueUTF8(0, param_value_size);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be UTF-8 encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.stringValueUTF8(0, param_value_size);
|
||||
}
|
||||
|
||||
private int getString(long object, int param_name, APIBuffer __buffer) {
|
||||
// Get string length
|
||||
int errcode = get(object, param_name, 0, NULL, __buffer.address());
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
private int getString(long object, int param_name, APIBuffer __buffer) {
|
||||
// Get string length
|
||||
int errcode = get(object, param_name, 0, NULL, __buffer.address());
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
|
||||
int bytes = (int)__buffer.pointerValue(0);
|
||||
__buffer.bufferParam(bytes);
|
||||
int bytes = (int) __buffer.pointerValue(0);
|
||||
__buffer.bufferParam(bytes);
|
||||
|
||||
// Get string
|
||||
errcode = get(object, param_name, bytes, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
// Get string
|
||||
errcode = get(object, param_name, bytes, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
|
||||
return bytes - 1; // all OpenCL char[] parameters are null-terminated
|
||||
}
|
||||
return bytes - 1; // all OpenCL char[] parameters are null-terminated
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,190 +16,209 @@ import static org.lwjgl.system.Pointer.*;
|
||||
/**
|
||||
* Base class for OpenCL object information queries.
|
||||
* <p/>
|
||||
* All methods require the object being queried (a pointer value), a second integer argument and the integer parameter name.
|
||||
* All methods require the object being queried (a pointer value), a second
|
||||
* integer argument and the integer parameter name.
|
||||
*
|
||||
* @see Info
|
||||
*/
|
||||
abstract class InfoQueryInt {
|
||||
|
||||
protected abstract int get(long pointer, int arg, int param_name, long param_value_size, long param_value, long param_value_size_ret);
|
||||
protected abstract int get(long pointer, int arg, int param_name, long param_value_size, long param_value, long param_value_size_ret);
|
||||
|
||||
InfoQueryInt() {
|
||||
}
|
||||
InfoQueryInt() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}, converted to a boolean.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's boolean value
|
||||
*/
|
||||
boolean getBoolean(long object, int arg, int param_name) {
|
||||
return getInt(object, arg, param_name) != 0;
|
||||
}
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}, converted
|
||||
* to a boolean.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's boolean value
|
||||
*/
|
||||
boolean getBoolean(long object, int arg, int param_name) {
|
||||
return getInt(object, arg, param_name) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's int value
|
||||
*/
|
||||
int getInt(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.intValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}),
|
||||
* {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's int value
|
||||
*/
|
||||
int getInt(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.intValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the long value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's long value
|
||||
*/
|
||||
long getLong(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.longValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the long value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}),
|
||||
* {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's long value
|
||||
*/
|
||||
long getLong(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.longValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pointer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's pointer value
|
||||
*/
|
||||
long getPointer(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.pointerValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the pointer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or
|
||||
* 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's pointer value
|
||||
*/
|
||||
long getPointer(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.pointerValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the pointer list for the specified {@code param_name} into {@code target}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
* @param target the buffer in which to put the returned pointer list
|
||||
*
|
||||
* @return how many pointers were actually returned
|
||||
*/
|
||||
int getPointers(long object, int arg, int param_name, PointerBuffer target) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address());
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return (int)(__buffer.pointerValue(0) >> POINTER_SHIFT);
|
||||
}
|
||||
/**
|
||||
* Writes the pointer list for the specified {@code param_name} into
|
||||
* {@code target}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or
|
||||
* 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
* @param target the buffer in which to put the returned pointer list
|
||||
*
|
||||
* @return how many pointers were actually returned
|
||||
*/
|
||||
int getPointers(long object, int arg, int param_name, PointerBuffer target) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address());
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return (int) (__buffer.pointerValue(0) >> POINTER_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueASCII(0, bytes);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be ASCII encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueASCII(0, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.stringValueASCII(0, param_value_size);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be ASCII encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, int arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.stringValueASCII(0, param_value_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueUTF8(0, bytes);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be UTF-8 encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueUTF8(0, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.stringValueUTF8(0, param_value_size);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be UTF-8 encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an integer argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, int arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.stringValueUTF8(0, param_value_size);
|
||||
}
|
||||
|
||||
private int getString(long object, int arg, int param_name, APIBuffer __buffer) {
|
||||
// Get string length
|
||||
int errcode = get(object, arg, param_name, 0, NULL, __buffer.address());
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
private int getString(long object, int arg, int param_name, APIBuffer __buffer) {
|
||||
// Get string length
|
||||
int errcode = get(object, arg, param_name, 0, NULL, __buffer.address());
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
|
||||
int bytes = (int)__buffer.pointerValue(0);
|
||||
__buffer.bufferParam(bytes + POINTER_SIZE);
|
||||
int bytes = (int) __buffer.pointerValue(0);
|
||||
__buffer.bufferParam(bytes + POINTER_SIZE);
|
||||
|
||||
// Get string
|
||||
errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
// Get string
|
||||
errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
|
||||
return bytes - 1; // all OpenCL char[] parameters are null-terminated
|
||||
}
|
||||
return bytes - 1; // all OpenCL char[] parameters are null-terminated
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,190 +16,209 @@ import static org.lwjgl.system.Pointer.*;
|
||||
/**
|
||||
* Base class for OpenCL object information queries.
|
||||
* <p/>
|
||||
* All methods require the object being queried (a pointer value), a second object argument (another pointer value) and the integer parameter name.
|
||||
* All methods require the object being queried (a pointer value), a second
|
||||
* object argument (another pointer value) and the integer parameter name.
|
||||
*
|
||||
* @see org.lwjgl.opencl.Info
|
||||
*/
|
||||
abstract class InfoQueryObject {
|
||||
|
||||
protected abstract int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret);
|
||||
protected abstract int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret);
|
||||
|
||||
InfoQueryObject() {
|
||||
}
|
||||
InfoQueryObject() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}, converted to a boolean.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's boolean value
|
||||
*/
|
||||
boolean getBoolean(long object, long arg, int param_name) {
|
||||
return getInt(object, arg, param_name) != 0;
|
||||
}
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}, converted
|
||||
* to a boolean.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's boolean value
|
||||
*/
|
||||
boolean getBoolean(long object, long arg, int param_name) {
|
||||
return getInt(object, arg, param_name) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's int value
|
||||
*/
|
||||
int getInt(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.intValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the integer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}),
|
||||
* {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's int value
|
||||
*/
|
||||
int getInt(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.intValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the long value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's long value
|
||||
*/
|
||||
long getLong(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.longValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the long value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}),
|
||||
* {@link #getPointer} should be used instead.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's long value
|
||||
*/
|
||||
long getLong(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.longValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pointer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's pointer value
|
||||
*/
|
||||
long getPointer(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.pointerValue(0);
|
||||
}
|
||||
/**
|
||||
* Returns the pointer value for the specified {@code param_name}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or
|
||||
* 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's pointer value
|
||||
*/
|
||||
long getPointer(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.pointerValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the pointer list for the specified {@code param_name} into {@code target}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
* @param target the buffer in which to put the returned pointer list
|
||||
*
|
||||
* @return how many pointers were actually returned
|
||||
*/
|
||||
int getPointers(long object, long arg, int param_name, PointerBuffer target) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address());
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return (int)(__buffer.pointerValue(0) >> POINTER_SHIFT);
|
||||
}
|
||||
/**
|
||||
* Writes the pointer list for the specified {@code param_name} into
|
||||
* {@code target}.
|
||||
* <p/>
|
||||
* This method should also be used for integer parameters that may be 32 or
|
||||
* 64 bits (e.g. {@code size_t}).
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
* @param target the buffer in which to put the returned pointer list
|
||||
*
|
||||
* @return how many pointers were actually returned
|
||||
*/
|
||||
int getPointers(long object, long arg, int param_name, PointerBuffer target) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address());
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return (int) (__buffer.pointerValue(0) >> POINTER_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueASCII(0, bytes);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be ASCII encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueASCII(0, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, long arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.stringValueASCII(0, param_value_size);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be ASCII encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringASCII(long object, long arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.stringValueASCII(0, param_value_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueUTF8(0, bytes);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be UTF-8 encoded.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, long arg, int param_name) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int bytes = getString(object, arg, param_name, __buffer);
|
||||
return __buffer.stringValueUTF8(0, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, long arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
return __buffer.stringValueUTF8(0, param_value_size);
|
||||
}
|
||||
/**
|
||||
* Returns the string value for the specified {@code param_name}. The raw
|
||||
* bytes returned are assumed to be UTF-8 encoded and have length equal to {@code
|
||||
* param_value_size}.
|
||||
*
|
||||
* @param object the object to query
|
||||
* @param arg an object argument
|
||||
* @param param_name the parameter to query
|
||||
* @param param_value_size the explicit string length
|
||||
*
|
||||
* @return the parameter's string value
|
||||
*/
|
||||
String getStringUTF8(long object, long arg, int param_name, int param_value_size) {
|
||||
APIBuffer __buffer = apiBuffer();
|
||||
int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
return __buffer.stringValueUTF8(0, param_value_size);
|
||||
}
|
||||
|
||||
private int getString(long object, long arg, int param_name, APIBuffer __buffer) {
|
||||
// Get string length
|
||||
int errcode = get(object, arg, param_name, 0, NULL, __buffer.address());
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
private int getString(long object, long arg, int param_name, APIBuffer __buffer) {
|
||||
// Get string length
|
||||
int errcode = get(object, arg, param_name, 0, NULL, __buffer.address());
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
|
||||
int bytes = (int)__buffer.pointerValue(0);
|
||||
__buffer.bufferParam(bytes + POINTER_SIZE);
|
||||
int bytes = (int) __buffer.pointerValue(0);
|
||||
__buffer.bufferParam(bytes + POINTER_SIZE);
|
||||
|
||||
// Get string
|
||||
errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL);
|
||||
if ( DEBUG )
|
||||
checkCLError(errcode);
|
||||
// Get string
|
||||
errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL);
|
||||
if (DEBUG) {
|
||||
checkCLError(errcode);
|
||||
}
|
||||
|
||||
return bytes - 1; // all OpenCL char[] parameters are null-terminated
|
||||
}
|
||||
return bytes - 1; // all OpenCL char[] parameters are null-terminated
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user