Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various enhancements and improvements #3

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
96f8878
Changed formatting style from Mozilla to file
verpeteren Jan 18, 2017
354c4cd
Moved files around
verpeteren Jan 18, 2017
84ddce8
Renamed output directory to cpp
verpeteren Jan 18, 2017
abe42f5
Moved idl file into idl directory
verpeteren Jan 18, 2017
70c3a38
Preparations for multiple file creation and easier setup.
verpeteren Jan 18, 2017
7d7b4d0
Automatically process all idl input files.
verpeteren Jan 18, 2017
c1abeec
Renamed example/Hello to example/Demo
verpeteren Jan 18, 2017
e14c8f1
Take the correct classname to generate the file and handle constructo…
verpeteren Jan 18, 2017
9cc4dcd
Add another demo (Fragment)
verpeteren Jan 18, 2017
91339d0
Renamed 'base_*' templates to 'impl_*'
verpeteren Jan 18, 2017
076d061
Generate the cpp code based on the template.
verpeteren Jan 18, 2017
5bb01c0
style
verpeteren Jan 18, 2017
e87c61e
Transferred research from NidiumTools:idl_classmapper branch.
verpeteren Jan 18, 2017
b92440c
Added the NidiumModule example (WIP)
verpeteren Jan 18, 2017
859a6bd
Added the Nidium example (WIP)
verpeteren Jan 18, 2017
646bb9a
Added the automatically generated idf files for Nidium.
verpeteren Jan 18, 2017
28c292c
Added more details to the README
verpeteren Jan 18, 2017
47a32fd
Added LICENSE texts
verpeteren Jan 18, 2017
a8391a6
Added Prefix to classname.
verpeteren Jan 18, 2017
347b1ac
NidiumModule 'Hello' looks good.
verpeteren Jan 18, 2017
4bdb401
Corrected several inconsistancies for static methods.
verpeteren Jan 25, 2017
12babd2
Registration process works with the Axtended Attribute 'exposed':
verpeteren Jan 25, 2017
661aeb8
Processed feedback
verpeteren Jan 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
This Software is MIT licensed but builds upon third-party libraries.

MIT License

Copyright (c) 2016 Nidium Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

###############################################################################
Nunjucks - A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
###############################################################################
Copyright (c) 2012-2015, James Long
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

###############################################################################
WebIDL2s - IDL Parse for node
###############################################################################
The MIT License (MIT)

Copyright (c) 2014 Robin Berjon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

28 changes: 0 additions & 28 deletions Makefile

This file was deleted.

41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# Generate CPP for JS based on IDL

See [WebIDL spec](http://heycam.github.io/webidl/) for details

# Usage:

Currently there are 3 example projects.
In any of these directories you can start with:

```
make
```
If not all dependencies are met, make should complain.

The idl input files are supposed to be in the 'idl' subdirectory
The generated cpp code will be written in the cpp subdirectory.

# Status

This is a work in progress, allthough the first resulst look promissing.

The following fields require more work:

* UnionType
* OtherType
* callbacks
* dictionaries
* events
* ..

# Spec

There is no final specification yet, only an rough outline that is under discussion.
Details will follow asap.

# Dependencies

executables: 'npm', 'nodejs'
NodeJs modules: 'nunjucks', 'webidl2'

# License

Copyright 2016 Nidium Inc. All rights reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file.

26 changes: 26 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2016 Nidium Inc. All rights reserved.
# Use of this source code is governed by a MIT license
# that can be found in the LICENSE file.

BIN_CLANGFORMAT := $(shell command -v clang-format-3.5 2> /dev/null)
BIN_NPM := $(shell command -v npm 2> /dev/null)
BIN_NODEJS := $(shell command -v nodejs 2> /dev/null)

ifndef BIN_CLANGFORMAT
$(error "clang-format-3.5 is not available. Please install")
endif

ifndef BIN_NPM
$(error "npm is not available. Please install")
endif

ifndef BIN_NODEJS
$(error "nodejs is not available. Please install")
endif

.PHONY: setup

setup: package.json
@$(BIN_NPM) install
@echo "All node dependencies are installed; Have a look at the examples"

1 change: 1 addition & 0 deletions examples/Demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpp
23 changes: 23 additions & 0 deletions examples/Demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2016 Nidium Inc. All rights reserved.
# Use of this source code is governed by a MIT license
# that can be found in the LICENSE file.

INPUT_DIR=./idl
OUTPUT_DIR=./cpp
IMPL_PREFIX=sm_JS_

INPUT_FILES = $(shell find $(INPUT_DIR) -type f -name '*.idl')

TARGETS = $(addprefix \
$(join $(OUTPUT_DIR)/, $(IMPL_PREFIX)), \
$(addsuffix .h, $(basename \
$(notdir $(INPUT_FILES) ) \
) \
) \
)

all: $(TARGETS)
@echo $(TARGETS)

include ../common.mk

27 changes: 27 additions & 0 deletions examples/Demo/idl/Fragment.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
exception GraphicsException {
DOMString reason;
};

interface Paint { };

interface SolidColor : Paint {
attribute float red;
attribute float green;
attribute float blue;
};

interface Pattern : Paint {
attribute DOMString imageURL;
};

[Constructor]
interface GraphicalWindow {
readonly attribute unsigned long width;
readonly attribute unsigned long height;

attribute Paint currentPaint;

void drawRectangle(float x, float y, float width, float height);

void drawText(float x, float y, DOMString text);
};
3 changes: 1 addition & 2 deletions examples/Hello.idl → examples/Demo/idl/Hello.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
};*/

[
Constructor(cstring ip, unsigned short port),
Constructor(cstring ip, (unsigned short or cstring) port),
className=Hello
] interface Hello
{
Expand All @@ -14,4 +14,3 @@

};


2 changes: 2 additions & 0 deletions examples/Nidium/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cpp

31 changes: 31 additions & 0 deletions examples/Nidium/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2016 Nidium Inc. All rights reserved.
# Use of this source code is governed by a MIT license
# that can be found in the LICENSE file.

INPUT_DIR=./idl
OUTPUT_DIR=./cpp
IMPL_PREFIX=sm_JS_

DOC_DIR = ../../..Nidium/docs
DOC2IDL=./../../NativeTools/IDL/doc2idl_transformer.py

INPUT_FILES = $(shell find $(INPUT_DIR) -type f -name '*.idl')

TARGETS = $(addprefix \
$(join $(OUTPUT_DIR)/, $(IMPL_PREFIX)), \
$(addsuffix .h, $(basename \
$(notdir $(INPUT_FILES) ) \
) \
) \
)

all: $(TARGETS)
@echo $(TARGETS)

$(OUTPUT_DIR)/$(IMPL_PREFIX)%.h: $(DOC_DIR)/%.cpp.py $(DOC2IDL)
$(DOC2IDL) $< $@

include ../common.mk



5 changes: 5 additions & 0 deletions examples/Nidium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Please note

The files in the idl directory are automatically generated based on nidiums documentation.
It is *very likely* that these will be overwritten any time.
These are only commited here, to gather some experience with IDL.
Empty file added examples/Nidium/idl/.gitignore
Empty file.
Loading