eolian_cxx: initial version of the EFL C++ Bindings Generator.

Summary:
This patch adds 'eolian_cxx' -- a C++ bindings generator --
to the EFL tree. Eolian Cxx uses Eolian API to read .eo files and generate
.eo.hh. It relies/depends on Eo Cxx and Eina Cxx (both non-generated
bindings).

src/bin/eolian_cxx: The eolian_cxx program.
src/lib/eolian_cxx: A header-only library that implements the C++ code
generation that binds the .eo classes.

=Examples=

src/examples/eolian_cxx/eolian_cxx_simple_01.cc: The simplest example,
it just uses some "dummy" generated C++ classes.

src/examples/eolian_cxx/eolian_cxx_inherit_01.cc: Illustrates how
pure C++ classes inherit from .eo generated classes.

src/examples/evas/evas_cxx_rectangle.cc: More realistic example using
the generated bindings Evas Cxx. Still a bit shallow because we don't
have full fledged .eo descriptions yet, but will be improved.

=Important=

The generated code is not supported and not a stable API/ABI. It is
here to gather people interest and get review before we set things in
stone for release 1.11.

@feature

Reviewers: cedric, smohanty, raster, stefan_schmidt

CC: felipealmeida, JackDanielZ, cedric, stefan

Differential Revision: https://phab.enlightenment.org/D805

Signed-off-by: Cedric Bail <cedric.bail@free.fr>
This commit is contained in:
Savio Sena 2014-05-03 00:55:51 +02:00 committed by Cedric Bail
parent 64c6c63725
commit 46b6e8a563
70 changed files with 4757 additions and 12 deletions

2
.gitignore vendored
View File

@ -31,6 +31,8 @@ tags
*.eo.c
*.eo.h
*.eo.legacy.h
*.eo.hh
.dir-locals.el
/efl-*-doc.tar.bz2
/ar-lib
/stamp-h1

View File

@ -122,7 +122,9 @@ pkgconfig_DATA += \
pc/eina.pc \
pc/eina-cxx.pc \
pc/eo.pc \
pc/eo-cxx.pc \
pc/eolian.pc \
pc/eolian-cxx.pc \
pc/eet.pc \
pc/evas.pc \
pc/ecore.pc \
@ -144,7 +146,8 @@ pc/efreet-trash.pc \
pc/edje.pc \
pc/emotion.pc \
pc/ethumb.pc \
pc/ethumb_client.pc
pc/ethumb_client.pc \
pc/evas-cxx.pc
if BUILD_ENGINE_SOFTWARE_X11
pkgconfig_DATA += pc/evas-software-x11.pc
@ -263,6 +266,36 @@ eolian_cmakeconfig_DATA = \
cmakeconfig/EolianConfig.cmake \
cmakeconfig/EolianConfigVersion.cmake
eolian_cxx_cmakeconfigdir = $(libdir)/cmake/EolianCxx/
eolian_cxx_cmakeconfig_DATA = \
cmakeconfig/EolianCxxConfig.cmake \
cmakeconfig/EolianCxxConfigVersion.cmake
eina_cxx_cmakeconfigdir = $(libdir)/cmake/EinaCxx/
eina_cxx_cmakeconfig_DATA = \
cmakeconfig/EinaCxxConfig.cmake \
cmakeconfig/EinaCxxConfigVersion.cmake
eo_cxx_cmakeconfigdir = $(libdir)/cmake/EoCxx/
eo_cxx_cmakeconfig_DATA = \
cmakeconfig/EoCxxConfig.cmake \
cmakeconfig/EoCxxConfigVersion.cmake
ecore_cxx_cmakeconfigdir = $(libdir)/cmake/EcoreCxx/
ecore_cxx_cmakeconfig_DATA = \
cmakeconfig/EcoreCxxConfig.cmake \
cmakeconfig/EcoreCxxConfigVersion.cmake
evas_cxx_cmakeconfigdir = $(libdir)/cmake/EvasCxx/
evas_cxx_cmakeconfig_DATA = \
cmakeconfig/EvasCxxConfig.cmake \
cmakeconfig/EvasCxxConfigVersion.cmake
eet_cxx_cmakeconfigdir = $(libdir)/cmake/EetCxx/
eet_cxx_cmakeconfig_DATA = \
cmakeconfig/EetCxxConfig.cmake \
cmakeconfig/EetCxxConfigVersion.cmake
eet_cmakeconfigdir = $(libdir)/cmake/Eet/
eet_cmakeconfig_DATA = \
cmakeconfig/EetConfig.cmake \

View File

