Skip to content

Instantly share code, notes, and snippets.

i->wrap_class<Child>().add_constructor("Child", i->get_object_template());
i->wrap_class<Parent>().add_constructor("Parent", i->get_object_template()).set_compatible_types<Child>();
i->wrap_class<NotFamily>().add_constructor("NotFamily", i->get_object_template());
i->add_function("parent", [](Parent * p) {
printf("In 'parent' function\n");
});
auto c = i->create_context();
c->run("parent(new Parent())");
c->run("parent(new Child())");
try {
@xaxxon
xaxxon / code.cpp
Last active February 4, 2016 06:26
#include <iostream>
#include <fstream>
#include <stdio.h>
#define USE_BOOST
using namespace std;
#define SAMPLE_DEBUG true
void Console::execute_command()
{
if (std::regex_match(this->current_line, Console::blank_line_regex)) {
printf("Skipping blank line\n");
return;
}
// static std::regex re{"^:(.*)"};
./casts.hpp:263:40: error: no matching function for call to object of type 'CastToJS<std::__1::basic_string<char> >'
(void)object->Set(context, CastToJS<T>()(isolate, pair.first), CastToJS<U>()(isolate, pair.second));
^~~~~~~~~~~~~
samples/sample.cpp:164:82: note: in instantiation of member function 'v8toolkit::CastToJS<std::__1::map<std::__1::basic_string<char>, int, std::__1::less<std::__1::basic_string<char> >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, int> > > >::operator()' requested here
add_variable(context, context->Global(), "m", CastToJS<decltype(m)>()(isolate, m));
^
*** THIS IS A GENERIC MATCH BECAUSE IT DOESNT FIND THE STRING SPECIALIZATION ***
./v8_class_wrapper.h:405:23: note: candidate function not viable: 2nd argument ('const std::__1::basic_string<char>') would lose const qualifier
v8::Local<v8::Value> operator()(
struct C (and D and E...) {
// same as B
}
class B : enable_shared_from_this<B> {
friend class A; // C has friend class B, etc..
B(){}
shared_ptr<A> parent_a;
#include <string>
using namespace std;
class Animal {
public: // everything below here can be used by everyone, not just inside this class
Animal(string input_name):name(input_name){} // **constructor**, takes a string and stores it in the new object being created
string name; // **data member**. A variable in each Animal object that stores the name
int string_length(string s)
{
int length;
length = s.length();
return length;
}
int main()
{
string my_string = "hello";
#include <SDL.h> // include SDL header
int main(int argc, char* argv[])
{
SDL_Surface *screen; // even with SDL2, we can still bring ancient code back
SDL_Window *window;
SDL_Surface *image;
SDL_Init(SDL_INIT_VIDEO); // init video
#include <SDL.h> // include SDL header
int main(int argc, char* argv[])
{
SDL_Surface *screen; // even with SDL2, we can still bring ancient code back
SDL_Window *window;
SDL_Surface *image;
SDL_Init(SDL_INIT_VIDEO); // init video
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <functional>
#include <iostream>
#include <map>
#include <vector>