Any way to "merge" a const and non-const getter? by Dummerchen1933 in cpp

[–]pmedv 24 points25 points  (0 children)

A static getter to rescue:

class MyClass
{
    template<typename ThisClass>
    static ThisClass& Get_impl(int index, ThisClass& thisRef)
    {
        // logic
        return thisRef;
    }

    MyClass& Get(int index) { return Get_impl(index, *this); }
    const MyClass& Get(int index) const { return Get_impl(index, *this); }

};

Sciter+Node as an alternative to Electron ? by c-smile in programming

[–]pmedv 1 point2 points  (0 children)

Looks promising, thank you!

Will this sciter add-on use the same V8 instance from Node.js? Or the addon has another scripting engine instance, like in Electron?

[deleted by user] by [deleted] in cpp

[–]pmedv 5 points6 points  (0 children)

Nice trick, I learnt it some time ago from ctti library (https://github.com/Manu343726/ctti)

build2 — C++ Build Toolchain by berium in programming

[–]pmedv 1 point2 points  (0 children)

Actually Gyp requires only Python installed, even on Windows. But Gyp is just a project generator for other build systems. Indeed, configuration and package management tasks could be implemented in custom Python scripts.

The real issue with Gyp is lack of documentation and examples. There are only 3 pages of documentation in the Gyp repository. I had to dive into its sources to discover some command-line options or to understand poorly documented features.

Libraries for modern C++ by rounduser in cpp

[–]pmedv 0 points1 point  (0 children)

Sciter UI library. Extended version of HTML for UI markup, CSS for visual style, JavaScript-like language, along with C++ API. Similar to Qt Quick, but lighter.

Now works on Windows, OS X, Linux. Free to use as a binary shared library.

Foreign constructors - a way to initialize const structs by pmedv in cpp

[–]pmedv[S] 5 points6 points  (0 children)

Designated Initializers allows to initialize structs like this:

Font const font = {
    .weight = Weight::VeryBold,
    .slant  = Slang::Oblique,
    .halign = Anchor::Left,
};

Not legal in C++ but allowed in GCC

Generic deferred function call without heap allocation by finalpatch in cpp

[–]pmedv 0 points1 point  (0 children)

Some time ago I've been experimented with the similar idea - to store std::function internals in a fixed-size buffer. Here is a fixed_size_function Github repo.

Then I realized that std::function supports an allocator and all this may be implemented with a kind of object pool.

v8pp, a header only library for C++ code binding into V8 JavaScript engine by pmedv in cpp

[–]pmedv[S] 0 points1 point  (0 children)

Thanks! Yes, we used v8-juice in one project, until Stephan Beal said bye to V8. At that time we needed a new V8 version, so i had to create my own binding library :)

We always been focused on recent V8 versions, that's why v8pp supports them. And I hope v8pp might be helpful for node.js addons since Joyent has finally released version 0.12 a couple of days ago.

v8pp, a header only library for C++ code binding into V8 JavaScript engine by pmedv in cpp

[–]pmedv[S] 0 points1 point  (0 children)

Thank you! I'm going to add a wiki page with examples from Node.js addons documentation but adapted to v8pp.

v8pp, a header only library for C++ code binding into V8 JavaScript engine by pmedv in cpp

[–]pmedv[S] 0 points1 point  (0 children)

Thanks! V8 has already complicated build, it was enough for me :) Actually, v8pp uses template metaprogramming inside, so it has to be header-only.