@ -0,0 +1,66 @@
# - Try to find ecore_cxx
# Once done this will define
#
# ECORE_CXX_FOUND - System has ecore_cxx
# ECORE_CXX_INCLUDE_DIRS - The ecore_cxx include directories
# ECORE_CXX_LIBRARIES - The libraries needed to use ecore_cxx
# ECORE_CXX_DEFINITIONS - Compiler switches required for using ecore_cxx
#
# When the COMPONENTS keyword was passed to find_package(),
# the following variables are defined for additional Ecore_Cxx modules
# such as Evas, X, Imf, Imf_Evas.
#
# ECORE_CXX_*_FOUND - System has ecore_cxx *
# ECORE_CXX_*_INCLUDE_DIRS - The ecore_cxx include directories
# ECORE_CXX_*_LIBRARIES - The libraries needed to use ecore_cxx
# ECORE_CXX_*_DEFINITIONS - Compiler switches required for using ecore_cxx * module.
set(MY_PKG ecore_cxx)
find_package(PkgConfig)
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
# "QUIET" was introduced in 2.8.2
set(_QUIET QUIET)
endif ()
pkg_check_modules(PC_LIBECORE_CXX ${_QUIET} ${MY_PKG})
find_library(ECORE_CXX_LIBRARY
NAMES ${PC_LIBECORE_CXX_LIBRARIES}
HINTS ${PC_LIBECORE_CXX_LIBDIR} ${PC_LIBECORE_CXX_LIBRARY_DIRS} )
set(ECORE_CXX_DEFINITIONS ${PC_LIBECORE_CXX_CFLAGS_OTHER})
set(ECORE_CXX_LIBRARIES ${ECORE_CXX_LIBRARY})
set(ECORE_CXX_INCLUDE_DIRS ${PC_LIBECORE_CXX_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set ECORE_CXX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
ECORE_CXX_LIBRARIES ECORE_CXX_INCLUDE_DIRS)
mark_as_advanced(ECORE_CXX_INCLUDE_DIRS ECORE_CXX_LIBRARY ECORE_CXX_LIBRARIES ECORE_CXX_DEFINITIONS)
if (Ecore_Cxx_FIND_COMPONENTS)
foreach(_component ${Ecore_Cxx_FIND_COMPONENTS})
string(TOUPPER ${_component} _COMPONENT)
string(TOLOWER ${_component} _component)
string(REGEX REPLACE "_" "-" _MODULE_PKGNAME "ecore_cxx-${_component}")
pkg_check_modules(PC_LIBECORE_CXX_${_COMPONENT} ${_QUIET} ${_MODULE_PKGNAME})
find_library(ECORE_CXX_${_COMPONENT}_LIBRARY
NAMES ${PC_LIBECORE_CXX_${_COMPONENT}_LIBRARIES}
HINTS ${PC_LIBECORE_CXX_${_COMPONENT}_LIBDIR}
${PC_LIBECORE_CXX_${_COMPONENT}_LIBRARY_DIRS})
set(ECORE_CXX_${_COMPONENT}_DEFINITIONS ${PC_LIBECORE_CXX_${_COMPONENT}_CFLAGS_OTHER})
set(ECORE_CXX_${_COMPONENT}_LIBRARIES ${ECORE_CXX_${_COMPONENT}_LIBRARY})
set(ECORE_CXX_${_COMPONENT}_INCLUDE_DIRS ${PC_LIBECORE_CXX_${_COMPONENT}_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set ECORE_CXX_*_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(ecore_cxx_${_component} DEFAULT_MSG
ECORE_CXX_${_COMPONENT}_LIBRARIES ECORE_CXX_${_COMPONENT}_INCLUDE_DIRS)
endforeach(_component)
endif(Ecore_Cxx_FIND_COMPONENTS)

View File

@ -0,0 +1,30 @@
# - Try to find eet
# Once done this will define
# EET_CXX_FOUND - System has eet
# EET_CXX_INCLUDE_DIRS - The eet include directories
# EET_CXX_LIBRARIES - The libraries needed to use eet
# EET_CXX_DEFINITIONS - Compiler switches required for using eet
set(MY_PKG eet_cxx)
find_package(PkgConfig)
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
# "QUIET" was introduced in 2.8.2
set(_QUIET QUIET)
endif ()
pkg_check_modules(PC_EET_CXX ${_QUIET} ${MY_PKG})
find_library(EET_CXX_LIBRARY
NAMES ${PC_EET_CXX_LIBRARIES}
HINTS ${PC_EET_CXX_LIBDIR} ${PC_EET_CXX_LIBRARY_DIRS} )
set(EET_CXX_DEFINITIONS ${PC_EET_CXX_CFLAGS_OTHER})
set(EET_CXX_LIBRARIES ${EET_CXX_LIBRARY})
set(EET_CXX_INCLUDE_DIRS ${PC_EET_CXX_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EET_CXX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
EET_CXX_LIBRARIES EET_CXX_INCLUDE_DIRS)
mark_as_advanced(EET_CXX_INCLUDE_DIRS EET_CXX_LIBRARY EET_CXX_LIBRARIES EET_CXX_DEFINITIONS)

View File

@ -0,0 +1,30 @@
# - Try to find eina
# Once done this will define
# EINA_CXX_FOUND - System has eina
# EINA_CXX_INCLUDE_DIRS - The eina include directories
# EINA_CXX_LIBRARIES - The libraries needed to use eina
# EINA_CXX_DEFINITIONS - Compiler switches required for using eina
set(MY_PKG eina_cxx)
find_package(PkgConfig)
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
# "QUIET" was introduced in 2.8.2
set(_QUIET QUIET)
endif ()
pkg_check_modules(PC_EINA_CXX ${_QUIET} ${MY_PKG})
find_library(EINA_CXX_LIBRARY
NAMES ${PC_EINA_CXX_LIBRARIES}
HINTS ${PC_EINA_CXX_LIBDIR} ${PC_EINA_CXX_LIBRARY_DIRS} )
set(EINA_CXX_DEFINITIONS ${PC_EINA_CXX_CFLAGS_OTHER})
set(EINA_CXX_LIBRARIES ${EINA_CXX_LIBRARY})
set(EINA_CXX_INCLUDE_DIRS ${PC_EINA_CXX_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EINA_CXX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
EINA_CXX_LIBRARIES EINA_CXX_INCLUDE_DIRS)
mark_as_advanced(EINA_CXX_INCLUDE_DIRS EINA_CXX_LIBRARY EINA_CXX_LIBRARIES EINA_CXX_DEFINITIONS)

View File

@ -0,0 +1,30 @@
# - Try to find eo
# Once done this will define
# EO_CXX_FOUND - System has eo
# EO_CXX_INCLUDE_DIRS - The eo include directories
# EO_CXX_LIBRARIES - The libraries needed to use eo
# EO_CXX_DEFINITIONS - Compiler switches required for using eo
set(MY_PKG eo_cxx)
find_package(PkgConfig)
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
# "QUIET" was introduced in 2.8.2
set(_QUIET QUIET)
endif ()
pkg_check_modules(PC_EO_CXX ${_QUIET} ${MY_PKG})
find_library(EO_CXX_LIBRARY
NAMES ${PC_EO_CXX_LIBRARIES}
HINTS ${PC_EO_CXX_LIBDIR} ${PC_EO_CXX_LIBRARY_DIRS} )
set(EO_CXX_DEFINITIONS ${PC_EO_CXX_CFLAGS_OTHER})
set(EO_CXX_LIBRARIES ${EO_CXX_LIBRARY})
set(EO_CXX_INCLUDE_DIRS ${PC_EO_CXX_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EO_CXX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
EO_CXX_LIBRARIES EO_CXX_INCLUDE_DIRS)
mark_as_advanced(EO_CXX_INCLUDE_DIRS EO_CXX_LIBRARY EO_CXX_LIBRARIES EO_CXX_DEFINITIONS)

View File

@ -0,0 +1,30 @@
# - Try to find eolian
# Once done this will define
# EOLIAN_CXX_FOUND - System has eolian
# EOLIAN_CXX_INCLUDE_DIRS - The eolian include directories
# EOLIAN_CXX_LIBRARIES - The libraries needed to use eolian
# EOLIAN_CXX_DEFINITIONS - Compiler switches required for using eolian
set(MY_PKG eolian_cxx)
find_package(PkgConfig)
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
# "QUIET" was introduced in 2.8.2
set(_QUIET QUIET)
endif ()
pkg_check_modules(PC_EOLIAN_CXX ${_QUIET} ${MY_PKG})
find_library(EOLIAN_CXX_LIBRARY
NAMES ${PC_EOLIAN_CXX_LIBRARIES}
HINTS ${PC_EOLIAN_CXX_LIBDIR} ${PC_EOLIAN_CXX_LIBRARY_DIRS} )
set(EOLIAN_CXX_DEFINITIONS ${PC_EOLIAN_CXX_CFLAGS_OTHER})
set(EOLIAN_CXX_LIBRARIES ${EOLIAN_CXX_LIBRARY})
set(EOLIAN_CXX_INCLUDE_DIRS ${PC_EOLIAN_CXX_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EOLIAN_CXX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
EOLIAN_CXX_LIBRARIES EOLIAN_CXX_INCLUDE_DIRS)
mark_as_advanced(EOLIAN_CXX_INCLUDE_DIRS EOLIAN_CXX_LIBRARY EOLIAN_CXX_LIBRARIES EOLIAN_CXX_DEFINITIONS)

View File

@ -0,0 +1,30 @@
# - Try to find evas
# Once done this will define
# EVAS_CXX_FOUND - System has evas
# EVAS_CXX_INCLUDE_DIRS - The evas include directories
# EVAS_CXX_LIBRARIES - The libraries needed to use evas
# EVAS_CXX_DEFINITIONS - Compiler switches required for using evas
set(MY_PKG evas_cxx)
find_package(PkgConfig)
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
# "QUIET" was introduced in 2.8.2
set(_QUIET QUIET)
endif ()
pkg_check_modules(PC_EVAS_CXX ${_QUIET} ${MY_PKG})
find_library(EVAS_CXX_LIBRARY
NAMES ${PC_EVAS_CXX_LIBRARIES}
HINTS ${PC_EVAS_CXX_LIBDIR} ${PC_EVAS_CXX_LIBRARY_DIRS} )
set(EVAS_CXX_DEFINITIONS ${PC_EVAS_CXX_CFLAGS_OTHER})
set(EVAS_CXX_LIBRARIES ${EVAS_CXX_LIBRARY})
set(EVAS_CXX_INCLUDE_DIRS ${PC_EVAS_CXX_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set EVAS_CXX_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(${MY_PKG} DEFAULT_MSG
EVAS_CXX_LIBRARIES EVAS_CXX_INCLUDE_DIRS)
mark_as_advanced(EVAS_CXX_INCLUDE_DIRS EVAS_CXX_LIBRARY EVAS_CXX_LIBRARIES EVAS_CXX_DEFINITIONS)

View File

@ -146,7 +146,7 @@ AC_SUBST(dbusservicedir)
efl_deprecated_option="no"
EFL_WITH_BIN([edje], [edje-cc])
EFL_WITH_BIN([eolian], [eolian-gen])
EFL_WITH_BIN([eolian_cxx], [eolian-cxx])
#### Default values
@ -1057,6 +1057,7 @@ EFL_LIB_START([Eolian])
### Default values
### Additional options to configure
EFL_ADD_FEATURE([EOLIAN], [cxx], [${have_cxx11}])
### Checks for programs
@ -4110,6 +4111,7 @@ src/examples/ephysics/Makefile
src/examples/edje/Makefile
src/examples/emotion/Makefile
src/examples/ethumb_client/Makefile
src/examples/eolian_cxx/Makefile
src/lib/eina/eina_config.h
src/lib/ecore_x/ecore_x_version.h
src/lib/efl/Efl_Config.h
@ -4121,7 +4123,9 @@ pc/eina-cxx.pc
pc/eet.pc
pc/eet-cxx.pc
pc/eo.pc
pc/eo-cxx.pc
pc/eolian.pc
pc/eolian-cxx.pc
pc/evas-fb.pc
pc/evas-opengl-x11.pc
pc/evas-opengl-sdl.pc
@ -4136,6 +4140,7 @@ pc/evas-wayland-shm.pc
pc/evas-wayland-egl.pc
pc/evas-drm.pc
pc/evas.pc
pc/evas-cxx.pc
pc/ecore.pc
pc/ecore-con.pc
pc/ecore-ipc.pc
@ -4181,6 +4186,18 @@ cmakeconfig/EoConfig.cmake
cmakeconfig/EoConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EolianConfig.cmake
cmakeconfig/EolianConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EolianCxxConfig.cmake
cmakeconfig/EolianCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EinaCxxConfig.cmake
cmakeconfig/EinaCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EoCxxConfig.cmake
cmakeconfig/EoCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EcoreCxxConfig.cmake
cmakeconfig/EcoreCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EvasCxxConfig.cmake
cmakeconfig/EvasCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EetCxxConfig.cmake
cmakeconfig/EetCxxConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EetConfig.cmake
cmakeconfig/EetConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
cmakeconfig/EvasConfig.cmake

4
pc/.gitignore vendored
View File

@ -52,3 +52,7 @@
/evas.pc
/evil.pc
/eolian.pc
/eolian-cxx.pc
/eo-cxx.pc
/evas-cxx.pc
/ecore-audio-cxx.pc.in

View File

@ -9,4 +9,4 @@ Version: @VERSION@
Requires.private: @requirements_pc_eet@
Libs: -L${libdir} -leet
Libs.private: @requirements_libs_eet@
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eet-@VMAJ@ -I${includedir}/efl-@VMAJ@ -I${includedir}/eet_cxx-@VMAJ@ -I${includedir}/eet_cxx-@VMAJ@/eet_cxx
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eet-@VMAJ@ -I${includedir}/efl-@VMAJ@ -I${includedir}/eet-cxx-@VMAJ@ -I${includedir}/eet-cxx-@VMAJ@/eet-cxx

View File

@ -9,4 +9,4 @@ Requires.private: @requirements_pc_eina@
Version: @VERSION@
Libs: -L${libdir} -leina @requirements_public_libs_eina@
Libs.private: @requirements_libs_eina@
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-@VMAJ@/eina -I${includedir}/eina_cxx-@VMAJ@ -I${includedir}/eina_cxx-@VMAJ@/eina_cxx
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-@VMAJ@/eina -I${includedir}/eina-cxx-@VMAJ@ -I${includedir}/eina-cxx-@VMAJ@/eina-cxx

12
pc/eo-cxx.pc.in Normal file
View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Eo C++
Description: C++ bindings for EFL's generic object system.
Version: @PACKAGE_VERSION@
Requires.private: @requirements_pc_eo@
Libs.private: @requirements_libs_eo@
Libs: -L${libdir} -leo
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eo-@VMAJ@ -I${includedir}/eo-cxx-@VMAJ@

12
pc/eolian-cxx.pc.in Normal file
View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: Eolian C++
Description: EFL's C++ bindings generator.
Version: @VERSION@
Require.private: @requirements_pc_eolian_cxx@
Libs: -L${libdir}
Libs.private: @requirements_libs_eolian_cxx@
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/eolian-cxx-@VMAJ@

15
pc/evas-cxx.pc.in Normal file
View File

@ -0,0 +1,15 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
eoincludedir=@datarootdir@/eolian/include
eolian_flags=-I${eoincludedir}/evas-cxx-@VMAJ@
Name: evas
Description: Evas C++ Bindings
Requires.private: @requirements_pc_evas@
Version: @VERSION@
Libs: -L${libdir} -levas
Libs.private: @requirements_libs_evas@
Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/evas-@VMAJ@ -I${includedir}/evas-cxx-@VMAJ@

View File

@ -56,7 +56,9 @@ include Makefile_Ecore_IMF.am
include Makefile_Ecore_IMF_Evas.am
include Makefile_Ecore_Evas.am
include Makefile_Ecore_Audio.am
include Makefile_Ecore_Audio_Cxx.am
include Makefile_Ecore_Avahi.am
include Makefile_Evas_Cxx.am
include Makefile_Embryo.am
include Makefile_Eio.am
include Makefile_Eldbus.am
@ -68,7 +70,10 @@ include Makefile_Emotion.am
include Makefile_Ethumb.am
include Makefile_Ethumb_Client.am
include Makefile_Eolian_Cxx.am
include Makefile_Eina_Cxx.am
include Makefile_Eo_Cxx.am
include Makefile_Edje_Cxx.am
.PHONY: benchmark examples
@ -97,7 +102,8 @@ examples/eldbus \
examples/ephysics \
examples/edje \
examples/emotion \
examples/ethumb_client
examples/ethumb_client \
examples/eolian_cxx
if ALWAYS_BUILD_EXAMPLES
SUBDIRS += . $(EXAMPLES_SUBDIRS)
endif

View File

@ -0,0 +1,58 @@
if HAVE_CXX11
### Generated headers
generated_ecore_audio_cxx_bindings = \
lib/ecore_audio/ecore_audio.eo.hh \
lib/ecore_audio/ecore_audio_in.eo.hh \
lib/ecore_audio/ecore_audio_out.eo.hh \
lib/ecore_audio/ecore_audio_in_sndfile.eo.hh \
lib/ecore_audio/ecore_audio_out_sndfile.eo.hh \
lib/ecore_audio/ecore_audio_out_pulse.eo.hh \
lib/ecore_audio/ecore_audio_in_tone.eo.hh
BUILT_SOURCES += \
lib/ecore_audio/Ecore_Audio.hh \
$(generated_ecore_audio_cxx_bindings)
lib/ecore_audio/Ecore_Audio.hh:
@echo -e "#ifndef EFL_CXX_ECORE_AUDIO_HH\n#define EFL_CXX_ECORE_AUDIO_HH\n" > $(top_builddir)/src/lib/ecore_audio/Ecore_Audio.hh
@echo -e "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/ecore_audio/Ecore_Audio.hh
@for i in $(generated_ecore_audio_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/ecore_audio/Ecore_Audio.hh; done
@echo -e "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/ecore_audio/Ecore_Audio.hh
installed_ecoreaudiocxxmainheadersdir = $(includedir)/ecore-audio-cxx-@VMAJ@
dist_installed_ecoreaudiocxxmainheaders_DATA = \
lib/ecore_audio/Ecore_Audio.hh \
$(generated_ecore_audio_cxx_bindings)
### Unit tests
if EFL_ENABLE_TESTS
check_PROGRAMS += tests/ecore_audio_cxx/cxx_compile_test
TESTS += tests/ecore_audio_cxx/cxx_compile_test
tests_ecore_audio_cxx_cxx_compile_test_SOURCES = tests/ecore_audio_cxx/cxx_compile_test.cc
tests_ecore_audio_cxx_cxx_compile_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/ecore_audio \
-I$(top_builddir)/src/lib/ecore_audio \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/eo \
-I$(top_builddir)/src/lib/eo \
-I$(top_srcdir)/src/bindings/eo_cxx \
-I$(top_builddir)/src/bindings/eo_cxx \
-I$(top_srcdir)/src/bindings/ecore_cxx \
-I$(top_builddir)/src/bindings/ecore_cxx \
-I$(top_srcdir)/src/bindings/eina_cxx \
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/ecore_audio_cxx\" \
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/ecore_audio_cxx\" \
@CHECK_CFLAGS@ @ECORE_CFLAGS@ @EINA_CFLAGS@
tests_ecore_audio_cxx_cxx_compile_test_LDADD = @CHECK_LIBS@ @USE_ECORE_LIBS@
tests_ecore_audio_cxx_cxx_compile_test_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@
endif
endif

View File

@ -1,17 +1,43 @@
### Library
installed_ecorecxxmainheadersdir = $(includedir)/ecore_cxx-@VMAJ@
dist_installed_ecorecxxmainheaders_DATA = \
bindings/ecore_cxx/Ecore.hh
installed_ecorecxxmainheadersdir = $(includedir)/ecore-cxx-@VMAJ@
dist_installed_ecorecxxmainheaders_DATA = bindings/ecore_cxx/Ecore.hh
if HAVE_CXX11
generated_ecore_cxx_bindings = \
lib/ecore/ecore_poll.eo.hh \
lib/ecore/ecore_job.eo.hh \
lib/ecore/ecore_idler.eo.hh \
lib/ecore/ecore_idle_exiter.eo.hh \
lib/ecore/ecore_animator.eo.hh \
lib/ecore/ecore_parent.eo.hh
BUILT_SOURCES += \
lib/ecore/Ecore.eo.hh \
$(generated_ecore_cxx_bindings)
installed_ecorecxxheadersdir = $(includedir)/ecore-cxx-@VMAJ@
dist_installed_ecorecxxheaders_DATA = \
lib/ecore/Ecore.eo.hh \
$(generated_ecore_cxx_bindings)
lib/ecore/Ecore.eo.hh:
@echo -e "#ifndef EFL_CXX_ECORE_HH\n#define EFL_CXX_ECORE_HH\n" > $(top_builddir)/src/lib/ecore/Ecore.eo.hh
@echo -e "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/ecore/Ecore.eo.hh
@for i in $(generated_ecore_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/ecore/Ecore.eo.hh; done
@echo -e "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/ecore/Ecore.eo.hh
endif
### Unit tests
if EFL_ENABLE_TESTS
if HAVE_CXX11
check_PROGRAMS += tests/ecore_cxx/ecore_cxx_suite
TESTS += tests/ecore_cxx/ecore_cxx_suite
check_PROGRAMS += tests/ecore_cxx/ecore_cxx_suite tests/ecore_cxx/cxx_compile_test
TESTS += tests/ecore_cxx/ecore_cxx_suite tests/ecore_cxx/cxx_compile_test
tests_ecore_cxx_ecore_cxx_suite_SOURCES = \
tests/ecore_cxx/ecore_cxx_suite.cc \
@ -20,6 +46,7 @@ tests/ecore_cxx/ecore_cxx_test_safe_call.cc
tests_ecore_cxx_ecore_cxx_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/bindings/ecore_cxx \
-I$(top_srcdir)/src/bindings/eina_cxx \
-I$(top_srcdir)/src/bindings/eo_cxx \
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/ecore_cxx\" \
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/ecore_cxx\" \
@CHECK_CFLAGS@ \
@ -32,5 +59,16 @@ tests_ecore_cxx_ecore_cxx_suite_LDADD = \
tests_ecore_cxx_ecore_cxx_suite_DEPENDENCIES = \
@USE_ECORE_INTERNAL_LIBS@
tests_ecore_cxx_cxx_compile_test_SOURCES = tests/ecore_cxx/cxx_compile_test.cc
tests_ecore_cxx_cxx_compile_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/bindings/ecore_cxx \
-I$(top_srcdir)/src/bindings/eina_cxx \
-I$(top_srcdir)/src/bindings/eo_cxx \
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/ecore_cxx\" \
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/ecore_cxx\" \
@CHECK_CFLAGS@ @ECORE_CFLAGS@ @EINA_CFLAGS@
tests_ecore_cxx_cxx_compile_test_LDADD = @CHECK_LIBS@ @USE_ECORE_LIBS@
tests_ecore_cxx_cxx_compile_test_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@
endif
endif

62
src/Makefile_Edje_Cxx.am Normal file
View File

@ -0,0 +1,62 @@
if HAVE_CXX11
### Generated headers
generated_edje_cxx_bindings = \
lib/edje/edje.eo.hh \
lib/edje/edje_edit.eo.hh
BUILT_SOURCES += \
lib/edje/Edje.hh \
$(generated_edje_cxx_bindings)
EXTRA_DIST += \
lib/edje/Edje.hh \
$(edje_cxx_bindngs)
installed_edjecxxmainheadersdir = $(includedir)/edje-cxx-@VMAJ@/
dist_installed_edjecxxmainheaders_DATA = \
lib/edje/Edje.hh \
$(generated_edje_cxx_bindings)
lib/edje/Edje.hh:
@echo -e "#ifndef EFL_CXX_EDJE_HH\n#define EFL_CXX_EDJE_HH\n" > $(top_builddir)/src/lib/edje/Edje.hh
@echo -e "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/edje/Edje.hh
@for i in $(generated_edje_cxx_bindings); do echo "#include <$$(basename $$i)>" >> $(top_builddir)/src/lib/edje/Edje.hh; done
@echo -e "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/edje/Edje.hh
### Unit tests
if EFL_ENABLE_TESTS
check_PROGRAMS += tests/edje_cxx/cxx_compile_test
TESTS += tests/edje_cxx/cxx_compile_test
tests_edje_cxx_cxx_compile_test_SOURCES = tests/edje_cxx/cxx_compile_test.cc
tests_edje_cxx_cxx_compile_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/edje \
-I$(top_builddir)/src/lib/edje \
-I$(top_srcdir)/src/lib/evas \
-I$(top_builddir)/src/lib/evas \
-I$(top_srcdir)/src/lib/evas/canvas \
-I$(top_builddir)/src/lib/evas/canvas \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/eo \
-I$(top_builddir)/src/lib/eo \
-I$(top_srcdir)/src/bindings/eo_cxx \
-I$(top_builddir)/src/bindings/eo_cxx \
-I$(top_srcdir)/src/bindings/ecore_cxx \
-I$(top_builddir)/src/bindings/ecore_cxx \
-I$(top_srcdir)/src/bindings/eina_cxx \
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/edje_cxx\" \
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/edje_cxx\" \
@CHECK_CFLAGS@ @ECORE_CFLAGS@ @EINA_CFLAGS@
tests_edje_cxx_cxx_compile_test_LDADD = @CHECK_LIBS@ @USE_ECORE_LIBS@
tests_edje_cxx_cxx_compile_test_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@
endif
endif

View File

@ -1,10 +1,10 @@
### Library
installed_eetcxxmainheadersdir = $(includedir)/eet_cxx-@VMAJ@
installed_eetcxxmainheadersdir = $(includedir)/eet-cxx-@VMAJ@
dist_installed_eetcxxmainheaders_DATA = bindings/eet_cxx/Eet.hh
installed_eetcxxheadersdir = $(includedir)/eet_cxx-@VMAJ@/eet_cxx
installed_eetcxxheadersdir = $(includedir)/eet-cxx-@VMAJ@/eet-cxx
dist_installed_eetcxxheaders_DATA = \
bindings/eet_cxx/eet_composite.hh \
bindings/eet_cxx/eet_fold.hh \

16
src/Makefile_Eo_Cxx.am Normal file
View File

@ -0,0 +1,16 @@
### Library
installed_eocxxmainheadersdir = $(includedir)/eo-cxx-@VMAJ@/
dist_installed_eocxxmainheaders_DATA = \
bindings/eo_cxx/Eo.hh
installed_eocxxheadersdir = $(includedir)/eo-cxx-@VMAJ@/
dist_installed_eocxxheaders_DATA = \
bindings/eo_cxx/eo_base.hh \
bindings/eo_cxx/eo_init.hh \
bindings/eo_cxx/eo_wref.hh \
bindings/eo_cxx/eo_inherit.hh \
bindings/eo_cxx/eo_ops.hh \
bindings/eo_cxx/eo_private.hh \
bindings/eo_cxx/eo_inherit_bindings.hh

View File

@ -0,0 +1,46 @@
### Binary
bin_PROGRAMS += \
bin/eolian_cxx/eolian_cxx
bin_eolian_cxx_eolian_cxx_SOURCES = \
bin/eolian_cxx/comments.cc \
bin/eolian_cxx/comments.hh \
bin/eolian_cxx/convert.cc \
bin/eolian_cxx/convert.hh \
bin/eolian_cxx/eo_read.h \
bin/eolian_cxx/safe_strings.hh \
bin/eolian_cxx/eolian_cxx.cc
bin_eolian_cxx_eolian_cxx_CFLAGS = \
-I$(top_builddir)/src/lib/efl \
-I$(top_builddir)/src/lib/eo \
-I$(top_srcdir)/src/lib/eo \
-I$(top_builddir)/src/lib/eina \
-I$(top_srcdir)/src/lib/eina \
-I$(top_builddir)/src/lib/eolian \
-I$(top_srcdir)/src/lib/eolian
bin_eolian_cxx_eolian_cxx_CXXFLAGS = \
-I$(top_builddir)/src/lib/efl \
-I$(top_builddir)/src/lib/eo \
-I$(top_srcdir)/src/lib/eo \
-I$(top_builddir)/src/lib/eina \
-I$(top_srcdir)/src/lib/eina \
-I$(top_builddir)/src/lib/eolian \
-I$(top_srcdir)/src/lib/eolian \
-I$(top_builddir)/src/bindings/eina_cxx \
-I$(top_srcdir)/src/bindings/eina_cxx \
-I$(top_builddir)/src/lib/eolian_cxx \
-I$(top_srcdir)/src/lib/eolian_cxx
bin_eolian_cxx_eolian_cxx_LDADD = \
@USE_EOLIAN_LIBS@
bin_eolian_cxx_eolian_cxx_DEPENDENCIES = \
@USE_EOLIAN_INTERNAL_LIBS@
include Makefile_Eolian_Cxx_Helper.am
CLEANFILES += $(BUILT_SOURCES)

View File

@ -0,0 +1,19 @@
if HAVE_EOLIAN_CXX
EOLIAN_CXX = @eolian_cxx@
_EOLIAN_CXX_DEP = @eolian_cxx@
else
EOLIAN_CXX = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/eolian_cxx/eolian_cxx${EXEEXT}
_EOLIAN_CXX_DEP = bin/eolian_cxx/eolian_cxx${EXEEXT}
endif
AM_V_EOLCXX = $(am__v_EOLCXX_@AM_V@)
am__v_EOLCXX_ = $(am__v_EOLCXX_@AM_DEFAULT_V@)
am__v_EOLCXX_0 = @echo " EOLCXX " $@;
SUFFIXES += .eo.hh
%.eo.hh: %.eo $(_EOLIAN_CXX_DEP)
$(AM_V_EOLCXX)$(EOLIAN_CXX) $(EOLIAN_FLAGS) -I./$< -o $@
CLEANFILES += $(BUILT_SOURCES)

76
src/Makefile_Evas_Cxx.am Normal file
View File

@ -0,0 +1,76 @@
if HAVE_CXX11
### Generated headers
generated_evas_canvas_cxx_bindings = \
lib/evas/canvas/evas_line.eo.hh \
lib/evas/canvas/evas_polygon.eo.hh \
lib/evas/canvas/evas_rectangle.eo.hh \
lib/evas/canvas/evas_text.eo.hh \
lib/evas/canvas/evas_textblock.eo.hh \
lib/evas/canvas/evas_textgrid.eo.hh \
lib/evas/canvas/evas_signal_interface.eo.hh \
lib/evas/canvas/evas_smart.eo.hh \
lib/evas/canvas/evas_smart_clipped.eo.hh \
lib/evas/canvas/evas_table.eo.hh \
lib/evas/canvas/evas_common_interface.eo.hh \
lib/evas/canvas/evas_object.eo.hh \
lib/evas/canvas/evas.eo.hh \
lib/evas/canvas/evas_grid.eo.hh \
lib/evas/canvas/evas_image.eo.hh \
lib/evas/canvas/evas_out.eo.hh \
lib/evas/canvas/evas_draggable_interface.eo.hh \
lib/evas/canvas/evas_clickable_interface.eo.hh \
lib/evas/canvas/evas_scrollable_interface.eo.hh \
lib/evas/canvas/evas_selectable_interface.eo.hh \
lib/evas/canvas/evas_zoomable_interface.eo.hh \
lib/evas/canvas/evas_box.eo.hh
BUILT_SOURCES += lib/evas/Evas.hh $(generated_evas_canvas_cxx_bindings)
installed_evascanvasmainheadersdir = $(includedir)/evas-cxx-@VMAJ@/
dist_installed_evascanvasmainheaders_DATA = lib/evas/Evas.hh
installed_evascanvasmainheadersdir = $(includedir)/evas-cxx-@VMAJ@/canvas
dist_installed_evascanvasmainheaders_DATA = $(generated_evas_canvas_cxx_bindings)
lib/evas/Evas.hh:
@echo -e "#ifndef EFL_CXX_EVAS_HH\n#define EFL_CXX_EVAS_HH\n" > $(top_builddir)/src/lib/evas/Evas.hh
@echo -e "#ifdef EFL_BETA_API_SUPPORT" >> $(top_builddir)/src/lib/evas/Evas.hh
@for i in $(generated_evas_canvas_cxx_bindings); do echo "#include <canvas/$$(basename $$i)>" >> $(top_builddir)/src/lib/evas/Evas.hh; done
@echo -e "#endif\n\n#endif\n" >> $(top_builddir)/src/lib/evas/Evas.hh
### 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 -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/edje \
-I$(top_builddir)/src/lib/edje \
-I$(top_srcdir)/src/lib/evas \
-I$(top_builddir)/src/lib/evas \
-I$(top_srcdir)/src/lib/evas/canvas \
-I$(top_builddir)/src/lib/evas/canvas \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/eo \
-I$(top_builddir)/src/lib/eo \
-I$(top_srcdir)/src/bindings/eo_cxx \
-I$(top_builddir)/src/bindings/eo_cxx \
-I$(top_srcdir)/src/bindings/ecore_cxx \
-I$(top_builddir)/src/bindings/ecore_cxx \
-I$(top_srcdir)/src/bindings/eina_cxx \
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/evas_cxx\" \
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/evas_cxx\" \
@CHECK_CFLAGS@ @ECORE_CFLAGS@ @EINA_CFLAGS@
tests_evas_cxx_cxx_compile_test_LDADD = @CHECK_LIBS@ @USE_ECORE_LIBS@
tests_evas_cxx_cxx_compile_test_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@
endif
endif

1
src/bin/eolian_cxx/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/eolian_cxx

View File

@ -0,0 +1,110 @@
#include "comments.hh"
#include "safe_strings.hh"
static std::string
_comment_parameter(Eolian_Function_Parameter param)
{
Eolian_Parameter_Dir direction;
Eina_Stringshare *description;
eolian_parameter_information_get
(param, &direction, NULL, NULL, &description);
std::string doc = "@param";
if (direction == EOLIAN_IN_PARAM) doc += " ";
else if (direction == EOLIAN_OUT_PARAM) doc += "[out] ";
else if (direction == EOLIAN_INOUT_PARAM) doc += "[inout] ";
else assert(false);
doc += safe_strshare(eolian_parameter_name_get(param));
doc += " ";
doc += safe_str(description);
return doc;
}
static std::string
_comment_parameters_list(const Eina_List *params)
{
std::string doc = "";
const Eina_List *it;
void *curr;
EINA_LIST_FOREACH (params, it, curr)
{
doc += _comment_parameter
(static_cast<Eolian_Function_Parameter>(curr)) + "\n";
}
return doc;
}
static std::string
_comment_brief_and_params(Eolian_Function function,
const char *key = EOLIAN_COMMENT)
{
std::string doc = "";
std::string func = safe_str(eolian_function_description_get(function, key));
if (func != "")
{
doc += "@brief " + func + "\n\n";
}
std::string params = _comment_parameters_list(eolian_parameters_list_get(function));
if (params != "")
{
doc += params + "\n";
}
return doc;
}
static std::string
_comment_return(Eolian_Function function,
Eolian_Function_Type rettype)
{
std::string doc = "";
std::string ret = safe_str(eolian_function_return_type_get(function, rettype));
std::string comment = safe_str(eolian_function_return_comment_get(function, rettype));
if (ret != "void" && ret != "" && comment != "")
{
doc = "@return " + comment;
}
return doc;
}
namespace detail {
std::string
eolian_class_comment(const char *classname)
{
return safe_str(eolian_class_description_get(classname));
}
std::string
eolian_constructor_comment(Eolian_Function constructor)
{
return _comment_brief_and_params(constructor);
}
std::string eolian_function_comment(Eolian_Function function)
{
std::string doc = _comment_brief_and_params(function);
doc += _comment_return(function, EOLIAN_METHOD);
return doc;
}
std::string eolian_property_getter_comment(Eolian_Function property)
{
std::string doc = _comment_brief_and_params
(property, EOLIAN_COMMENT_GET);
doc += _comment_return(property, EOLIAN_PROP_GET);
return doc;
}
std::string eolian_property_setter_comment(Eolian_Function property)
{
std::string doc = _comment_brief_and_params
(property, EOLIAN_COMMENT_SET);
doc += _comment_return(property, EOLIAN_PROP_SET);
return doc;
}
} // namespace detail

View File

@ -0,0 +1,29 @@
#ifndef EOLIAN_CXX_EOLIAN_CONVERT_COMMENTS_HH
#define EOLIAN_CXX_EOLIAN_CONVERT_COMMENTS_HH
#include <string>
extern "C"
{
#include <Eina.h>
#include <Eolian.h>
}
#include <Eolian_Cxx.hh>
namespace detail {
std::string eolian_class_comment(const char *classname);
std::string eolian_constructor_comment(Eolian_Function constructor);
std::string eolian_function_comment(Eolian_Function function);
std::string eolian_property_getter_comment(Eolian_Function function);
std::string eolian_property_setter_comment(Eolian_Function function);
}
#endif // EOLIAN_CXX_EOLIAN_CONVERT_COMMENTS_HH

View File

@ -0,0 +1,304 @@
#include <vector>
#include <algorithm>
#include <cassert>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Eina.h>
#include <Eina.hh>
#include <Eo.h>
#include <Eolian.h>
#include "eo_types.hh"
#include "safe_strings.hh"
#include "comments.hh"
static std::string
_resolve_param_type(Eolian_Function_Parameter id, bool is_get)
{
Eolian_Parameter_Dir dir;
const char *type;
bool is_const;
std::string res;
eolian_parameter_information_get(id, &dir, &type, NULL, NULL);
is_const = eolian_parameter_const_attribute_get(id, is_get);
res = safe_str(type);
assert(res != "");
if (is_const) res = std::string("const ") + res;
if (dir == EOLIAN_OUT_PARAM || dir == EOLIAN_INOUT_PARAM) res += "*";
return res;
}
static efl::eolian::parameters_container_type
_get_params(const Eina_List *eolian_params, bool is_get = false)
{
const Eina_List *it;
void *curr;
if (eolian_params == NULL)
{
return efl::eolian::parameters_container_type();
}
efl::eolian::parameters_container_type list;
EINA_LIST_FOREACH (eolian_params, it, curr)
{
Eolian_Function_Parameter id =
(static_cast<Eolian_Function_Parameter>(curr));
list.push_back({
_resolve_param_type(id, is_get),
safe_strshare(eolian_parameter_name_get(id))
});
}
return list;
}
static efl::eolian::functions_container_type
_get_properties(const char *classname)
{
efl::eolian::functions_container_type container;
std::string cxx_classname = classname;
std::transform(cxx_classname.begin(), cxx_classname.end(),
cxx_classname.begin(), ::tolower);
const Eina_List *properties;
properties = eolian_class_functions_list_get(classname, EOLIAN_PROPERTY);
const Eina_List *it;
void *curr;
std::string prefix(safe_str(eolian_class_eo_prefix_get(classname)));
EINA_LIST_FOREACH (properties, it, curr)
{
Eolian_Function property = static_cast<Eolian_Function>(curr);
Eolian_Function_Type type = eolian_function_type_get(property);
std::string name = safe_str(eolian_function_name_get(property));
if (type == EOLIAN_PROP_GET || type == EOLIAN_PROPERTY)
{
const Eina_List *keys_ = eolian_property_keys_list_get(property);
efl::eolian::parameters_container_type params = _get_params
(eolian_parameters_list_get(property), true);
efl::eolian::eo_function getter;
getter.type = efl::eolian::eo_function::regular_;
getter.name = name + "_get";
getter.impl = (prefix != "" ? prefix : cxx_classname) + "_" + getter.name;
std::string ret = safe_str
(eolian_function_return_type_get(property, EOLIAN_PROP_GET));
if (ret == "") ret = "void";
// if the getter has a single parameter and void return
// we translate it to a getter with no parameters that
// returns its type.
if ((ret == "void") && params.size() == 1)
{
getter.ret = params[0].type;
getter.params.clear();
}
else // otherwise just create the described getter
{
getter.ret = ret;
getter.params = params;
std::transform
(params.begin(), params.end(), getter.params.begin(),
[](efl::eolian::eo_parameter const& param)
{
return efl::eolian::eo_parameter
{ param.type + "*", param.name };
});
}
if (eina_list_count(keys_) > 0)
{
efl::eolian::parameters_container_type keys = _get_params(keys_, true);
keys.reserve(keys.size() + getter.params.size());
keys.insert(keys.end(), getter.params.begin(), getter.params.end());
getter.params = keys;
}
getter.comment = detail::eolian_property_getter_comment(property);
container.push_back(getter);
}
if (type == EOLIAN_PROP_SET || type == EOLIAN_PROPERTY)
{
const Eina_List *keys_ = eolian_property_keys_list_get(property);
const Eina_List *args_ = eolian_parameters_list_get(property);
Eina_List *params_ = eina_list_merge(eina_list_clone(keys_), eina_list_clone(args_));
efl::eolian::parameters_container_type params = _get_params(params_);
eina_list_free(params_);
efl::eolian::eo_function setter;
setter.type = efl::eolian::eo_function::regular_;
setter.name = name + "_set";
setter.impl = (prefix != "" ? prefix : cxx_classname) + "_" + setter.name;
setter.params = params;
setter.ret = safe_str(eolian_function_return_type_get
(property, EOLIAN_PROP_SET));
if (setter.ret == "") setter.ret = "void";
setter.comment = detail::eolian_property_setter_comment(property);
container.push_back(setter);
}
}
return container;
}
namespace detail {
void
convert_eolian_inheritances(efl::eolian::eo_class& cls, const char *classname)
{
const Eina_List *inheritances = eolian_class_inherits_list_get(classname);
const Eina_List *it;
void *curr;
if (eina_list_count(inheritances) == 0
|| eina_list_data_get(inheritances) == NULL)
{
cls.parent = "efl::eo::base";
return;
}
else
{
std::string parent =
static_cast<const char*>(eina_list_data_get(inheritances));
std::transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
// "eo_base" is the Eolian name for EO_BASE_CLASS.
cls.parent = (parent == "eo_base" || parent == "") ? "efl::eo::base" : parent;
}
inheritances = eina_list_next(inheritances);
EINA_LIST_FOREACH (inheritances, it, curr)
{
std::string extension = static_cast<const char*>(curr);
std::transform
(extension.begin(), extension.end(), extension.begin(), ::tolower);
cls.extensions.push_back(extension);
}
}
void
convert_eolian_implements(efl::eolian::eo_class& cls, const char *classname)
{
const Eina_List *it;
void *curr;
std::string prefix(safe_str(eolian_class_eo_prefix_get(classname)));
const Eina_List *implements = eolian_class_implements_list_get(classname);
Eolian_Implement impl_desc;
void *impl_desc_;
EINA_LIST_FOREACH(eolian_class_implements_list_get(classname), it, impl_desc_)
{
Eolian_Implement impl_desc = static_cast<Eolian_Implement>(impl_desc_);
Eolian_Function_Type func_type;
const char *func_name;
const char *impl_class;
eolian_implement_information_get
(impl_desc, &impl_class, &func_name, &func_type);
#if 1 // XXX only due to a bug in Eolian we have to double-check
if(func_type == EOLIAN_UNRESOLVED &&
eolian_class_function_find_by_name(impl_class, func_name, EOLIAN_CTOR) != NULL)
func_type = EOLIAN_CTOR;
#endif
if (func_type == EOLIAN_CTOR)
{
efl::eolian::eo_constructor constructor;
Eolian_Function eolian_constructor = eolian_class_function_find_by_name
(impl_class, func_name, func_type);
assert(eolian_constructor != NULL);
std::string parent = safe_str(impl_class);
if(parent == "Eo_Base") parent = "eo";
else std::transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
constructor.name = parent + "_" + safe_str(func_name);
constructor.params = _get_params
(eolian_parameters_list_get(eolian_constructor));
constructor.comment = detail::eolian_constructor_comment
(eolian_constructor);
cls.constructors.push_back(constructor);
}
}
}
void
convert_eolian_constructors(efl::eolian::eo_class& cls, const char *classname)
{
const Eina_List *it;
void *curr;
std::string prefix(safe_str(eolian_class_eo_prefix_get(classname)));
const Eina_List *constructors =
eolian_class_functions_list_get(classname, EOLIAN_CTOR);
EINA_LIST_FOREACH (constructors, it, curr)
{
Eolian_Function eolian_constructor = static_cast<Eolian_Function>(curr);
efl::eolian::eo_constructor constructor;
constructor.name = (prefix != "" ? prefix : cls.name) + "_" + safe_str
(eolian_function_name_get(eolian_constructor));
constructor.params = _get_params
(eolian_parameters_list_get(eolian_constructor));
constructor.comment = detail::eolian_constructor_comment
(eolian_constructor);
cls.constructors.push_back(constructor);
}
}
void
convert_eolian_functions(efl::eolian::eo_class& cls, const char *classname)
{
const Eina_List *it;
void *curr;
const Eina_List *eolian_functions =
eolian_class_functions_list_get(classname, EOLIAN_METHOD);
EINA_LIST_FOREACH (eolian_functions, it, curr)
{
efl::eolian::eo_function function;
Eolian_Function eolian_function = static_cast<Eolian_Function>(curr);
std::string prefix(safe_str(eolian_class_eo_prefix_get(classname)));
// XXX Eolian only provides regular methods so far
function.type = efl::eolian::eo_function::regular_;
function.name = safe_str(eolian_function_name_get(eolian_function));
function.impl = ( prefix != "" ? prefix : cls.name ) + "_" + function.name;
function.ret = safe_str(eolian_function_return_type_get
(eolian_function, EOLIAN_METHOD));
if(function.ret == "") function.ret = "void";
function.params = _get_params(eolian_parameters_list_get(eolian_function));
function.comment = detail::eolian_function_comment(eolian_function);
cls.functions.push_back(function);
}
}
void
convert_eolian_properties(efl::eolian::eo_class& cls, const char *classname)
{
efl::eolian::functions_container_type properties = _get_properties(classname);
cls.functions.insert(cls.functions.end(), properties.begin(), properties.end());
}
} // namespace detail {
efl::eolian::eo_class
_cxx_new(const char *classname)
{
using namespace efl::eolian;
eo_class cls;
Eolian_Class_Type cls_type = ::eolian_class_type_get(classname);
if (cls_type == EOLIAN_CLASS_REGULAR) cls.type = eo_class::regular_;
else if (cls_type == EOLIAN_CLASS_ABSTRACT) cls.type = eo_class::regular_noninst_;
else if (cls_type == EOLIAN_CLASS_MIXIN) cls.type = eo_class::mixin_;
else if (cls_type == EOLIAN_CLASS_INTERFACE) cls.type = eo_class::interface_;
else { assert(false); }
std::string prefix(safe_str(eolian_class_eo_prefix_get(classname)));
cls.name = classname;
cls.eo_name = (prefix != "" ? prefix : cls.name) + "_CLASS";
cls.comment = detail::eolian_class_comment(classname);
std::transform(cls.name.begin(), cls.name.end(), cls.name.begin(), ::tolower);
std::transform(cls.eo_name.begin(), cls.eo_name.end(), cls.eo_name.begin(), ::toupper);
return cls;
}
efl::eolian::eo_class
c_to_cxx(const char *classname)
{
efl::eolian::eo_class cls(_cxx_new(classname));
detail::convert_eolian_inheritances(cls, classname);
detail::convert_eolian_implements(cls, classname);
detail::convert_eolian_constructors(cls, classname);
detail::convert_eolian_functions(cls, classname);
detail::convert_eolian_properties(cls, classname);
return cls;
}

View File

@ -0,0 +1,9 @@
#ifndef EOLIAN_CXX_EOLIAN_CONVERT_CLASSES_HH
#define EOLIAN_CXX_EOLIAN_CONVERT_CLASSES_HH
#include "eo_types.hh"
efl::eolian::eo_class c_to_cxx(const char *classname);