Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Pavel Medvedev
    @pmed
    Yes, it would be great to have the CMake support. Pull requests are welcomed! :)
    while the library can be mostly used as a header-only, it would be good to have CMake support for quick starting with examples or tests
    Alexey Zasenko
    @0xDAD
    Also, cmake config file could help easily embed and customize the library into user projects. Thanks. Will make request if have something interesting
    Pavel Medvedev
    @pmed
    Super, thanks!
    Alexey Zasenko
    @0xDAD
    Got linking error in case of using v8pp::context and V8PP_HEADER_ONLY defined. Was it intended not to use contexts in header-only implementation? Or maybe I did smth wrong? Thanks
    Alexey Zasenko
    @0xDAD
    error LNK2019: unresolved external symbol "public: __thiscall v8pp::context::context(class v8::Isolate *,class v8::ArrayBuffer::Allocator *,bool)" (??0context@v8pp@@QAE@PAVIsolate@v8@@PAVAllocator@ArrayBuffer@3@_N@Z) 
    error LNK2019: unresolved external symbol "public: __thiscall v8pp::context::~context(void)" (??1context@v8pp@@QAE@XZ)
    Adding context.cpp to the project solves the problem.
    Pavel Medvedev
    @pmed
    This v8pp::context is used mostly for test and in a couple of projects those had V8 embedded. Intent for V8PP_HEADER_ONLY was to use the library without installation in projects for Node.js native add-ons. There you could just add the library as an NPM dependency in package.json. See also these comments: https://github.com/pmed/v8pp/issues/75#issuecomment-397034400 https://github.com/pmed/v8pp/issues/75#issuecomment-397249100
    Alexey Zasenko
    @0xDAD
    Got it. I'm trying to use the library for wrapping business objects for V8 engine embedded into my app. I found it quite straightforward and cppish) Thanks for your time and for sharing!
    Pavel Medvedev
    @pmed
    You are welcome! I've created this library for one similar, so v8pp was designed from requirements to that project.
    David Warford
    @redstonedash
    Hello. I am confused on how I am supposed to include v8 into my project. do i just add the v8pp directory as an include directory?
    David Warford
    @redstonedash
    also all the examples seem to include node.h but i don't have a node.h
    Pavel Medvedev
    @pmed
    Hello! This library is a wrapper for V8, that should also be a dependency in your project. Please refer the V8 documentation how to embed it into your project. And yes, v8pp is a header-only library, so you can add its v8pp subdirectory into your project includes path.
    v8pp/examples contains native Node.js addons, implemented with v8pp. You could read how to build the native Node.js in the Node.js documentation: https://nodejs.org/dist/latest-v12.x/docs/api/addons.html#addons_building
    David Warford
    @redstonedash
    oh. i guess i was misinformed. somone said this game with the v8 binaries and thats why i was trying to use it because building v8 was a struggle for me
    Pavel Medvedev
    @pmed
    Here is also some documentation in v8pp: https://github.com/pmed/v8pp/blob/master/docs/addons.md
    Pavel Medvedev
    @pmed
    ok, v8 building is not a trivial task. I've made a project to build V8 on windows into a NuGet package: https://github.com/pmed/v8-nuget
    Artur
    @S0PEX

    Hey, this is a bit ramdom but do you know how to convert a v8::Context* to v8::Local<v8::Context> ? I am currently extending an application and it only provides a pointer to the context and isolation, so my current workaround is

    // We need to enter the panel context as it has all the api
    panelContext->Enter();
    
    // Get the current entered context
    const auto context = isolate->GetCurrentContext();
    v8::Context::Scope context_scope { context };
    
    const v8::TryCatch tryCatch { isolate };
    
    // Create a string containing the JavaScript source code.
    const auto source = v8::String::NewFromUtf8(isolate, js_code, v8::NewStringType::kNormal).ToLocalChecked();
    
    // Compile the source code.
    auto script = v8::Script::Compile(context, source).ToLocalChecked();

    This is very unclean as I am just entering the context to get the v8::Local version of it.

    Pavel Medvedev
    @pmed
    Hi @S0PEX, sorry I have no idea. Yea, it seems not very clean and a bit strange to have only a raw pointer a V8 object without Local handle. It might luckily work because the panelContext is alive in the isolate.
    Artur
    @S0PEX
    Yeah I think thats the case. Thanks anyway.
    kapilpipaliya
    @kapilpipaliya
    I have std::unordered_map<std::shared<Request>, std::string>how to register it to v8?
    Pavel Medvedev
    @pmed
    Hi @kapilpipaliya, you could start from the documentation at https://github.com/pmed/v8pp/blob/master/docs/index.md
    kapilpipaliya
    @kapilpipaliya
    Thank you so much.
    kapilpipaliya
    @kapilpipaliya
    How to import npm modules in v8?
    GutZuFusss
    @GutZuFusss
    Hello there! I am very interested in using v8pp to bind v8 to my project... I have a few questions left, is this the right place to ask?
    Pavel Medvedev
    @pmed
    Hi! yes, you can ask the questions here, or create issues on the project Github
    GutZuFusss
    @GutZuFusss
    So I have a problem binding v8 itself when compiling with MinGW-W64 (MSVC works fine...). The error output I get is the following:
    Z:/Repositories/CDXX/other/v8/include/v8.h:7807:5: error: typedef 'v8::UnhandledExceptionCallback' is initialized (use decltype instead) _EXCEPTION_POINTERS* exception_pointers); ^~~~~~~~~~~~~~~~~~~ Z:/Repositories/CDXX/other/v8/include/v8.h:7807:5: error: '_EXCEPTION_POINTERS' was not declared in this scope Z:/Repositories/CDXX/other/v8/include/v8.h:7807:5: note: suggested alternative: 'EXCEPTION_UNWINDING' _EXCEPTION_POINTERS* exception_pointers); ^~~~~~~~~~~~~~~~~~~ EXCEPTION_UNWINDING Z:/Repositories/CDXX/other/v8/include/v8.h:7807:26: error: 'exception_pointers' was not declared in this scope _EXCEPTION_POINTERS* exception_pointers); ^~~~~~~~~~~~~~~~~~ Z:/Repositories/CDXX/other/v8/include/v8.h:7807:26: note: suggested alternative: 'exception_code' _EXCEPTION_POINTERS* exception_pointers); ^~~~~~~~~~~~~~~~~~ exception_code Z:/Repositories/CDXX/other/v8/include/v8.h:9707:7: error: 'UnhandledExceptionCallback' has not been declared UnhandledExceptionCallback unhandled_exception_callback); ^~~~~~~~~~~~~~~~~~~~~~~~~~
    sorry, gitter did not seem to like the linebreaks!
    I use the precompiled libraries from your v8-nuget repository
    GutZuFusss
    @GutZuFusss
    I installed the libraries with msys and it works now! thanks anyways
    Pavel Medvedev
    @pmed
    Yeah, v8 building might be not an easy task, especially on Windows. That's the reason I've created the v8-nuget project. Actually I've never tried to build v8 with anything else Visual C++. And as far as I remember, there are some build errors with the recent v8 versions in v8-nuget build.py script
    GutZuFusss
    @GutZuFusss
    I am now trying to bind a function, but i get Check failed: !value_obj->IsJSReceiver() || value_obj->IsTemplateInfo() and the program crashes
    my code:
    without the ..set("print", GameConsolePrint) it works fine
    Pavel Medvedev
    @pmed
    It seems that v8 expects GameConsolePrint should be a FunctionTemplate. Would it help, to bind the print function directly, as a lambda
    E.g.
    GameConsole.set("print", [](){ CV8Test::m_pCGameClient->Console()->Print(); });
    GutZuFusss
    @GutZuFusss
    Thanks a lot, that works!
    Hrnkas
    @Hrnkas

    I get unresolved external symbol in VS2019 Community:
    Console Application
    #include <v8pp/context.hpp>
    #include <libplatform/libplatform.h>
    #include <v8.h>

    v8pp.lib(context.obj) : error LNK2019: unresolved external symbol "public: static class v8::Local<class v8::FunctionTemplate> cdecl v8::FunctionTemplate::New(class v8::Isolate *,void (cdecl)(class v8::FunctionCallbackInfo<class v8::Value> const &),class v8::Local<class v8::Value>,class v8::Local<class v8::Signature>,int,enum v8::ConstructorBehavior,enum v8::SideEffectType)" (?New@FunctionTemplate@v8@@SA?AV?$Local@VFunctionTemplate@v8@@@2@PAVIsolate@2@P6AXABV?$FunctionCallbackInfo@VValue@v8@@@2@@ZV?$Local@VValue@v8@@@2@V?$Local@VSignature@v8@@@2@HW4ConstructorBehavior@2@W4SideEffectType@2@@Z) referenced in function "public: __thiscall v8pp::context::context(class v8::Isolate ,class v8::ArrayBuffer::Allocator *,bool,bool)" (??0context@v8pp@@QAE@PAVIsolate@v8@@PAVAllocator@ArrayBuffer@3@_N2@Z)

    v8pp is compiled using same vs2019 version - no errors - all tests passing

    v8pp.lib ist included in linker settings as additional dependency

    Hrnkas
    @Hrnkas
    Here is my code: https://pastebin.com/mPh7XcH6
    As you see, I am not yet using any v8 Functionality, except for binding and initializing / shutdown.
    here are my Configuration properties -> C/C++: https://pastebin.com/zKDzZk6D
    and my linker Settings: https://pastebin.com/0TPxFX9X
    Hrnkas
    @Hrnkas
    Found solution: I installed the newest version (8.4.371.15) of the NuGet package for v142 (VC2019) - after downgrading to 7.5.288.23 it compiles without errors.
    Maybe you could set Version 8 as beta, to prevent such issues.
    GutZuFusss
    @GutZuFusss
    Hi everyone, I was wondering if any of you know any examples bigger than the v8 "hello world" ones, but not as overwhelming as node.js... I find it quite difficult to grasp the design patterns intended by the v8 devs, splitting my code up into classes gives mit trouble I can only overcome with massive hacks.
    GutZuFusss
    @GutZuFusss
    preferrably a setup where multiple scripts run in parallel (if thats even possible with one isolate). I want to do something like a plugin system for a game, maybe also just tell me if thats bullshit haha
    GutZuFusss
    @GutZuFusss
    does it make sense from a ressource management standpoint to have multiple isolates in parallel, if i expect to run say 20-50 scripts in parallel? should i maybe only have one isolate and manage scripts JS sided? Sorry, the documentation on all these things is pretty thin.
    Hrnkas
    @Hrnkas
    @GutZuFusss I don't know that much about v8 itself (just starting myself), but when I am concerned about performance of two different options, then I build a rough prototype and test both options.
    In your case, just spin up 50 isolates and see what cpu and ram do. If the ressource usage explodes, than maybe you are better off implementing different "threads" in the js. Just start a bunch of async functions (promises) and see how that works. My gut tells me that first option with multiple isolates will be faster, but use more memory in comparison to js solution.
    Yoj have to decide what works for you
    Hrnkas
    @Hrnkas
    What is the proper strategy to initialize isolate with all c++ function and class binding? I do not want to execute all binding boilerplate each time when I instantiate an isolate. Is there a possibility to do that only once, so that all new isolates have the same binding? Can a isolate be copied?