forked from enlightenment/efl
Added beginning of eina js generator
This commit is contained in:
parent
92681d602f
commit
a5d3406a11
|
@ -80,6 +80,8 @@ include Makefile_Eo_Cxx.am
|
|||
include Makefile_Efl_Cxx.am
|
||||
|
||||
include Makefile_Eina_Js.am
|
||||
include Makefile_Evas_Js.am
|
||||
include Makefile_Eolian_Js.am
|
||||
|
||||
include Makefile_Elua.am
|
||||
include Makefile_Elocation.am
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
|
||||
### Binary
|
||||
if HAVE_CXX11
|
||||
|
||||
bin_PROGRAMS += bin/eolian_js/eolian_js
|
||||
|
||||
bin_eolian_js_eolian_js_SOURCES = \
|
||||
bin/eolian_js/main.cc
|
||||
|
||||
bin_eolian_js_eolian_js_CXXFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
-I$(top_srcdir)/src/bin/eolian_js \
|
||||
@CHECK_CFLAGS@ @EINA_CFLAGS@ @EINA_CXX_CFLAGS@ @EO_CFLAGS@ \
|
||||
@EOLIAN_CXX_CFLAGS@ @EOLIAN_CFLAGS@
|
||||
|
||||
bin_eolian_js_eolian_js_LDADD = @CHECK_LIBS@ @USE_EOLIAN_LIBS@
|
||||
|
||||
bin_eolian_js_eolian_js_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
|
||||
|
||||
include Makefile_Eolian_Js_Helper.am
|
||||
|
||||
### Library
|
||||
|
||||
lib_LTLIBRARIES += bindings/eolian_js/libeolian_js.la
|
||||
|
||||
bindings_eolian_js_libeolian_js_la_SOURCES =\
|
||||
bindings/eolian_js/main.cc \
|
||||
$(generated_evas_canvas_js_bindings)
|
||||
|
||||
bindings_eolian_js_libeolian_js_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
@EINA_CFLAGS@ \
|
||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_js\" \
|
||||
@VALGRIND_CFLAGS@
|
||||
|
||||
bindings_eolian_js_libeolian_js_la_LIBADD = @EINA_LIBS@ @DL_LIBS@
|
||||
bindings_eolian_js_libeolian_js_la_DEPENDENCIES = @EINA_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@
|
||||
bindings_eolian_js_libeolian_js_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
|
||||
|
||||
### Unit tests
|
||||
|
||||
if EFL_ENABLE_TESTS
|
||||
|
||||
# check_PROGRAMS += tests/eolian_cxx/eolian_cxx_suite
|
||||
# TESTS += tests/eolian_cxx/eolian_cxx_suite
|
||||
|
||||
# tests_eolian_cxx_eolian_cxx_suite_SOURCES = \
|
||||
# tests/eolian_cxx/eolian_cxx_suite.cc \
|
||||
# tests/eolian_cxx/eolian_cxx_test_parse.cc \
|
||||
# tests/eolian_cxx/callback.c \
|
||||
# tests/eolian_cxx/eolian_cxx_test_callback.cc \
|
||||
# tests/eolian_cxx/eolian_cxx_test_generate.cc
|
||||
|
||||
# tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-eolian_cxx_test_callback.$(OBJEXT): tests/eolian_cxx/callback.eo.hh
|
||||
|
||||
# tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-callback.$(OBJEXT): tests/eolian_cxx/callback.eo.c tests/eolian_cxx/callback.eo.h
|
||||
|
||||
# CLEANFILES += tests/eolian_cxx/callback.eo.hh tests/eolian_cxx/callback.eo.c tests/eolian_cxx/callback.eo.h
|
||||
|
||||
# tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS = \
|
||||
# -I$(top_builddir)/src/lib/efl \
|
||||
# -I$(top_srcdir)/src/bin/eolian_cxx \
|
||||
# -I$(top_builddir)/src/tests/eolian_cxx \
|
||||
# -DTESTS_WD=\"`pwd`\" \
|
||||
# -DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_cxx\" \
|
||||
# -DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_cxx\" \
|
||||
# -DPACKAGE_DATA_DIR=\"$(datadir)/eolian_cxx\" \
|
||||
# -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_cxx\" \
|
||||
# @CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_CXX_CFLAGS@ \
|
||||
# @EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@ @ECORE_CFLAGS@ \
|
||||
# @EO_CXX_CFLAGS@
|
||||
|
||||
# tests_eolian_cxx_eolian_cxx_suite_CFLAGS = ${tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS}
|
||||
# tests_eolian_cxx_eolian_cxx_suite_CPPFLAGS = ${tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS}
|
||||
# tests_eolian_cxx_eolian_cxx_suite_LDADD = \
|
||||
# @CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@
|
||||
# tests_eolian_cxx_eolian_cxx_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
|
||||
|
||||
endif
|
||||
|
||||
#EXTRA_DIST += tests/eolian_cxx/callback.eo
|
||||
|
||||
endif
|
|
@ -0,0 +1,18 @@
|
|||
#if HAVE_EOLIAN_JS
|
||||
#EOLIAN_JS = @eolian_js@
|
||||
#_EOLIAN_JS_DEP = @eolian_js@
|
||||
#else
|
||||
EOLIAN_JS = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/eolian_js/eolian_js${EXEEXT}
|
||||
_EOLIAN_JS_DEP = bin/eolian_js/eolian_js${EXEEXT}
|
||||
#endif
|
||||
|
||||
AM_V_EOLJS = $(am__v_EOLJS_@AM_V@)
|
||||
am__v_EOLJS_ = $(am__v_EOLJS_@AM_DEFAULT_V@)
|
||||
am__v_EOLJS_0 = @echo " EOLJS " $@;
|
||||
|
||||
SUFFIXES += .eo.js.cc
|
||||
|
||||
%.eo.js.cc: %.eo $(_EOLIAN_JS_DEP)
|
||||
$(AM_V_EOLJS)$(EOLIAN_JS) $(EOLIAN_FLAGS) -o $@ $<
|
||||
|
||||
CLEANFILES += $(BUILT_SOURCES)
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
if HAVE_CXX11
|
||||
|
||||
### Generated headers
|
||||
|
||||
generated_evas_canvas_js_bindings = \
|
||||
lib/evas/canvas/evas_line.eo.js.cc \
|
||||
lib/evas/canvas/evas_polygon.eo.js.cc \
|
||||
lib/evas/canvas/evas_rectangle.eo.js.cc \
|
||||
lib/evas/canvas/evas_text.eo.js.cc \
|
||||
lib/evas/canvas/evas_textblock.eo.js.cc \
|
||||
lib/evas/canvas/evas_textgrid.eo.js.cc \
|
||||
lib/evas/canvas/evas_signal_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_object_smart.eo.js.cc \
|
||||
lib/evas/canvas/evas_smart_clipped.eo.js.cc \
|
||||
lib/evas/canvas/evas_table.eo.js.cc \
|
||||
lib/evas/canvas/evas_common_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_object.eo.js.cc \
|
||||
lib/evas/canvas/evas_canvas.eo.js.cc \
|
||||
lib/evas/canvas/evas_grid.eo.js.cc \
|
||||
lib/evas/canvas/evas_image.eo.js.cc \
|
||||
lib/evas/canvas/evas_out.eo.js.cc \
|
||||
lib/evas/canvas/evas_draggable_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_clickable_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_scrollable_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_selectable_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_zoomable_interface.eo.js.cc \
|
||||
lib/evas/canvas/evas_box.eo.js.cc
|
||||
|
||||
CLEANFILES += $(generated_evas_canvas_js_bindings)
|
||||
|
||||
### Unit tests
|
||||
|
||||
# if EFL_ENABLE_TESTS
|
||||
|
||||
# check_PROGRAMS += tests/evas_cxx/cxx_compile_test
|
||||
# TESTS += tests/evas_cxx/cxx_compile_test
|
||||
|
||||
# tests_evas_cxx_cxx_compile_test_SOURCES = tests/evas_cxx/cxx_compile_test.cc
|
||||
# tests_evas_cxx_cxx_compile_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
|
||||
# -DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/evas_cxx\" \
|
||||
# -DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/evas_cxx\" \
|
||||
# @CHECK_CFLAGS@ @ECORE_CXX_CFLAGS@ @EINA_CXX_CFLAGS@ @EVAS_CXX_CFLAGS@ @EO_CXX_CFLAGS@ \
|
||||
# @ECORE_CFLAGS@ @EINA_CFLAGS@ @EVAS_CFLAGS@ @EO_CFLAGS@
|
||||
# tests_evas_cxx_cxx_compile_test_LDADD = @CHECK_LIBS@ @USE_EVAS_LIBS@
|
||||
# tests_evas_cxx_cxx_compile_test_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@
|
||||
|
||||
# endif
|
||||
endif
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef EOLIAN_KLASS_HH
|
||||
#define EOLIAN_KLASS_HH
|
||||
|
||||
inline std::string name(Eolian_Class const& cls)
|
||||
{
|
||||
return ::eolian_class_name_get(&cls);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
#include <Eina.hh>
|
||||
|
||||
namespace eolian { namespace js {
|
||||
|
||||
efl::eina::log_domain domain("eolian_cxx");
|
||||
|
||||
} }
|
|
@ -0,0 +1,144 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Eolian.h>
|
||||
|
||||
#include <Eina.hh>
|
||||
|
||||
#include <eolian/js/domain.hh>
|
||||
#include <eolian/class.hh>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::vector<std::string> include_paths;
|
||||
std::string out_file, in_file;
|
||||
|
||||
efl::eina::eina_init eina_init;
|
||||
struct eolian_init
|
||||
{
|
||||
eolian_init() { ::eolian_init(); }
|
||||
~eolian_init() { ::eolian_shutdown(); }
|
||||
} eolian_init;
|
||||
|
||||
const struct option long_options[] =
|
||||
{
|
||||
{ "in", required_argument, 0, 'I' },
|
||||
{ "out-file", required_argument, 0, 'o' },
|
||||
{ "version", no_argument, 0, 'v' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
const char* options = "I:D:o:c:arvh";
|
||||
|
||||
int c, idx;
|
||||
while ( (c = getopt_long(argc, argv, options, long_options, &idx)) != -1)
|
||||
{
|
||||
if (c == 'I')
|
||||
{
|
||||
include_paths.push_back(optarg);
|
||||
}
|
||||
else if (c == 'o')
|
||||
{
|
||||
if(!out_file.empty())
|
||||
{
|
||||
// _usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
out_file = optarg;
|
||||
}
|
||||
else if (c == 'h')
|
||||
{
|
||||
// _usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
else if (c == 'v')
|
||||
{
|
||||
// _print_version();
|
||||
// if (argc == 2) exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc-1)
|
||||
{
|
||||
in_file = argv[optind];
|
||||
}
|
||||
|
||||
|
||||
for(auto src : include_paths)
|
||||
if (!::eolian_directory_scan(src.c_str()))
|
||||
{
|
||||
EINA_CXX_DOM_LOG_WARN(eolian::js::domain)
|
||||
<< "Couldn't load eolian from '" << src << "'.";
|
||||
}
|
||||
if (!::eolian_all_eot_files_parse())
|
||||
{
|
||||
EINA_CXX_DOM_LOG_ERR(eolian::js::domain)
|
||||
<< "Eolian failed parsing eot files";
|
||||
assert(false && "Error parsing eot files");
|
||||
}
|
||||
if (!::eolian_eo_file_parse(in_file.c_str()))
|
||||
{
|
||||
EINA_CXX_DOM_LOG_ERR(eolian::js::domain)
|
||||
<< "Failed parsing: " << in_file << ".";
|
||||
assert(false && "Error parsing input file");
|
||||
}
|
||||
|
||||
const Eolian_Class *klass = NULL;
|
||||
{
|
||||
char* dup = strdup(in_file.c_str());
|
||||
char *bn = basename(dup);
|
||||
klass = ::eolian_class_get_by_file(bn);
|
||||
free(dup);
|
||||
}
|
||||
if(!klass)
|
||||
{
|
||||
EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "could not find any class defined in this eo file";
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::ofstream os (out_file.c_str());
|
||||
if(!os.is_open())
|
||||
{
|
||||
EINA_CXX_DOM_LOG_ERR(eolian::js::domain) << "Couldn't open output file " << out_file;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string class_name = name(*klass);
|
||||
std::transform(class_name.begin(), class_name.end(), class_name.begin()
|
||||
, [] (unsigned char c) { return std::toupper(c); });
|
||||
os << "#ifndef EFL_GENERATED_EOLIAN_CLASS_GUARD_" << class_name << "_H\n";
|
||||
os << "#define EFL_GENERATED_EOLIAN_CLASS_GUARD_" << class_name << "_H\n\n";
|
||||
|
||||
std::vector<std::string> namespace_;
|
||||
|
||||
for(efl::eina::iterator<const char> first (::eolian_class_namespaces_get(klass))
|
||||
, last; first != last; ++first)
|
||||
namespace_.push_back(&*first);
|
||||
|
||||
os << "namespace ";
|
||||
for(auto first = namespace_.begin()
|
||||
, last = namespace_.end(); first != last; ++first)
|
||||
{
|
||||
os << *first;
|
||||
if(std::next(first) != last) os << "::";
|
||||
}
|
||||
os << " {\n";
|
||||
|
||||
std::vector<Eolian_Function const*> functions;
|
||||
|
||||
for(efl::eina::iterator<Eolian_Function> first
|
||||
( ::eolian_class_functions_get(klass, EOLIAN_METHOD) )
|
||||
, last; first != last; ++first)
|
||||
functions.push_back(&*first);
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
|
Loading…
Reference in New Issue