All Projects → uliwitness → cpptoswift

uliwitness / cpptoswift

Licence: other
Hack that'll hopefully one day auto-generate a Swift wrapper around C++ source code.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to cpptoswift

reggie
Stata-like Regression Functionality for R
Stars: ✭ 24 (+84.62%)
Mutual labels:  work-in-progress
anisthesia
Media detection library
Stars: ✭ 32 (+146.15%)
Mutual labels:  work-in-progress
spring-boot-jpa
A Spring Boot microservices reference application using Spring Data JPA
Stars: ✭ 25 (+92.31%)
Mutual labels:  work-in-progress
PS OPNsense
PowerShell Module for OPNsense REST api
Stars: ✭ 27 (+107.69%)
Mutual labels:  work-in-progress
consul-registration-hook
Hook that can be used for synchronous registration and deregistration in Consul discovery service on Kubernetes or Mesos cluster with Allegro executor
Stars: ✭ 17 (+30.77%)
Mutual labels:  work-in-progress
slingr
A simple CLI for UPnP media file streaming
Stars: ✭ 32 (+146.15%)
Mutual labels:  work-in-progress
smalldragon
[Work in Progress] Toy Compiler <3
Stars: ✭ 23 (+76.92%)
Mutual labels:  work-in-progress
finetuneAlexVGG
Finetune ConvNets with Tensorflow
Stars: ✭ 20 (+53.85%)
Mutual labels:  work-in-progress
FSharpWrap
Utility that automatically generates F# modules and functions based on your F# project file's references
Stars: ✭ 14 (+7.69%)
Mutual labels:  work-in-progress
tangerine
A work-in-progress music player for the Nintendo 3DS and Nintendo Switch
Stars: ✭ 20 (+53.85%)
Mutual labels:  work-in-progress
bound
Data-binding made easy
Stars: ✭ 21 (+61.54%)
Mutual labels:  work-in-progress
sanzo-wada
🎨 Interactive version of Sanzo Wada's - "A Dictionary of Color Combinations"
Stars: ✭ 139 (+969.23%)
Mutual labels:  work-in-progress
ltjs
LithTech Jupiter System
Stars: ✭ 37 (+184.62%)
Mutual labels:  work-in-progress
linguistic-datasets-portuguese
Linguistic Datasets for Portuguese: Lista de conjuntos de dados linguísticos para língua portuguesa com licença flexíveis: banco de dados, lista de palavras, sinônimos, antônimos, dicionário temático, tesauro, linked data, semântica, ontologia e representação de conhecimento
Stars: ✭ 46 (+253.85%)
Mutual labels:  work-in-progress
nes-emulator
🛠 [WIP] The Nintendo Entertainment System emulator written in Rust
Stars: ✭ 12 (-7.69%)
Mutual labels:  work-in-progress
vscode-xslt-tokenizer
VSCode extension for highlighting XSLT and XPath (upto 3.0/3.1)
Stars: ✭ 37 (+184.62%)
Mutual labels:  work-in-progress
nim.nvim
Nim plugin for NeoVim
Stars: ✭ 159 (+1123.08%)
Mutual labels:  work-in-progress
Vrtk
*Beta* - An example of how to use the Tilia packages to create great content with VRTK v4.
Stars: ✭ 3,422 (+26223.08%)
Mutual labels:  work-in-progress
wip
WIP & naenae: CLI utilities to easily manage Work In Progress with Git
Stars: ✭ 46 (+253.85%)
Mutual labels:  work-in-progress
galio-starter-kit
Galio's starter kit is an app you can use to see what you can create with our library
Stars: ✭ 156 (+1100%)
Mutual labels:  work-in-progress

Hack for generating a Swift class around a C++ class. It does this by wrapping the C++ class in C and then generating a Swift class that calls this

Usage

Put the following in your prefix header or at the start of every exported C++ header:

#ifndef CP2SINIT
#define CP2SINIT
#define CP2SMETHOD
#define CP2SCLASS
#endif

(This will hide cpp2swift's markup from the C++ compiler)

Then mark up every class, constructor and method that you want to export from your class to Swift with CP2SCLASS, CP2SINIT resp. CP2SMETHOD. E.g. a simple example:

#include <stdio.h>

#ifndef CP2SINIT
#define CP2SINIT
#define CP2SMETHOD
#define CP2SCLASS
#endif


class cppclass CP2SCLASS
{
public:
	cppclass() CP2SINIT : ivar(1234)	{}
	
	void	method( int theNum ) CP2SMETHOD;
	void	method2() CP2SMETHOD { printf("yay!"); }
	
protected:
	int	ivar;
};

Then run the cpptoswift tool with your C++ header as the first argument and the path and base name (without filename suffix) you want for the output files as the second argument, E.g.:

cpptoswift mysource.hpp generated/mysource

It will generate 3 files:

generated/mysource.cpp	-	The glue code that bridges your C++ class to C.
generated/mysource.h	-	A header that you should include from your
							Swift app's bridging header.
generated/mysource.swift-	A Swift class that calls the functions declared
							and defined by the other two files to create and
							destruct the C++ object.

Note that this software is a work in progress and might not fully work, especially as C++ code becomes more complex.

It is recommended that you put all the generated code in a framework, which can then have its own bridging header, leaving your actual project that uses the Swift wrapper free from C++ and C, and mostly ignorant of the C++ code's internal file structure.

License

Copyright 2015 by Uli Kusterer.

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source
distribution.

The source code files generated by this software based on your files are exempt from this license and are subject to whatever original license the input files were under.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].