Last active
August 19, 2017 20:50
-
-
Save veryjos/e8dc755cbea575f527558c36da7652c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------------------------------- | |
// Copyright (C) Microsoft. All rights reserved. | |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | |
//------------------------------------------------------------------------------------------------------- | |
#include "main.hpp" | |
#include "MetaPlug.hpp" | |
#include "ChakraCore.h" | |
int main() | |
{ | |
// ... Initialize ChakraCore | |
// Initialize CurryChakra bindings | |
CC::InitializeBindings(); | |
auto result = RunScript(R"( | |
( | |
() => { | |
let test = new TestClass(1.5, 2.5); | |
test.x += 12; | |
test.PrintSelf(); | |
return test.x; | |
} | |
)() | |
)"); | |
printf("Result -> %f\n", result->AsFloat()); | |
// ... Cleanup ChakraCore | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <cstdio> | |
#include "MetaPlug.hpp" | |
Meta(CC::Bind) // V Pure mix-in parent doens't bloat instance size with a vtable and has no valid downcast | |
class TestClass : public CC::JsBound { | |
public: | |
Meta(CC::Bind) | |
TestClass(float x, float y) : | |
x(x), y(y) {}; | |
Meta(CC::Bind) | |
void PrintSelf() { | |
printf("Native method PrintSelf() called\n"); | |
printf("%f\n", x); | |
printf("%f\n", y); | |
}; | |
Meta(CC::Bind) | |
float x; | |
Meta(CC::Bind) | |
float y; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Native method PrintSelf() called | |
13.500000 | |
2.500000 | |
Result -> 13.5 | |
test: 1.000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment