Miroslav Sobotka
11/26/2022, 10:12 AM.toShort()
every time I use it.
Options: redefine each constant directly in the def file or subsequently in the kotlin code.黄文和
11/26/2022, 11:01 AMMiroslav Sobotka
11/26/2022, 11:28 AM.convert()
helps me because I don't need to know what the type of the constant is, but it doesn't solve the problem I have (maybe I wasn't very precise): the constant is always used as a Short Integer, so I don't have to convert it to the correct type every time.
I'm looking for a solution where I can specify the type of the constant. Ideally without having to redefine all types in the def / kt file.黄文和
11/26/2022, 11:31 AMMiroslav Sobotka
11/26/2022, 11:52 AMsql.h and sqlucode.h
./sql.h:117:#define SQL_DIAG_RETURNCODE 1
./sql.h:118:#define SQL_DIAG_NUMBER 2
./sql.h:119:#define SQL_DIAG_ROW_COUNT 3
./sql.h:120:#define SQL_DIAG_SQLSTATE 4
./sql.h:121:#define SQL_DIAG_NATIVE 5
./sql.h:122:#define SQL_DIAG_MESSAGE_TEXT 6
./sql.h:123:#define SQL_DIAG_DYNAMIC_FUNCTION 7
./sql.h:124:#define SQL_DIAG_CLASS_ORIGIN 8
./sql.h:125:#define SQL_DIAG_SUBCLASS_ORIGIN 9
./sql.h:126:#define SQL_DIAG_CONNECTION_NAME 10
./sqlucode.h:136:SQLRETURN SQL_API SQLGetDiagRecW(
./sqlucode.h-137- SQLSMALLINT fHandleType,
./sqlucode.h-138- SQLHANDLE handle,
...
knm file
public const val SQL_DIAG_INSERT: <http://kotlin.Int|kotlin.Int> /* compiled code */
public const val SQL_DIAG_MESSAGE_TEXT: <http://kotlin.Int|kotlin.Int> /* compiled code */
public const val SQL_DIAG_NATIVE: <http://kotlin.Int|kotlin.Int> /* compiled code */
public const val SQL_DIAG_NUMBER: <http://kotlin.Int|kotlin.Int> /* compiled code */
public const val SQL_DIAG_RETURNCODE: <http://kotlin.Int|kotlin.Int> /* compiled code */
public const val SQL_DIAG_REVOKE: <http://kotlin.Int|kotlin.Int> /* compiled code */
public const val SQL_DIAG_ROW_COUNT: <http://kotlin.Int|kotlin.Int> /* compiled code */
@kotlinx.cinterop.internal.CCall public external fun SQLGetDiagRecW(fHandleType: unixODBC.SQLSMALLINT /* = kotlin.Short */, handle: unixODBC.SQLHANDLE? /* = kotlinx.cinterop.CPointer<out kotlinx.cinterop.CPointed>? */, iRecord: unixODBC.SQLSMALLINT /* = kotlin.Short */, szSqlState: kotlinx.cinterop.CValuesRef<unixODBC.SQLWCHARVar /* = kotlinx.cinterop.UShortVarOf<kotlin.UShort> */>?, pfNativeError: kotlinx.cinterop.CValuesRef<unixODBC.SQLINTEGERVar /* = kotlinx.cinterop.IntVarOf<kotlin.Int> */>?, szErrorMsg: kotlinx.cinterop.CValuesRef<unixODBC.SQLWCHARVar /* = kotlinx.cinterop.UShortVarOf<kotlin.UShort> */>?, cbErrorMsgMax: unixODBC.SQLSMALLINT /* = kotlin.Short */, pcbErrorMsg: kotlinx.cinterop.CValuesRef<unixODBC.SQLSMALLINTVar /* = kotlinx.cinterop.ShortVarOf<kotlin.Short> */>?): unixODBC.SQLRETURN /* = kotlin.Short */ { /* compiled code */ }
kotlin code
SQLGetDiagRecW(SQL_HANDLE_STMT.convert(), ...
Miroslav Sobotka
11/26/2022, 11:55 AMSQL_DIAG_RETURNCODE
is a type of SQLSMALLINT
which is type of kotlin.Short