The way around that is to usually wrap the API you want to use and only
expose what you actually need. When you need something with some type of
unsupported parameter or return type, write some code around it to convert
to sensible supported types. Here is an example of what I end up doing
instead of fighting gomobile at every turn:

https://github.com/brunoga/robomaster/tree/main/sdk2/mobile

-Bruno


On Tue, Nov 28, 2023 at 10:31 AM Kevin Wang <[email protected]> wrote:

> I'm trying to build https://github.com/pion/webrtc with gomobile but I'm
> running into this error. To reproduce, clone and then run gomobile bind .
>
> gobind/go_webrtcmain.go:86:19: cannot use
> (*proxywebrtc_TrackLocal)(_param_track_ref) (value of type
> *proxywebrtc_TrackLocal) as webrtc.TrackLocal value in assignment:
> *proxywebrtc_TrackLocal does not implement webrtc.TrackLocal (missing
> method Bind)
>
> Specifically, I've tracked it down to this function signature:
> https://github.com/pion/webrtc/blob/master/rtpsender.go#L61 where it
> seems like gobind generates some code that looks like:
>
> func proxywebrtc_API_NewRTPSender(refnum C.int32_t, param_track C.int32_t,
> param_transport C.int32_t) (C.int32_t, C.int32_t) {
>         ref := _seq.FromRefNum(int32(refnum))
>         v := ref.Get().(*webrtc.API)
>         var _param_track webrtc.TrackLocal
>         _param_track_ref := _seq.FromRefNum(int32(param_track))
>         if _param_track_ref != nil {
>                 if param_track < 0 { // go object
>                         _param_track =
> _param_track_ref.Get().(webrtc.TrackLocal)
>                 } else { // foreign object
>                         _param_track =
> (*proxywebrtc_TrackLocal)(_param_track_ref)
>                 }
>         }
>
> A little bit up, it seems that it's indeed creating a proxy TrackLocal
> type but doesn't implement the interface completely
>
> type proxywebrtc_TrackLocal _seq.Ref
>
> func (p *proxywebrtc_TrackLocal) Bind_proxy_refnum__() int32 {
>         return (*_seq.Ref)(p).Bind_IncNum()
> }
>
> // skipped method TrackLocal.Bind with unsupported parameter or result
> types
>
> So I'm not surprised this can't be assigned. I guess the consequence is
> that this API can't be bound?
>
> Is it possible to have gobind skip the non-working functions with a
> comment or something? I'm not sure why gobind doesn't reject the API and
> instead crashes.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/a8351e46-9595-4693-bc6c-03f52ec1a945n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/a8351e46-9595-4693-bc6c-03f52ec1a945n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEd86Tzov%3DU1YE%2B8xOW3Ay9LoCMBbmuO22dABXoaAr5x4r7kQA%40mail.gmail.com.

Reply via email to