Git Product home page Git Product logo

lcpp's Introduction

lcpp

test my idea about lua cpp binding, this repo will not update after test finish!

usage

#include <lclass.hpp>

void func1(int a, int b, std::string c)
{
}

class Test1
{
public:
    enum
    {
        V1 = 2
    }
    Test1() {}
    Test1(int a, int b) {}
    void t1_func1(int a, int b, std::string c) {}
}

class Test2
{
public:
    static Test2 *instance()
    {
        if (!_ins) _ins = new Test2();

        return _ins;
    }
    void t2_func1(int a, int b, std::string c) {}
private:
    Test2()
    {
    }
    static Test2* _ins;
};
Test2* Test2::_ins = nullptr;

lclass::reg_global_func<&func1>("func1");

LClass<Test1> lt1(L, "Test1");
// or LClass<Test1, int, int> lt1(L, "Test1"); // using 2nd constructor
lt1.def<&Test1::t1_func1>("t1_func1");
lt1.set<Test1::V1, "V1");

LClass<Test2> lt2(L, "Test2");

Test2 *t2 = Test2::instance();
lt2.push_global(L, t2, "gt2");
func1();

local Test1 = require "Test1"
local t1 = Test1(111, 222)
t1:t1_func1();


gt2:t2_func1()

lcpp's People

Contributors

changnet avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.