Bruce, ahhh thank you, that was the missing piece of the puzzle. It works
now!

Arve

On Fri, Sep 12, 2014 at 12:05 PM, Bruce Mitchener <[email protected]
> wrote:

> You don't want to put your function inside the $RTAUDIO object.
>
> You'd just put it at top level in the LibraryRtAudio object. $RTAUDIO is
> where you'll put shared internal stuff.
>
>  - Bruce
>
>
> On Fri, Sep 12, 2014 at 9:58 AM, Arve Knudsen <[email protected]>
> wrote:
>
>> I need to write a shim for the C++ API RtAudio, i.e. the class RtAudio
>> really. Your docs show how to write shims for C APIs (e.g. SDL), but not
>> C++ APIs:
>> http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html?highlight=webidl#implement-a-c-api-in-javascript.
>> No idea how embind/webidl-binder would fit into this scenario.
>>
>> Anyhow, I wrote a (very) simple C wrapper for RtAudio, thus sidestepping
>> the C++ issue, so I can just write a C API shim. I try to implement a
>> single C function, rtaudio_initialize, in JavaScript, but it's not found by
>> the generated JavaScript (chuck.js). I can tell that the shim (or
>> JavaScript library) is used when building however, since I can have it
>> break the build by throwing an exception. Why is my JS implementation of
>> rtaudio_initialize not found??
>>
>> My shim can be seen here:
>> https://github.com/aknuds1/chuck/blob/emscripten/src/emscripten/shims/rtaudio.js,
>> and it's incorporated in the build via the --js-library option to
>> emcc: --js-library emscripten/shims/rtaudio.js.
>>
>> Thanks,
>> Arve
>>
>> On Fri, Sep 12, 2014 at 11:31 AM, Alon Zakai <[email protected]> wrote:
>>
>>> What do you mean by "shim a C++ API"? And in what way are embind and the
>>> webidl-binder not sufficient?
>>>
>>> - Alon
>>>
>>>
>>> On Thu, Sep 11, 2014 at 7:29 PM, Arve Knudsen <[email protected]>
>>> wrote:
>>>
>>>> I can't see that those docs mention how to shim a C++ API in
>>>> JavaScript? There is a section on C API though, and how to integrate your
>>>> shims, so that's helpful at least. Is it simply not possible to shim a C++
>>>> API? If so, I'll have to write a C wrapper instead I guess.
>>>>
>>>> Arve
>>>>
>>>>
>>>> On Fri, Sep 12, 2014 at 11:17 AM, Alon Zakai <[email protected]>
>>>> wrote:
>>>>
>>>>> General docs on that are at
>>>>> http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html?highlight=webidl
>>>>>
>>>>> In particular if you are going to use C++ classes from JS, you
>>>>> probably want embind or webidl-binder.
>>>>>
>>>>> - Alon
>>>>>
>>>>>
>>>>> On Thu, Sep 11, 2014 at 7:02 PM, Arve Knudsen <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi guys
>>>>>>
>>>>>> As pertaining my previous more general question about writing
>>>>>> Emscripten shims, I have a more specific follow-up question. How can I
>>>>>> write an Emscripten shim library to mimic the RtAudio C++ class 
>>>>>> constructor
>>>>>> (
>>>>>> http://www.music.mcgill.ca/~gary/rtaudio/classRtAudio.html#afd0bfa26deae9804e18faff59d0273d9)?
>>>>>> And how do I integrate said shim into my build, so that invoking the
>>>>>> constructor works? The shim will eventually need to do more than just 
>>>>>> mimic
>>>>>> the constructor of course, but that would be a superb start.
>>>>>>
>>>>>> For context, what I'm trying to do is to port the ChucK music
>>>>>> programming language to JS, my GitHub project can be found here (branch
>>>>>> emscripten): https://github.com/aknuds1/chuck/tree/emscripten. The
>>>>>> README includes instructions on how to build with Emscripten.
>>>>>>
>>>>>> Let me know if you need to know more.
>>>>>>
>>>>>> Best,
>>>>>> Arve
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "emscripten-discuss" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "emscripten-discuss" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "emscripten-discuss" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to