By the way, I already have some functionality completed. WebSockets, for 
example, now works 100% from C++ (actually I stole and improved some code 
from an old game I had written that I wanted to release on WIndows, Linux, 
Web).
On Saturday, May 13, 2023 at 1:55:08 AM UTC-4 Nicholas Ingrassellino wrote:

> I have been looking at Embind for the last few days. Thank you for the 
> suggestion but I do not think it is what I am looking for (although I could 
> be wrong there, there is so much reading to learn from).
>
> Really my problem boils down to this: I want to create and manage the HTML 
> elements (I am not interested in Canvas) via C++ in order to create a new 
> head-only library that is the jQuery for C++/Emscripten. This is my goal, 
> any way. Going to be real slow going since I am only one guy (will invite 
> pull requests once I am happy with it). Especially if I remain stuck for a 
> while here.
>
> Thanks for any help and/or pointing me to more information!
> On Friday, May 12, 2023 at 8:00:07 PM UTC-4 s...@google.com wrote:
>
>> Your code looks like it will correctly create the element but you cannot 
>> return a JS object to native code like that.   
>>
>> You can only return basic types like numbers unless you use some kind of 
>> higher level binding system such as embind. 
>>
>> See 
>> https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
>>  
>> for more information on connecting the JS and C++ worlds.
>>
>> On Fri, May 12, 2023 at 4:22 PM Nicholas Ingrassellino <nick...@gmail.com> 
>> wrote:
>>
>>>
>>> Sorry, I do not see an edit button but I made a mistake. Here is the 
>>> correction:
>>> It spits out emscgT �� which I thought was a good sign. Turns out trying 
>>> to create two different elements at two different times always says that 
>>> when cast to either void* or char* (all over types just give me 0).
>>> On Friday, May 12, 2023 at 6:53:40 PM UTC-4 Nicholas Ingrassellino wrote:
>>>
>>>> Good morning all! Or good afternoon or have a great night. You know, 
>>>> wherever you are.
>>>>
>>>> I have the following code:
>>>> void* createElement( const char* type ) {
>>>>     return EM_ASM_PTR( {
>>>>         return document.createElement( UTF8ToString( $0 ) );
>>>>     }, type );
>>>> };
>>>>
>>>> I am calling it like this:
>>>> std::cout << static_cast< char* >( cppquery::html::createElement( "div" 
>>>> ) ) << std::endl;
>>>>
>>>> It spits out emscgT �� which I thought was a good sign. Turns out 
>>>> trying to create two different elements at two different times always says 
>>>> that when cast to anything other than either void* or char*.
>>>>
>>>> What I am trying to do is crate an element (not yet added to the DOM), 
>>>> store whatever (a pointer, I guess) to it, and use it later with other 
>>>> C++-stored JavaScript element objects.
>>>>
>>>> I could just do all the work on the JavaScript side and JSON.stringyify 
>>>> everything but that sounds like way too much.
>>>>
>>> -- 
>>> 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 emscripten-disc...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/emscripten-discuss/caeb2610-9aaa-4c30-8d4a-4feaad7a0f0en%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/emscripten-discuss/caeb2610-9aaa-4c30-8d4a-4feaad7a0f0en%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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 emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/da3825ea-1ce2-4264-b631-974581ecc6adn%40googlegroups.com.

Reply via email to