Coder Social home page Coder Social logo

bicomc's Introduction

BiCOMC

License Travis CI AppVeyor CircleCI Gitlab CI

Binary Compatibility Object Model for C++ (BiCOMC) is library for surporting binary compatibility to C++ classes.

Requirements

  • C++ 03 or higher support
  • __VA_ARGS__ support
  • SFINAE support

How to link your project

In general

Just add include to the include directory path.

In CMake 2.8.8 or higher

  1. Move to directory of BiCOMC

  2. Install BiCOMC (just once)

    mkdir build && cd build
    cmake ..
    cmake --build . --target install
  3. Link BiCOMC to your project

    find_package(BiCOMC CONFIG REQUIRED)
    add_executable(YourTarget ...) # or add_library(...)
    target_link_libraries(YourTarget BiCOMC)

In CMake all versions

  1. Check the absolute path of include

  2. Include the path to your project using include_directories

    include_directories("path/of/bicomc/include")
    add_executable(YourTarget ...) # or add_library(...)

How to use

To define interface

// iprinter.h
#pragma once
#include <bicomc/object.h>
BICOMC_INTERFACE(IPrinter)
	BICOMC_DECL_METHOD(print, void(char const* message), 1)
BICOMC_INTERFACE_END(IPrinter)

To implement interface

// printer.h
#pragma once
#include <iostream>
#include "iprinter.h"
class Printer : public IPrinter {
	BICOMC_OVERRIDE(IPrinter)
		BICOMC_OVER_METHOD(print, void(char const*))
	BICOMC_OVERRIDE_END(IPrinter)
public:
	Printer() : BICOMC_OVERRIDE_INIT() {}
	void print(char const* message) {
		std::cout << message;
	}
};

To instantiate, cast, and call

// main.cpp
#include "printer.h"
int main() {
	bcc::Object* p = new Printer();
	IPrinter& printer = bicomc_cast<IPrinter&>(*p);
	printer.print("Hellow world!!");
	p->destroy(); // as a 'delete p'
	return 0;
}

License

BiCOMC is distributed under the Apache License 2.0 and it uses open source softwares shown in the NOTICE file.

bicomc's People

Contributors

yudonguk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.