package nosqldb_sdk import ( "C" ) import ( "fmt" "strings" "unsafe" "github.com/oracle/nosql-go-sdk/nosqldb" "nosql_db_sdk_ffi/util/ptrproxy" ) //export ffi_nosqldb_table_request_new func ffi_nosqldb_table_request_new() NosqldbTableRequest { treq := nosqldb.TableRequest{} return NosqldbTableRequest(ptrproxy.Ref(unsafe.Pointer(&treq))) } //export ffi_nosqldb_table_request_debug func ffi_nosqldb_table_request_debug(unsafe_nosqldb_table_request_ptr NosqldbTableRequest) Error { nosqldb_table_request_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_table_request_ptr)) if !ok { return C.CString("NosqldbTableRequestPtr cannot deref") } table_request := (*nosqldb.TableRequest)(nosqldb_table_request_ptr) fmt.Printf("client: %v\n", table_request) return nil } const ( statement = iota tablename ) //export ffi_nosqldb_table_request_set func ffi_nosqldb_table_request_set(unsafe_nosqldb_table_request_ptr NosqldbTableRequest, key C.uint, value string) Error { nosqldb_table_request_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_table_request_ptr)) if !ok { return C.CString("NosqldbTableRequestPtr cannot deref") } table_request := (*nosqldb.TableRequest)(nosqldb_table_request_ptr) value_cpy := strings.Clone(value) switch key { case statement: table_request.Statement = value_cpy //println("Statement:", table_request.Statement) case tablename: table_request.TableName = value_cpy //println("TableName:", table_request.TableName) default: return C.CString("invalid key") } return nil } //export ffi_nosqldb_table_request_set_table_limits func ffi_nosqldb_table_request_set_table_limits(unsafe_nosqldb_table_request_ptr NosqldbTableRequest, unsafe_nosqldb_table_limits_ptr NosqldbTableLimits) Error { nosqldb_table_request_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_table_request_ptr)) if !ok { return C.CString("NosqldbTableRequestPtr cannot deref") } treq := (*nosqldb.TableRequest)(nosqldb_table_request_ptr) nosqldb_table_limits_ptr, ok := ptrproxy.Move(unsafe.Pointer(unsafe_nosqldb_table_limits_ptr)) if !ok { return C.CString("NosqldbTableLimitsPtr cannot deref") } tlmts := (*nosqldb.TableLimits)(nosqldb_table_limits_ptr) treq.TableLimits = tlmts return nil } //export ffi_nosqldb_delete_request_debug func ffi_nosqldb_delete_request_debug(unsafe_nosqldb_delete_request_ptr NosqldbDeleteRequest) Error { nosqldb_delete_request_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_delete_request_ptr)) if !ok { return C.CString("NosqldbDeleteRequestPtr cannot deref") } dltrs := (*nosqldb.DeleteRequest)(nosqldb_delete_request_ptr) fmt.Printf("delete_table_request: %v\n", dltrs) return nil } //export ffi_nosqldb_delete_request_clone func ffi_nosqldb_delete_request_clone(unsafe_nosqldb_delete_request_ptr NosqldbDeleteRequest) (NosqldbDeleteRequest, Error) { nosqldb_delete_request_value_ptr, ok := ptrproxy.Deref(unsafe.Pointer(unsafe_nosqldb_delete_request_ptr)) if !ok { return nil, C.CString("NosqldbDeleteRequestPtr cannot deref") } delete_request := (*nosqldb.DeleteRequest)(nosqldb_delete_request_value_ptr) copy := *delete_request return NosqldbDeleteRequest(ptrproxy.Ref(unsafe.Pointer(©))), nil }