forked from enlightenment/efl
parent
8b6d230f5b
commit
4f3f37059c
|
@ -0,0 +1,5 @@
|
||||||
|
*.swp
|
||||||
|
Session.vim
|
||||||
|
tags
|
||||||
|
.clang_complete
|
||||||
|
/build
|
|
@ -0,0 +1,49 @@
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
project(eobj)
|
||||||
|
set(EOBJ_VERSION_MAJOR 0)
|
||||||
|
set(EOBJ_VERSION_MINOR 1)
|
||||||
|
set(EOBJ_VERSION_MICRO 0)
|
||||||
|
set(EOBJ_VERSION ${EOBJ_VERSION_MAJOR}.${EOBJ_VERSION_MINOR}.${EOBJ_VERSION_MICRO})
|
||||||
|
|
||||||
|
set(PACKAGE ${CMAKE_PROJECT_NAME})
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||||
|
|
||||||
|
include_directories ("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
|
find_package(Eina REQUIRED)
|
||||||
|
find_package(Evas REQUIRED)
|
||||||
|
find_package(Elementary REQUIRED)
|
||||||
|
|
||||||
|
# likely put this into an FindCompilerAttribute.cmake:
|
||||||
|
INCLUDE(CheckCSourceCompiles)
|
||||||
|
SET(HAVE___ATTRIBUTE__)
|
||||||
|
CHECK_C_SOURCE_COMPILES(
|
||||||
|
"void foo (int bar __attribute__((unused)) ) { }
|
||||||
|
static void baz (void) __attribute__((unused));
|
||||||
|
static void baz (void) { }
|
||||||
|
int main(){}
|
||||||
|
" HAVE___ATTRIBUTE__
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DPACKAGE_BIN_DIR="${CMAKE_INSTALL_PREFIX}/bin"
|
||||||
|
-DPACKAGE_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/${CMAKE_PROJECT_NAME}"
|
||||||
|
-DPACKAGE_LIB_DIR="${CMAKE_INSTALL_PREFIX}/lib")
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||||
|
|
||||||
|
configure_file (
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmakeconfig.h.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/config.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
include(EFLCheck)
|
||||||
|
|
||||||
|
add_subdirectory(lib)
|
||||||
|
add_subdirectory(examples/evas)
|
||||||
|
add_subdirectory(examples/mixin)
|
||||||
|
add_subdirectory(examples/signals)
|
||||||
|
add_subdirectory(examples/access)
|
||||||
|
add_subdirectory(examples/constructors)
|
||||||
|
|
||||||
|
add_subdirectory(tests EXCLUDE_FROM_ALL)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
include(CTest)
|
||||||
|
ENABLE_TESTING()
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
|
||||||
|
|
||||||
|
find_package(Check)
|
||||||
|
set (CHECK_ENABLED ${CHECK_FOUND})
|
||||||
|
|
||||||
|
set(EFL_COVERAGE false CACHE BOOL "Whether coverage support should be built.'")
|
||||||
|
if (EFL_COVERAGE)
|
||||||
|
include(EFLlcov REQUIRED)
|
||||||
|
ENABLE_COVERAGE()
|
||||||
|
endif (EFL_COVERAGE)
|
|
@ -0,0 +1,31 @@
|
||||||
|
macro(ENABLE_COVERAGE)
|
||||||
|
if (CHECK_ENABLED)
|
||||||
|
find_program(LCOV_BINARY lcov HINTS ${EFL_LCOV_PATH})
|
||||||
|
find_program(GENHTML_BINARY genhtml HINTS ${EFL_LCOV_PATH})
|
||||||
|
set(EFL_COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage")
|
||||||
|
set(EFL_COVERAGE_LIBS "gcov")
|
||||||
|
endif (CHECK_ENABLED)
|
||||||
|
|
||||||
|
if (DEFINED LCOV_BINARY)
|
||||||
|
set(EFL_COVERAGE_ENABLED true)
|
||||||
|
add_custom_target(lcov-reset
|
||||||
|
COMMAND rm -rf ${CMAKE_BINARY_DIR}/coverage
|
||||||
|
COMMAND find ${CMAKE_BINARY_DIR} -name "*.gcda" -delete
|
||||||
|
COMMAND ${LCOV_BINARY} --zerocounters --directory ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(lcov-report
|
||||||
|
COMMAND mkdir ${CMAKE_BINARY_DIR}/coverage
|
||||||
|
COMMAND ${LCOV_BINARY} --capture --compat-libtool --output-file ${CMAKE_BINARY_DIR}/coverage/coverage.info --directory ${CMAKE_BINARY_DIR}
|
||||||
|
COMMAND ${LCOV_BINARY} --remove ${CMAKE_BINARY_DIR}/coverage/coverage.info '*.h' --output-file ${CMAKE_BINARY_DIR}/coverage/coverage.cleaned.info
|
||||||
|
COMMAND ${GENHTML_BINARY} -t "${PACKAGE}" -o "${CMAKE_BINARY_DIR}/coverage/html" "${CMAKE_BINARY_DIR}/coverage/coverage.cleaned.info"
|
||||||
|
COMMAND echo "Coverage Report at ${CMAKE_BINARY_DIR}/coverage/html"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(coverage
|
||||||
|
COMMAND ${CMAKE_MAKE_PROGRAM} lcov-reset
|
||||||
|
COMMAND ${CMAKE_MAKE_PROGRAM} check
|
||||||
|
COMMAND ${CMAKE_MAKE_PROGRAM} lcov-report
|
||||||
|
)
|
||||||
|
endif (DEFINED LCOV_BINARY)
|
||||||
|
endmacro(ENABLE_COVERAGE)
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find check
|
||||||
|
# Once done this will define
|
||||||
|
# CHECK_FOUND - System has check
|
||||||
|
# CHECK_INCLUDE_DIRS - The check include directories
|
||||||
|
# CHECK_LIBRARIES - The libraries needed to use check
|
||||||
|
# CHECK_DEFINITIONS - Compiler switches required for using check
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBCHECK QUIET check)
|
||||||
|
set(CHECK_DEFINITIONS ${PC_LIBCHECK_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(CHECK_INCLUDE_DIR check.h
|
||||||
|
HINTS ${PC_LIBCHECK_INCLUDEDIR} ${PC_LIBCHECK_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES check )
|
||||||
|
|
||||||
|
find_library(CHECK_LIBRARY NAMES check
|
||||||
|
HINTS ${PC_LIBCHECK_LIBDIR} ${PC_LIBCHECK_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(CHECK_LIBRARIES ${CHECK_LIBRARY} )
|
||||||
|
set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set CHECK_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(check DEFAULT_MSG
|
||||||
|
CHECK_LIBRARY CHECK_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARY )
|
|
@ -0,0 +1,59 @@
|
||||||
|
# - Try to find ecore
|
||||||
|
# Once done this will define
|
||||||
|
# ECORE_FOUND - System has ecore
|
||||||
|
# ECORE_INCLUDE_DIRS - The ecore include directories
|
||||||
|
# ECORE_LIBRARIES - The libraries needed to use ecore
|
||||||
|
# ECORE_DEFINITIONS - Compiler switches required for using ecore
|
||||||
|
|
||||||
|
# Use FIND_PACKAGE( Ecore COMPONENTS ... ) to enable modules
|
||||||
|
IF( Ecore_FIND_COMPONENTS )
|
||||||
|
FOREACH( component ${Ecore_FIND_COMPONENTS} )
|
||||||
|
STRING( TOUPPER ${component} _COMPONENT )
|
||||||
|
SET( ECORE_USE_${_COMPONENT} 1 )
|
||||||
|
ENDFOREACH( component )
|
||||||
|
ENDIF( Ecore_FIND_COMPONENTS )
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBECORE QUIET ecore)
|
||||||
|
set(ECORE_DEFINITIONS ${PC_LIBECORE_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(ECORE_INCLUDE_DIR Ecore.h
|
||||||
|
HINTS ${PC_LIBECORE_INCLUDEDIR} ${PC_LIBECORE_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES ecore )
|
||||||
|
|
||||||
|
find_library(ECORE_LIBRARY NAMES ecore
|
||||||
|
HINTS ${PC_LIBECORE_LIBDIR} ${PC_LIBECORE_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(ECORE_LIBRARIES ${ECORE_LIBRARY} )
|
||||||
|
set(ECORE_INCLUDE_DIRS ${ECORE_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set ECORE_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(ecore DEFAULT_MSG
|
||||||
|
ECORE_LIBRARY ECORE_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced( ECORE_INCLUDE_DIR ECORE_LIBRARY )
|
||||||
|
|
||||||
|
if (ECORE_USE_ECORE-X)
|
||||||
|
pkg_check_modules(PC_LIBECORE_X QUIET ecore-x)
|
||||||
|
set(ECORE_X_DEFINITIONS ${PC_LIBECORE_X_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(ECORE_X_INCLUDE_DIR Ecore_X.h
|
||||||
|
HINTS ${PC_LIBECORE_X_INCLUDEDIR} ${PC_LIBECORE_X_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES ecore )
|
||||||
|
|
||||||
|
find_library(ECORE_X_LIBRARY NAMES ecore_x
|
||||||
|
HINTS ${PC_LIBECORE_X_LIBDIR} ${PC_LIBECORE_X_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(ECORE_X_LIBRARIES ${ECORE_X_LIBRARY} )
|
||||||
|
set(ECORE_X_INCLUDE_DIRS ${ECORE_X_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set ECORE_X_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(ecore_x DEFAULT_MSG
|
||||||
|
ECORE_X_LIBRARY ECORE_X_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced( ECORE_X_INCLUDE_DIR ECORE_X_LIBRARY )
|
||||||
|
endif (ECORE_USE_ECORE-X)
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find edje
|
||||||
|
# Once done this will define
|
||||||
|
# EDJE_FOUND - System has edje
|
||||||
|
# EDJE_INCLUDE_DIRS - The edje include directories
|
||||||
|
# EDJE_LIBRARIES - The libraries needed to use edje
|
||||||
|
# EDJE_DEFINITIONS - Compiler switches required for using edje
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBEDJE QUIET edje)
|
||||||
|
set(EDJE_DEFINITIONS ${PC_LIBEDJE_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(EDJE_INCLUDE_DIR Edje.h
|
||||||
|
HINTS ${PC_LIBEDJE_INCLUDEDIR} ${PC_LIBEDJE_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES edje )
|
||||||
|
|
||||||
|
find_library(EDJE_LIBRARY NAMES edje
|
||||||
|
HINTS ${PC_LIBEDJE_LIBDIR} ${PC_LIBEDJE_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EDJE_LIBRARIES ${EDJE_LIBRARY} )
|
||||||
|
set(EDJE_INCLUDE_DIRS ${EDJE_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EDJE_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(edje DEFAULT_MSG
|
||||||
|
EDJE_LIBRARY EDJE_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(EDJE_INCLUDE_DIR EDJE_LIBRARY )
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find eet
|
||||||
|
# Once done this will define
|
||||||
|
# EET_FOUND - System has eet
|
||||||
|
# EET_INCLUDE_DIRS - The eet include directories
|
||||||
|
# EET_LIBRARIES - The libraries needed to use eet
|
||||||
|
# EET_DEFINITIONS - Compiler switches required for using eet
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBEET QUIET eet)
|
||||||
|
set(EET_DEFINITIONS ${PC_LIBEET_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(EET_INCLUDE_DIR Eet.h
|
||||||
|
HINTS ${PC_LIBEET_INCLUDEDIR} ${PC_LIBEET_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES eet )
|
||||||
|
|
||||||
|
find_library(EET_LIBRARY NAMES eet
|
||||||
|
HINTS ${PC_LIBEET_LIBDIR} ${PC_LIBEET_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EET_LIBRARIES ${EET_LIBRARY} )
|
||||||
|
set(EET_INCLUDE_DIRS ${EET_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EET_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(eet DEFAULT_MSG
|
||||||
|
EET_LIBRARY EET_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced( EET_INCLUDE_DIR EET_LIBRARY )
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find efreet
|
||||||
|
# Once done this will define
|
||||||
|
# EFREET_FOUND - System has efreet
|
||||||
|
# EFREET_INCLUDE_DIRS - The efreet include directories
|
||||||
|
# EFREET_LIBRARIES - The libraries needed to use efreet
|
||||||
|
# EFREET_DEFINITIONS - Compiler switches required for using efreet
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBEFREET QUIET efreet)
|
||||||
|
set(EFREET_DEFINITIONS ${PC_LIBEFREET_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(EFREET_INCLUDE_DIR Efreet.h
|
||||||
|
HINTS ${PC_LIBEFREET_INCLUDEDIR} ${PC_LIBEFREET_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES efreet )
|
||||||
|
|
||||||
|
find_library(EFREET_LIBRARY NAMES efreet
|
||||||
|
HINTS ${PC_LIBEFREET_LIBDIR} ${PC_LIBEFREET_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EFREET_LIBRARIES ${EFREET_LIBRARY} )
|
||||||
|
set(EFREET_INCLUDE_DIRS ${EFREET_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EFREET_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(efreet DEFAULT_MSG
|
||||||
|
EFREET_LIBRARY EFREET_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(EFREET_INCLUDE_DIR EFREET_LIBRARY )
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find eina
|
||||||
|
# Once done this will define
|
||||||
|
# EINA_FOUND - System has eina
|
||||||
|
# EINA_INCLUDE_DIRS - The eina include directories
|
||||||
|
# EINA_LIBRARIES - The libraries needed to use eina
|
||||||
|
# EINA_DEFINITIONS - Compiler switches required for using eina
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBEINA QUIET eina)
|
||||||
|
set(EINA_DEFINITIONS ${PC_LIBEINA_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(EINA_INCLUDE_DIR Eina.h
|
||||||
|
HINTS ${PC_LIBEINA_INCLUDEDIR} ${PC_LIBEINA_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES eina )
|
||||||
|
|
||||||
|
find_library(EINA_LIBRARY NAMES eina
|
||||||
|
HINTS ${PC_LIBEINA_LIBDIR} ${PC_LIBEINA_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EINA_LIBRARIES ${EINA_LIBRARY} )
|
||||||
|
set(EINA_INCLUDE_DIRS ${EINA_INCLUDE_DIR} "${EINA_INCLUDE_DIR}/eina" )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(eina DEFAULT_MSG
|
||||||
|
EINA_LIBRARY EINA_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(EINA_INCLUDE_DIR EINA_LIBRARY )
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find elementary
|
||||||
|
# Once done this will define
|
||||||
|
# ELEMENTARY_FOUND - System has elementary
|
||||||
|
# ELEMENTARY_INCLUDE_DIRS - The elementary include directories
|
||||||
|
# ELEMENTARY_LIBRARIES - The libraries needed to use elementary
|
||||||
|
# ELEMENTARY_DEFINITIONS - Compiler switches required for using elementary
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBELEMENTARY QUIET elementary)
|
||||||
|
set(ELEMENTARY_DEFINITIONS ${PC_LIBELEMENTARY_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(ELEMENTARY_INCLUDE_DIR Elementary.h
|
||||||
|
HINTS ${PC_LIBELEMENTARY_INCLUDEDIR} ${PC_LIBELEMENTARY_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES elementary )
|
||||||
|
|
||||||
|
find_library(ELEMENTARY_LIBRARY NAMES elementary
|
||||||
|
HINTS ${PC_LIBELEMENTARY_LIBDIR} ${PC_LIBELEMENTARY_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(ELEMENTARY_LIBRARIES ${ELEMENTARY_LIBRARY} )
|
||||||
|
set(ELEMENTARY_INCLUDE_DIRS ${PC_LIBELEMENTARY_INCLUDEDIR} ${PC_LIBELEMENTARY_INCLUDE_DIRS} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set ELEMENTARY_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(elementary DEFAULT_MSG
|
||||||
|
ELEMENTARY_LIBRARY ELEMENTARY_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(ELEMENTARY_INCLUDE_DIR ELEMENTARY_LIBRARY )
|
|
@ -0,0 +1,28 @@
|
||||||
|
# - Try to find evas
|
||||||
|
# Once done this will define
|
||||||
|
# EVAS_FOUND - System has evas
|
||||||
|
# EVAS_INCLUDE_DIRS - The evas include directories
|
||||||
|
# EVAS_LIBRARIES - The libraries needed to use evas
|
||||||
|
# EVAS_DEFINITIONS - Compiler switches required for using evas
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_LIBEVAS QUIET evas)
|
||||||
|
set(EVAS_DEFINITIONS ${PC_LIBEVAS_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
find_path(EVAS_INCLUDE_DIR Evas.h
|
||||||
|
HINTS ${PC_LIBEVAS_INCLUDEDIR} ${PC_LIBEVAS_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES evas )
|
||||||
|
|
||||||
|
find_library(EVAS_LIBRARY NAMES evas
|
||||||
|
HINTS ${PC_LIBEVAS_LIBDIR} ${PC_LIBEVAS_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
set(EVAS_LIBRARIES ${EVAS_LIBRARY} )
|
||||||
|
set(EVAS_INCLUDE_DIRS ${EVAS_INCLUDE_DIR} )
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set EVAS_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(evas DEFAULT_MSG
|
||||||
|
EVAS_LIBRARY EVAS_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(EVAS_INCLUDE_DIR EVAS_LIBRARY )
|
|
@ -0,0 +1,122 @@
|
||||||
|
# - adds support for the 'make distcheck' command -*- cmake -*-
|
||||||
|
# Dependencies:
|
||||||
|
# 1. CPack generating ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz.
|
||||||
|
# 2. Having a "dist" target, e.g:
|
||||||
|
# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
||||||
|
# Usage:
|
||||||
|
# add_distcheck() ... called exactly once per project in the top-level
|
||||||
|
# CMakeLists.txt; it adds the 'dist' and 'distcheck'
|
||||||
|
# targets
|
||||||
|
#
|
||||||
|
# This module implements the 'make dist' and 'make distcheck'
|
||||||
|
# commands.
|
||||||
|
# It supports the following variables:
|
||||||
|
#
|
||||||
|
# DISTCHECK_TMPDIR ... directory for temporary files
|
||||||
|
# DISTCHECK_FILENAME ... basename of existing tar.gz.; defaults to
|
||||||
|
# ${CPACK_SOURCE_PACKAGE_FILE_NAME}
|
||||||
|
# DISTCHECK_CMAKEFLAGS
|
||||||
|
# ... flags which are given to 'cmake' by 'make distcheck'
|
||||||
|
# DISTCHECK_BUILDTARGETS
|
||||||
|
# ... the build-targets tried by 'make distcheck';
|
||||||
|
# defaults to nothing (--> all)
|
||||||
|
# DISTCHECK_INSTALLTARGETS
|
||||||
|
# ... the install-targets tried by 'make distcheck';
|
||||||
|
# defaults to 'install'
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# --- top-level CMakeLists.txt ---
|
||||||
|
# add_subdirectory(foo)
|
||||||
|
# ...
|
||||||
|
# ...
|
||||||
|
# set(CPACK_PACKAGE_VERSION_MAJOR ${ECRIRE_VERSION_MAJOR})
|
||||||
|
# set(CPACK_PACKAGE_VERSION_MINOR ${ECRIRE_VERSION_MINOR})
|
||||||
|
# set(CPACK_PACKAGE_VERSION_PATCH ${ECRIRE_VERSION_MICRO})
|
||||||
|
# set(CPACK_SOURCE_GENERATOR "TGZ")
|
||||||
|
# set(CPACK_SOURCE_IGNORE_FILES
|
||||||
|
# "${CMAKE_BINARY_DIR};/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
|
||||||
|
# include(CPack)
|
||||||
|
# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
||||||
|
#
|
||||||
|
# find_package(Distcheck)
|
||||||
|
# add_distcheck()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Tom Hacohen <tom@stosb.com>
|
||||||
|
# Based on the work done by:
|
||||||
|
# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
||||||
|
#
|
||||||
|
# Redistribution and use, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions must retain the above copyright notice, this
|
||||||
|
# list of conditions and the following disclaimer.
|
||||||
|
# 2. The name of the author may not be used to endorse or promote
|
||||||
|
# products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
|
||||||
|
macro(add_distcheck)
|
||||||
|
set(MakeDist_FOUND 1)
|
||||||
|
|
||||||
|
set(DISTCHECK_TMPDIR "${CMAKE_BINARY_DIR}/.make-dist" CACHE PATH "directory for temporary files created by'make dist*'")
|
||||||
|
set(DISTCHECK_FILENAME ${CPACK_SOURCE_PACKAGE_FILE_NAME} CACHE PATH "basename of the tarball created by 'make dist'")
|
||||||
|
set(DISTCHECK_CMAKEFLAGS CACHE STRING "flags which are given to 'cmake' by 'make distcheck'")
|
||||||
|
set(DISTCHECK_BUILDTARGETS "" CACHE STRING "build-target(s) tried by 'make distcheck'")
|
||||||
|
set(DISTCHECK_INSTALLTARGETS install CACHE STRING "install-target(s) tried by 'make distcheck'")
|
||||||
|
|
||||||
|
mark_as_advanced(DISTCHECK_TMPDIR DISTCHECK_FILENAME DISTCHECK_CMAKEFLAGS DISTCHECK_BUILDTARGETS DISTCHECK_INSTALLTARGETS)
|
||||||
|
|
||||||
|
set(DISTCHECK_BASESOURCEDIR "${DISTCHECK_TMPDIR}/source")
|
||||||
|
set(DISTCHECK_SOURCEDIR "${DISTCHECK_BASESOURCEDIR}/${DISTCHECK_FILENAME}")
|
||||||
|
set(DISTCHECK_BUILDDIR "${DISTCHECK_TMPDIR}/build")
|
||||||
|
set(DISTCHECK_INSTALLTARGETS "install")
|
||||||
|
add_custom_target(distcheck
|
||||||
|
# Create the tarball
|
||||||
|
COMMAND ${CMAKE_MAKE_PROGRAM} dist
|
||||||
|
|
||||||
|
# Create the temp dir.
|
||||||
|
COMMAND chmod -Rf a+w "${DISTCHECK_TMPDIR}" 2>/dev/null || :
|
||||||
|
COMMAND rm -rf "${DISTCHECK_TMPDIR}"
|
||||||
|
COMMAND mkdir -p "${DISTCHECK_SOURCEDIR}" "${DISTCHECK_BUILDDIR}"
|
||||||
|
|
||||||
|
# extract tarball
|
||||||
|
COMMAND tar xzf ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz -C "${DISTCHECK_BASESOURCEDIR}"
|
||||||
|
# write-protect sources to detect modifies-sourcetree bugs
|
||||||
|
COMMAND chmod -R a-w "${DISTCHECK_SOURCEDIR}"
|
||||||
|
|
||||||
|
COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH="${DISTCHECK_TMPDIR}/install" ${DISTCHECK_CMAKEFLAGS} "${DISTCHECK_SOURCEDIR}"
|
||||||
|
|
||||||
|
COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_BUILDTARGETS}
|
||||||
|
|
||||||
|
# execute 'make install' without DESTDIR
|
||||||
|
COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR=
|
||||||
|
# write protect installation path to detect writing outside of DESTDIR
|
||||||
|
COMMAND chmod -R a-w "${DISTCHECK_TMPDIR}/install"
|
||||||
|
# execute 'make install' with DESTDIR and move the files to a better location
|
||||||
|
COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR="${DISTCHECK_TMPDIR}/install-tmp"
|
||||||
|
COMMAND mv "${DISTCHECK_TMPDIR}/install-tmp/${DISTCHECK_TMPDIR}/install" "${DISTCHECK_TMPDIR}/install-destdir"
|
||||||
|
|
||||||
|
# generate list of files which were installed by the both 'make
|
||||||
|
# install' commands above and compare them
|
||||||
|
COMMAND cd "${DISTCHECK_TMPDIR}/install" && find -type f | sort > ../files.install
|
||||||
|
COMMAND cd "${DISTCHECK_TMPDIR}/install-destdir" && find -type f | sort > ../files.destdir
|
||||||
|
COMMAND cd "${DISTCHECK_TMPDIR}" && diff files.install files.destdir
|
||||||
|
|
||||||
|
# cleanup tmpdir
|
||||||
|
COMMAND chmod -R u+Xw "${DISTCHECK_TMPDIR}" 2>/dev/null || :
|
||||||
|
COMMAND rm -rf "${DISTCHECK_TMPDIR}"
|
||||||
|
)
|
||||||
|
endmacro(add_distcheck)
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#define PACKAGE "@CMAKE_PROJECT_NAME@"
|
||||||
|
#define PACKAGE_NAME PACKAGE
|
||||||
|
#define VERSION "@EOBJ_VERSION@"
|
||||||
|
#define VMAJ @EOBJ_VERSION_MAJOR@
|
||||||
|
#define VMIN @EOBJ_VERSION_MINOR@
|
||||||
|
#define VMIC @EOBJ_VERSION_MICRO@
|
||||||
|
|
||||||
|
#cmakedefine HAVE___ATTRIBUTE__
|
||||||
|
#ifdef HAVE___ATTRIBUTE__
|
||||||
|
#define __UNUSED__ __attribute__((unused))
|
||||||
|
#else
|
||||||
|
#define __UNUSED__
|
||||||
|
#endif
|
|
@ -0,0 +1,23 @@
|
||||||
|
LIST(APPEND ACCESS_CC_SOURCES
|
||||||
|
main.c
|
||||||
|
simple.c
|
||||||
|
inherit.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
${EVAS_INCLUDE_DIRS}
|
||||||
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(access ${ACCESS_CC_SOURCES})
|
||||||
|
|
||||||
|
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||||
|
target_link_libraries(access
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${eobj_LIB_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(access eobj)
|
||||||
|
|
||||||
|
add_test(Example_access access)
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
#include "simple_protected.h"
|
||||||
|
|
||||||
|
#include "inherit.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op INHERIT_BASE_ID = 0;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_prot_print(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Simple_Protected_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||||
|
(void) op;
|
||||||
|
(void) list;
|
||||||
|
printf("%s %d\n", __func__, pd->protected_x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT), _prot_print),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
inherit_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(INHERIT_SUB_ID_PROT_PRINT, "", "Print protected var x1."),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Inherit",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&INHERIT_BASE_ID, op_desc, INHERIT_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef INHERIT_H
|
||||||
|
#define INHERIT_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op INHERIT_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
INHERIT_SUB_ID_PROT_PRINT,
|
||||||
|
INHERIT_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define INHERIT_ID(sub_id) (INHERIT_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define INHERIT_PROT_PRINT() INHERIT_ID(INHERIT_SUB_ID_PROT_PRINT)
|
||||||
|
|
||||||
|
#define INHERIT_CLASS inherit_class_get()
|
||||||
|
const Eobj_Class *inherit_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
#include "inherit.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
|
eobj_init();
|
||||||
|
|
||||||
|
Eobj *obj = eobj_add(INHERIT_CLASS, NULL);
|
||||||
|
|
||||||
|
eobj_do(obj, SIMPLE_A_SET(1), INHERIT_PROT_PRINT());
|
||||||
|
|
||||||
|
Simple_Public_Data *pd = eobj_data_get(obj, SIMPLE_CLASS);
|
||||||
|
printf("Pub: %d\n", pd->public_x2);
|
||||||
|
|
||||||
|
eobj_unref(obj);
|
||||||
|
eobj_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
#include "simple_protected.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Simple_Protected_Data protected;
|
||||||
|
int a;
|
||||||
|
} Private_Data;
|
||||||
|
|
||||||
|
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||||
|
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Private_Data *pd = eobj_data_get(obj, _my_class);
|
||||||
|
(void) op;
|
||||||
|
int a;
|
||||||
|
a = va_arg(*list, int);
|
||||||
|
pd->a = a;
|
||||||
|
printf("%s %d\n", __func__, pd->a);
|
||||||
|
|
||||||
|
pd->protected.protected_x1 = a + 1;
|
||||||
|
pd->protected.public.public_x2 = a + 2;
|
||||||
|
|
||||||
|
eobj_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Event_Description *event_desc[] = {
|
||||||
|
SIG_A_CHANGED,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||||
|
event_desc,
|
||||||
|
sizeof(Private_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SIMPLE_H
|
||||||
|
#define SIMPLE_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SIMPLE_SUB_ID_A_SET,
|
||||||
|
SIMPLE_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int public_x2;
|
||||||
|
} Simple_Public_Data;
|
||||||
|
|
||||||
|
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define SIMPLE_A_SET(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||||
|
|
||||||
|
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||||
|
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||||
|
|
||||||
|
#define SIMPLE_CLASS simple_class_get()
|
||||||
|
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef SIMPLE_PROTECTED_H
|
||||||
|
#define SIMPLE_PROTECTED_H
|
||||||
|
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Simple_Public_Data public;
|
||||||
|
int protected_x1;
|
||||||
|
} Simple_Protected_Data;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,26 @@
|
||||||
|
LIST(APPEND CONSTRUCTORS_CC_SOURCES
|
||||||
|
main.c
|
||||||
|
simple.c
|
||||||
|
simple2.c
|
||||||
|
simple3.c
|
||||||
|
simple4.c
|
||||||
|
mixin.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
${EVAS_INCLUDE_DIRS}
|
||||||
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(constructors ${CONSTRUCTORS_CC_SOURCES})
|
||||||
|
|
||||||
|
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||||
|
target_link_libraries(constructors
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${eobj_LIB_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(constructors eobj)
|
||||||
|
|
||||||
|
add_test(Example_constructors constructors)
|
|
@ -0,0 +1,73 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
#include "simple2.h"
|
||||||
|
#include "simple3.h"
|
||||||
|
#include "simple4.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
|
||||||
|
int my_init_count = 0;
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
|
eobj_init();
|
||||||
|
|
||||||
|
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||||
|
|
||||||
|
if (my_init_count != 2)
|
||||||
|
{
|
||||||
|
printf("Error! my_init_count == %d\n", my_init_count);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
eobj_do(obj, SIMPLE_A_SET(1), SIMPLE_B_SET(2));
|
||||||
|
|
||||||
|
int a, b;
|
||||||
|
eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b), MIXIN_ADD_AND_PRINT(5));
|
||||||
|
|
||||||
|
eobj_unref(obj);
|
||||||
|
|
||||||
|
if (my_init_count != 0)
|
||||||
|
{
|
||||||
|
printf("Error! my_init_count == %d\n", my_init_count);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = eobj_add(SIMPLE2_CLASS, NULL);
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
printf("Error! obj is supposed to be NULL.\n");
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = eobj_add(SIMPLE3_CLASS, NULL);
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
printf("Error! obj is supposed to be NULL.\n");
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my_init_count = 0;
|
||||||
|
obj = eobj_add(SIMPLE4_CLASS, NULL);
|
||||||
|
|
||||||
|
if (my_init_count != 2)
|
||||||
|
{
|
||||||
|
printf("Error! my_init_count == %d\n", my_init_count);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
eobj_unref(obj);
|
||||||
|
|
||||||
|
if (my_init_count != 0)
|
||||||
|
{
|
||||||
|
printf("Error! my_init_count == %d\n", my_init_count);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
eobj_shutdown();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op MIXIN_BASE_ID = 0;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_add_and_print_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
(void) op;
|
||||||
|
int a, b, x;
|
||||||
|
eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b));
|
||||||
|
x = va_arg(*list, const int);
|
||||||
|
printf("%s %d\n", __func__, a + b + x);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int my_init_count;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
my_init_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
|
||||||
|
my_init_count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
mixin_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(MIXIN_SUB_ID_ADD_AND_SET, "i", "Add A + B + param and print it"),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Mixin",
|
||||||
|
EOBJ_CLASS_TYPE_MIXIN,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef MIXIN_H
|
||||||
|
#define MIXIN_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op MIXIN_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MIXIN_SUB_ID_ADD_AND_SET,
|
||||||
|
MIXIN_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define MIXIN_ADD_AND_PRINT(x) MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), EOBJ_TYPECHECK(int, x)
|
||||||
|
|
||||||
|
#define MIXIN_CLASS mixin_class_get()
|
||||||
|
const Eobj_Class *mixin_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,98 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
} Private_Data;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
#define _GET_SET_FUNC(name) \
|
||||||
|
static void \
|
||||||
|
_##name##_get(Eobj *obj, Eobj_Op op, va_list *list) \
|
||||||
|
{ \
|
||||||
|
Private_Data *pd = eobj_data_get(obj, _my_class); \
|
||||||
|
(void) op; \
|
||||||
|
int *name; \
|
||||||
|
name = va_arg(*list, int *); \
|
||||||
|
*name = pd->name; \
|
||||||
|
printf("%s %d\n", __func__, pd->name); \
|
||||||
|
} \
|
||||||
|
static void \
|
||||||
|
_##name##_set(Eobj *obj, Eobj_Op op, va_list *list) \
|
||||||
|
{ \
|
||||||
|
Private_Data *pd = eobj_data_get(obj, _my_class); \
|
||||||
|
(void) op; \
|
||||||
|
int name; \
|
||||||
|
name = va_arg(*list, int); \
|
||||||
|
pd->name = name; \
|
||||||
|
printf("%s %d\n", __func__, pd->name); \
|
||||||
|
}
|
||||||
|
|
||||||
|
_GET_SET_FUNC(a)
|
||||||
|
_GET_SET_FUNC(b)
|
||||||
|
|
||||||
|
extern int my_init_count;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
my_init_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
|
||||||
|
my_init_count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
sizeof(Private_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, MIXIN_CLASS, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef SIMPLE_H
|
||||||
|
#define SIMPLE_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SIMPLE_SUB_ID_A_SET,
|
||||||
|
SIMPLE_SUB_ID_A_GET,
|
||||||
|
SIMPLE_SUB_ID_B_SET,
|
||||||
|
SIMPLE_SUB_ID_B_GET,
|
||||||
|
SIMPLE_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define SIMPLE_A_SET(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||||
|
#define SIMPLE_A_GET(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EOBJ_TYPECHECK(int *, a)
|
||||||
|
#define SIMPLE_B_SET(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EOBJ_TYPECHECK(int, b)
|
||||||
|
#define SIMPLE_B_GET(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EOBJ_TYPECHECK(int *, b)
|
||||||
|
|
||||||
|
#define SIMPLE_CLASS simple_class_get()
|
||||||
|
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple2.h"
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
eobj_constructor_error_set(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple2_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple2",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
_my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
return _my_class;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef SIMPLE2_H
|
||||||
|
#define SIMPLE2_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
#define SIMPLE2_CLASS simple2_class_get()
|
||||||
|
const Eobj_Class *simple2_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple3.h"
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
(void) obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple3_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple3",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
_my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
return _my_class;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef SIMPLE3_H
|
||||||
|
#define SIMPLE3_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
#define SIMPLE3_CLASS simple3_class_get()
|
||||||
|
const Eobj_Class *simple3_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple.h"
|
||||||
|
#include "simple4.h"
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple4_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple4",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
_my_class = eobj_class_new(&class_desc, SIMPLE_CLASS, MIXIN_CLASS, NULL);
|
||||||
|
return _my_class;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef SIMPLE4_H
|
||||||
|
#define SIMPLE4_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
#define SIMPLE4_CLASS simple4_class_get()
|
||||||
|
const Eobj_Class *simple4_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,26 @@
|
||||||
|
LIST(APPEND EVAS_CC_SOURCES
|
||||||
|
elw_box.c
|
||||||
|
elw_boxedbutton.c
|
||||||
|
elw_win.c
|
||||||
|
elw_button.c
|
||||||
|
evas_obj.c
|
||||||
|
test.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
${EVAS_INCLUDE_DIRS}
|
||||||
|
${ELEMENTARY_INCLUDE_DIRS}
|
||||||
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(evas ${EVAS_CC_SOURCES})
|
||||||
|
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||||
|
target_link_libraries(evas
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${EVAS_LIBRARIES}
|
||||||
|
${ELEMENTARY_LIBRARIES}
|
||||||
|
${eobj_LIB_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(evas eobj)
|
|
@ -0,0 +1,88 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "evas_obj.h"
|
||||||
|
#include "elw_box.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op ELW_BOX_BASE_ID = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Evas_Object *bx;
|
||||||
|
} Widget_Data;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_pack_end(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
(void) op;
|
||||||
|
Eobj *child_obj;
|
||||||
|
child_obj = va_arg(*list, Eobj *);
|
||||||
|
/* FIXME: Ref and the later uref child_obj here... */
|
||||||
|
elm_box_pack_end(wd->bx, eobj_evas_object_get(child_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
|
||||||
|
/* FIXME: An hack, because our tree is not yet only Eobj */
|
||||||
|
wd->bx = elm_box_add(eobj_evas_object_get(eobj_parent_get(obj)));
|
||||||
|
evas_object_size_hint_align_set(wd->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
evas_object_size_hint_weight_set(wd->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
|
||||||
|
eobj_evas_object_set(obj, wd->bx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
|
||||||
|
//Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
/* FIXME: Commented out because it's automatically done because our tree
|
||||||
|
* is not made of only eobj */
|
||||||
|
// evas_object_del(wd->bx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), _pack_end),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
elw_box_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(ELW_BOX_SUB_ID_PACK_END, "o", "Pack obj at the end of box."),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Elw Box",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BOX_BASE_ID, op_desc, ELW_BOX_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
sizeof(Widget_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef ELW_BOX_H
|
||||||
|
#define ELW_BOX_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op ELW_BOX_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ELW_BOX_SUB_ID_PACK_END,
|
||||||
|
ELW_BOX_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ELW_BOX_ID(sub_id) (ELW_BOX_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define ELW_BOX_PACK_END(obj) ELW_BOX_ID(ELW_BOX_SUB_ID_PACK_END), EOBJ_TYPECHECK(Eobj *, obj)
|
||||||
|
|
||||||
|
#define ELW_BOX_CLASS elw_box_class_get()
|
||||||
|
const Eobj_Class *elw_box_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "evas_obj.h"
|
||||||
|
#include "elw_box.h"
|
||||||
|
#include "elw_button.h"
|
||||||
|
#include "elw_boxedbutton.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// Evas_Object *bx;
|
||||||
|
} Widget_Data;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
Eobj *bt = eobj_add(ELW_BUTTON_CLASS, obj);
|
||||||
|
eobj_composite_object_attach(obj, bt);
|
||||||
|
eobj_event_callback_forwarder_add(bt, SIG_CLICKED, obj);
|
||||||
|
eobj_do(bt, EVAS_OBJ_VISIBILITY_SET(EINA_TRUE));
|
||||||
|
|
||||||
|
eobj_do(obj, ELW_BOX_PACK_END(bt));
|
||||||
|
eobj_unref(bt);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
elw_boxedbutton_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Elw BoxedButton",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||||
|
NULL,
|
||||||
|
sizeof(Widget_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, ELW_BOX_CLASS,
|
||||||
|
ELW_BUTTON_CLASS, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef ELW_BOXEDBUTTON_H
|
||||||
|
#define ELW_BOXEDBUTTON_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
#define ELW_BOXEDBUTTON_CLASS elw_boxedbutton_class_get()
|
||||||
|
const Eobj_Class *elw_boxedbutton_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,118 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "evas_obj.h"
|
||||||
|
#include "elw_button.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op ELW_BUTTON_BASE_ID = 0;
|
||||||
|
|
||||||
|
EAPI const Eobj_Event_Description _SIG_CLICKED =
|
||||||
|
EOBJ_EVENT_DESCRIPTION("clicked", "", "Called when there was a click.");
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Evas_Object *bt;
|
||||||
|
} Widget_Data;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_position_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
(void) op;
|
||||||
|
(void) obj;
|
||||||
|
Evas_Coord x, y;
|
||||||
|
x = va_arg(*list, Evas_Coord);
|
||||||
|
y = va_arg(*list, Evas_Coord);
|
||||||
|
printf("But set position %d,%d\n", x, y);
|
||||||
|
eobj_class_parent_do(obj, _my_class, EVAS_OBJ_POSITION_SET(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_text_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
(void) op;
|
||||||
|
const char *text;
|
||||||
|
text = va_arg(*list, const char *);
|
||||||
|
elm_object_text_set(wd->bt, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_btn_clicked(void *data, Evas_Object *evas_obj, void *event_info)
|
||||||
|
{
|
||||||
|
(void) evas_obj;
|
||||||
|
(void) event_info;
|
||||||
|
Eobj *obj = data;
|
||||||
|
eobj_event_callback_call(obj, SIG_CLICKED, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
|
||||||
|
/* FIXME: An hack, because our tree is not yet only Eobj */
|
||||||
|
wd->bt = elm_button_add(eobj_evas_object_get(eobj_parent_get(obj)));
|
||||||
|
evas_object_size_hint_align_set(wd->bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
evas_object_size_hint_weight_set(wd->bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_smart_callback_add(wd->bt, "clicked", _btn_clicked, obj);
|
||||||
|
|
||||||
|
eobj_evas_object_set(obj, wd->bt);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
|
||||||
|
//Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
/* FIXME: Commented out because it's automatically done because our tree
|
||||||
|
* is not made of only eobj */
|
||||||
|
//evas_object_del(wd->bt);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), _text_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
elw_button_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(ELW_BUTTON_SUB_ID_TEXT_SET, "s", "Text of a text supporting evas object."), // FIXME: This ID sholudn't really be defined here...
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Event_Description *event_desc[] = {
|
||||||
|
SIG_CLICKED,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Elw Button",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&ELW_BUTTON_BASE_ID, op_desc, ELW_BUTTON_SUB_ID_LAST),
|
||||||
|
event_desc,
|
||||||
|
sizeof(Widget_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef ELW_BUTTON_H
|
||||||
|
#define ELW_BUTTON_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op ELW_BUTTON_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ELW_BUTTON_SUB_ID_TEXT_SET,
|
||||||
|
ELW_BUTTON_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ELW_BUTTON_ID(sub_id) (ELW_BUTTON_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
/* FIXME Doesn't belong here, but just for the example... */
|
||||||
|
#define ELW_BUTTON_TEXT_SET(obj) ELW_BUTTON_ID(ELW_BUTTON_SUB_ID_TEXT_SET), EOBJ_TYPECHECK(const char *, obj)
|
||||||
|
|
||||||
|
extern const Eobj_Event_Description _SIG_CLICKED;
|
||||||
|
#define SIG_CLICKED (&(_SIG_CLICKED))
|
||||||
|
|
||||||
|
#define ELW_BUTTON_CLASS elw_button_class_get()
|
||||||
|
const Eobj_Class *elw_button_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,76 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "evas_obj.h"
|
||||||
|
#include "elw_win.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Evas_Object *win;
|
||||||
|
Evas_Object *bg;
|
||||||
|
} Widget_Data;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
my_win_del(void *data, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
/* called when my_win_main is requested to be deleted */
|
||||||
|
elm_exit(); /* exit the program's main loop that runs in elm_run() */
|
||||||
|
(void) data;
|
||||||
|
(void) obj;
|
||||||
|
(void) event_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
|
||||||
|
/* FIXME: Will actually do something about those when I care... */
|
||||||
|
wd->win = elm_win_add(NULL, "eobj-test", ELM_WIN_BASIC);
|
||||||
|
elm_win_title_set(wd->win, "Eobj Test");
|
||||||
|
elm_win_autodel_set(wd->win, EINA_TRUE);
|
||||||
|
evas_object_smart_callback_add(wd->win, "delete,request", my_win_del, NULL);
|
||||||
|
|
||||||
|
wd->bg = elm_bg_add(wd->win);
|
||||||
|
elm_win_resize_object_add(wd->win, wd->bg);
|
||||||
|
evas_object_size_hint_weight_set(wd->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_show(wd->bg);
|
||||||
|
|
||||||
|
eobj_evas_object_set(obj, wd->win);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
|
||||||
|
//Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
/* FIXME: Commented out because it's automatically done because our tree
|
||||||
|
* is not made of only eobj */
|
||||||
|
// evas_object_del(wd->bx);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
elw_win_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Elw Box",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||||
|
NULL,
|
||||||
|
sizeof(Widget_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EVAS_OBJ_CLASS, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef ELW_WIN_H
|
||||||
|
#define ELW_WIN_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
#define ELW_WIN_CLASS elw_win_class_get()
|
||||||
|
const Eobj_Class *elw_win_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,153 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "evas_obj.h"
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
EAPI Eobj_Op EVAS_OBJ_BASE_ID = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Eina_List *children;
|
||||||
|
} Widget_Data;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_position_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||||
|
(void) op;
|
||||||
|
Evas_Coord x, y;
|
||||||
|
x = va_arg(*list, Evas_Coord);
|
||||||
|
y = va_arg(*list, Evas_Coord);
|
||||||
|
evas_object_move(evas_obj, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_size_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||||
|
(void) op;
|
||||||
|
Evas_Coord w, h;
|
||||||
|
w = va_arg(*list, Evas_Coord);
|
||||||
|
h = va_arg(*list, Evas_Coord);
|
||||||
|
evas_object_resize(evas_obj, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_color_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||||
|
(void) op;
|
||||||
|
int r, g, b, a;
|
||||||
|
r = va_arg(*list, int);
|
||||||
|
g = va_arg(*list, int);
|
||||||
|
b = va_arg(*list, int);
|
||||||
|
a = va_arg(*list, int);
|
||||||
|
evas_object_color_set(evas_obj, r, g, b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_color_get(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||||
|
(void) op;
|
||||||
|
int *r, *g, *b, *a;
|
||||||
|
r = va_arg(*list, int*);
|
||||||
|
g = va_arg(*list, int*);
|
||||||
|
b = va_arg(*list, int*);
|
||||||
|
a = va_arg(*list, int*);
|
||||||
|
evas_object_color_get(evas_obj, r, g, b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_visibility_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Evas_Object *evas_obj = eobj_evas_object_get(obj);
|
||||||
|
(void) op;
|
||||||
|
Eina_Bool v;
|
||||||
|
v = va_arg(*list, int);
|
||||||
|
if (v) evas_object_show(evas_obj);
|
||||||
|
else evas_object_hide(evas_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_child_add(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
(void) op;
|
||||||
|
Eobj *child;
|
||||||
|
child = va_arg(*list, Eobj *);
|
||||||
|
wd->children = eina_list_append(wd->children, eobj_ref(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
/* Add type check. */
|
||||||
|
Eobj *parent = eobj_parent_get(obj);
|
||||||
|
if (parent)
|
||||||
|
eobj_do(parent, EVAS_OBJ_CHILD_ADD(obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
|
||||||
|
Widget_Data *wd = eobj_data_get(obj, _my_class);
|
||||||
|
|
||||||
|
Eobj *child;
|
||||||
|
EINA_LIST_FREE(wd->children, child)
|
||||||
|
{
|
||||||
|
eobj_del(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), _position_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_SIZE_SET), _size_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_SET), _color_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_GET), _color_get),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_VISIBILITY_SET), _visibility_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CHILD_ADD), _child_add),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
evas_object_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_POSITION_SET, "ii", "Position of an evas object."),
|
||||||
|
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_SIZE_SET, "ii", "Size of an evas object."),
|
||||||
|
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_COLOR_SET, "iiii", "Color of an evas object."),
|
||||||
|
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_COLOR_GET, "iiii", "Color of an evas object."),
|
||||||
|
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_VISIBILITY_SET, "b", "Visibility of an evas object."),
|
||||||
|
EOBJ_OP_DESCRIPTION(EVAS_OBJ_SUB_ID_CHILD_ADD, "o", "Add a child eobj."),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Evas Object",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&EVAS_OBJ_BASE_ID, op_desc, EVAS_OBJ_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
sizeof(Widget_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef EVAS_OBJ_H
|
||||||
|
#define EVAS_OBJ_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op EVAS_OBJ_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
EVAS_OBJ_SUB_ID_POSITION_SET,
|
||||||
|
EVAS_OBJ_SUB_ID_SIZE_SET,
|
||||||
|
EVAS_OBJ_SUB_ID_COLOR_SET,
|
||||||
|
EVAS_OBJ_SUB_ID_COLOR_GET,
|
||||||
|
EVAS_OBJ_SUB_ID_VISIBILITY_SET,
|
||||||
|
EVAS_OBJ_SUB_ID_CHILD_ADD,
|
||||||
|
EVAS_OBJ_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define EVAS_OBJ_ID(sub_id) (EVAS_OBJ_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define EVAS_OBJ_POSITION_SET(x, y) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_POSITION_SET), EOBJ_TYPECHECK(Evas_Coord, x), EOBJ_TYPECHECK(Evas_Coord, y)
|
||||||
|
#define EVAS_OBJ_SIZE_SET(w, h) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_SIZE_SET), EOBJ_TYPECHECK(Evas_Coord, w), EOBJ_TYPECHECK(Evas_Coord, h)
|
||||||
|
#define EVAS_OBJ_COLOR_SET(r, g, b, a) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_SET), EOBJ_TYPECHECK(int, r), EOBJ_TYPECHECK(int, g), EOBJ_TYPECHECK(int, b), EOBJ_TYPECHECK(int, a)
|
||||||
|
#define EVAS_OBJ_COLOR_GET(r, g, b, a) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_COLOR_GET), EOBJ_TYPECHECK(int *, r), EOBJ_TYPECHECK(int *, g), EOBJ_TYPECHECK(int *, b), EOBJ_TYPECHECK(int *, a)
|
||||||
|
#define EVAS_OBJ_VISIBILITY_SET(v) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_VISIBILITY_SET), EOBJ_TYPECHECK(Eina_Bool, v)
|
||||||
|
#define EVAS_OBJ_CHILD_ADD(child) EVAS_OBJ_ID(EVAS_OBJ_SUB_ID_CHILD_ADD), EOBJ_TYPECHECK(Eobj *, child)
|
||||||
|
|
||||||
|
#define EVAS_OBJ_CLASS evas_object_class_get()
|
||||||
|
const Eobj_Class *evas_object_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#define EVAS_OBJ_STR "Evas_Obj"
|
||||||
|
/* FIXME: Hack in the meanwhile. */
|
||||||
|
static inline Evas_Object *
|
||||||
|
eobj_evas_object_get(Eobj *obj)
|
||||||
|
{
|
||||||
|
return eobj_generic_data_get(obj, EVAS_OBJ_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Hack in the meanwhile. */
|
||||||
|
static inline void
|
||||||
|
eobj_evas_object_set(Eobj *obj, Evas_Object *evas_obj)
|
||||||
|
{
|
||||||
|
eobj_generic_data_set(obj, EVAS_OBJ_STR, evas_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "evas_obj.h"
|
||||||
|
#include "elw_button.h"
|
||||||
|
#include "elw_box.h"
|
||||||
|
#include "elw_boxedbutton.h"
|
||||||
|
#include "elw_win.h"
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_btn_clicked_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||||
|
{
|
||||||
|
(void) obj;
|
||||||
|
(void) event_info;
|
||||||
|
const Eobj_Class *klass = eobj_class_get(obj);
|
||||||
|
printf("%s obj-type:'%s' data:'%s'\n", desc->name, eobj_class_name_get(klass), (const char *) data);
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
Evas_Coord winw, winh;
|
||||||
|
{
|
||||||
|
winw = 400;
|
||||||
|
winh = 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
elm_init(argc, argv);
|
||||||
|
eobj_init();
|
||||||
|
|
||||||
|
Eobj *win = eobj_add(ELW_WIN_CLASS, NULL);
|
||||||
|
eobj_do(win, EVAS_OBJ_SIZE_SET(winw, winh), EVAS_OBJ_VISIBILITY_SET(EINA_TRUE));
|
||||||
|
|
||||||
|
Eobj *bt = eobj_add(ELW_BUTTON_CLASS, win);
|
||||||
|
eobj_do(bt, EVAS_OBJ_POSITION_SET(25, 25),
|
||||||
|
EVAS_OBJ_SIZE_SET(50, 50),
|
||||||
|
EVAS_OBJ_COLOR_SET(255, 0, 0, 255),
|
||||||
|
ELW_BUTTON_TEXT_SET("Click"),
|
||||||
|
EVAS_OBJ_VISIBILITY_SET(EINA_TRUE));
|
||||||
|
eobj_event_callback_add(bt, SIG_CLICKED, _btn_clicked_cb, "btn");
|
||||||
|
|
||||||
|
int r, g, b, a;
|
||||||
|
eobj_do(bt, EVAS_OBJ_COLOR_GET(&r, &g, &b, &a));
|
||||||
|
printf("RGBa(%d, %d, %d, %d)\n", r, g, b, a);
|
||||||
|
|
||||||
|
Eobj *bx = eobj_add(ELW_BOXEDBUTTON_CLASS, win);
|
||||||
|
eobj_do(bx, EVAS_OBJ_POSITION_SET(100, 100),
|
||||||
|
EVAS_OBJ_SIZE_SET(70, 70),
|
||||||
|
EVAS_OBJ_COLOR_SET(0, 0, 255, 255),
|
||||||
|
ELW_BUTTON_TEXT_SET("Click2"),
|
||||||
|
EVAS_OBJ_VISIBILITY_SET(EINA_TRUE));
|
||||||
|
eobj_event_callback_add(bx, SIG_CLICKED, _btn_clicked_cb, "bxedbtn");
|
||||||
|
|
||||||
|
elm_run();
|
||||||
|
|
||||||
|
eobj_unref(bx);
|
||||||
|
eobj_unref(bt);
|
||||||
|
eobj_unref(win);
|
||||||
|
eobj_shutdown();
|
||||||
|
elm_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
LIST(APPEND MIXIN_CC_SOURCES
|
||||||
|
main.c
|
||||||
|
simple.c
|
||||||
|
mixin.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
${EVAS_INCLUDE_DIRS}
|
||||||
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(mixin ${MIXIN_CC_SOURCES})
|
||||||
|
|
||||||
|
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||||
|
target_link_libraries(mixin
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${eobj_LIB_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(mixin eobj)
|
||||||
|
|
||||||
|
add_test(Example_mixin mixin)
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
|
eobj_init();
|
||||||
|
|
||||||
|
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||||
|
|
||||||
|
eobj_do(obj, SIMPLE_A_SET(1), SIMPLE_B_SET(2));
|
||||||
|
|
||||||
|
int a, b;
|
||||||
|
eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b), MIXIN_ADD_AND_PRINT(5));
|
||||||
|
|
||||||
|
eobj_unref(obj);
|
||||||
|
eobj_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op MIXIN_BASE_ID = 0;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_add_and_print_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
(void) op;
|
||||||
|
int a, b, x;
|
||||||
|
eobj_do(obj, SIMPLE_A_GET(&a), SIMPLE_B_GET(&b));
|
||||||
|
x = va_arg(*list, const int);
|
||||||
|
printf("%s %d\n", __func__, a + b + x);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), _add_and_print_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
mixin_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(MIXIN_SUB_ID_ADD_AND_SET, "i", "Add A + B + param and print it"),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Mixin",
|
||||||
|
EOBJ_CLASS_TYPE_MIXIN,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&MIXIN_BASE_ID, op_desc, MIXIN_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
_my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
|
||||||
|
return _my_class;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef MIXIN_H
|
||||||
|
#define MIXIN_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op MIXIN_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MIXIN_SUB_ID_ADD_AND_SET,
|
||||||
|
MIXIN_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MIXIN_ID(sub_id) (MIXIN_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define MIXIN_ADD_AND_PRINT(x) MIXIN_ID(MIXIN_SUB_ID_ADD_AND_SET), EOBJ_TYPECHECK(int, x)
|
||||||
|
|
||||||
|
#define MIXIN_CLASS mixin_class_get()
|
||||||
|
const Eobj_Class *mixin_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,92 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "mixin.h"
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
} Private_Data;
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
#define _GET_SET_FUNC(name) \
|
||||||
|
static void \
|
||||||
|
_##name##_get(Eobj *obj, Eobj_Op op, va_list *list) \
|
||||||
|
{ \
|
||||||
|
Private_Data *pd = eobj_data_get(obj, _my_class); \
|
||||||
|
(void) op; \
|
||||||
|
int *name; \
|
||||||
|
name = va_arg(*list, int *); \
|
||||||
|
*name = pd->name; \
|
||||||
|
printf("%s %d\n", __func__, pd->name); \
|
||||||
|
} \
|
||||||
|
static void \
|
||||||
|
_##name##_set(Eobj *obj, Eobj_Op op, va_list *list) \
|
||||||
|
{ \
|
||||||
|
Private_Data *pd = eobj_data_get(obj, _my_class); \
|
||||||
|
(void) op; \
|
||||||
|
int name; \
|
||||||
|
name = va_arg(*list, int); \
|
||||||
|
pd->name = name; \
|
||||||
|
printf("%s %d\n", __func__, pd->name); \
|
||||||
|
}
|
||||||
|
|
||||||
|
_GET_SET_FUNC(a)
|
||||||
|
_GET_SET_FUNC(b)
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_B_SET), _b_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_B_GET), _b_get),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_GET, "i", "Get property A"),
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_SET, "i", "Set property B"),
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_B_GET, "i", "Get property B"),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||||
|
NULL,
|
||||||
|
sizeof(Private_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, MIXIN_CLASS, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef SIMPLE_H
|
||||||
|
#define SIMPLE_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SIMPLE_SUB_ID_A_SET,
|
||||||
|
SIMPLE_SUB_ID_A_GET,
|
||||||
|
SIMPLE_SUB_ID_B_SET,
|
||||||
|
SIMPLE_SUB_ID_B_GET,
|
||||||
|
SIMPLE_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define SIMPLE_A_SET(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||||
|
#define SIMPLE_A_GET(a) SIMPLE_ID(SIMPLE_SUB_ID_A_GET), EOBJ_TYPECHECK(int *, a)
|
||||||
|
#define SIMPLE_B_SET(b) SIMPLE_ID(SIMPLE_SUB_ID_B_SET), EOBJ_TYPECHECK(int, b)
|
||||||
|
#define SIMPLE_B_GET(b) SIMPLE_ID(SIMPLE_SUB_ID_B_GET), EOBJ_TYPECHECK(int *, b)
|
||||||
|
|
||||||
|
#define SIMPLE_CLASS simple_class_get()
|
||||||
|
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,22 @@
|
||||||
|
LIST(APPEND SIGNALS_CC_SOURCES
|
||||||
|
main.c
|
||||||
|
simple.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
${EVAS_INCLUDE_DIRS}
|
||||||
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(signals ${SIGNALS_CC_SOURCES})
|
||||||
|
|
||||||
|
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||||
|
target_link_libraries(signals
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${eobj_LIB_FILE}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_dependencies(signals eobj)
|
||||||
|
|
||||||
|
add_test(Example_signals signals)
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_a_changed_cb(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||||
|
{
|
||||||
|
/* FIXME: Actually print it. */
|
||||||
|
(void) desc;
|
||||||
|
(void) obj;
|
||||||
|
int new_a = *((int *) event_info);
|
||||||
|
printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
|
||||||
|
|
||||||
|
/* Fix data is NULL, stop. */
|
||||||
|
return !!data;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
|
eobj_init();
|
||||||
|
|
||||||
|
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||||
|
|
||||||
|
/* The order of these two is undetermined. */
|
||||||
|
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, "CALLED");
|
||||||
|
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_BEFORE, _a_changed_cb, "CALLED2");
|
||||||
|
/* This will be called afterwards. */
|
||||||
|
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_DEFAULT, _a_changed_cb, NULL);
|
||||||
|
/* This will never be called because the previous callback returns NULL. */
|
||||||
|
eobj_event_callback_priority_add(obj, SIG_A_CHANGED, EOBJ_CALLBACK_PRIORITY_AFTER, _a_changed_cb, "NOT CALLED");
|
||||||
|
|
||||||
|
eobj_do(obj, SIMPLE_A_SET(1));
|
||||||
|
|
||||||
|
eobj_event_callback_del_full(obj, SIG_A_CHANGED, _a_changed_cb, NULL);
|
||||||
|
|
||||||
|
eobj_unref(obj);
|
||||||
|
eobj_shutdown();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
#include "eobj.h"
|
||||||
|
#include "simple.h"
|
||||||
|
|
||||||
|
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
} Private_Data;
|
||||||
|
|
||||||
|
EAPI const Eobj_Event_Description _SIG_A_CHANGED =
|
||||||
|
EOBJ_EVENT_DESCRIPTION("a,changed", "i", "Called when a has changed.");
|
||||||
|
|
||||||
|
static Eobj_Class *_my_class = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||||
|
{
|
||||||
|
Private_Data *pd = eobj_data_get(obj, _my_class);
|
||||||
|
(void) op;
|
||||||
|
int a;
|
||||||
|
a = va_arg(*list, int);
|
||||||
|
pd->a = a;
|
||||||
|
printf("%s %d\n", __func__, pd->a);
|
||||||
|
|
||||||
|
eobj_event_callback_call(obj, SIG_A_CHANGED, &pd->a);
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_cb_added(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||||
|
{
|
||||||
|
const Eobj_Event_Description *cb_desc = event_info;
|
||||||
|
(void) data;
|
||||||
|
(void) desc;
|
||||||
|
|
||||||
|
if (cb_desc != SIG_A_CHANGED)
|
||||||
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
int count = (int) eobj_generic_data_get(obj, "cb_count") + 1;
|
||||||
|
eobj_generic_data_set(obj, "cb_count", (void *) count);
|
||||||
|
|
||||||
|
printf("Added SIG_A_CHANGED callback to %p. Count: %d\n", obj, count);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eina_Bool
|
||||||
|
_cb_deled(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info)
|
||||||
|
{
|
||||||
|
const Eobj_Event_Description *cb_desc = event_info;
|
||||||
|
(void) data;
|
||||||
|
(void) desc;
|
||||||
|
|
||||||
|
if (cb_desc != SIG_A_CHANGED)
|
||||||
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
int count = (int) eobj_generic_data_get(obj, "cb_count") - 1;
|
||||||
|
eobj_generic_data_set(obj, "cb_count", (void *) count);
|
||||||
|
|
||||||
|
printf("Removed SIG_A_CHANGED callback from %p. Count: %d\n", obj, count);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_constructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_constructor_super(obj);
|
||||||
|
|
||||||
|
eobj_event_callback_add(obj, EOBJ_SIG_CALLBACK_ADD, _cb_added, NULL);
|
||||||
|
eobj_event_callback_add(obj, EOBJ_SIG_CALLBACK_DEL, _cb_deled, NULL);
|
||||||
|
|
||||||
|
eobj_generic_data_set(obj, "cb_count", (intptr_t) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_destructor(Eobj *obj)
|
||||||
|
{
|
||||||
|
eobj_destructor_super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_class_constructor(Eobj_Class *klass)
|
||||||
|
{
|
||||||
|
const Eobj_Op_Func_Description func_desc[] = {
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||||
|
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
eobj_class_funcs_set(klass, func_desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Eobj_Class *
|
||||||
|
simple_class_get(void)
|
||||||
|
{
|
||||||
|
if (_my_class) return _my_class;
|
||||||
|
|
||||||
|
static const Eobj_Op_Description op_desc[] = {
|
||||||
|
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||||
|
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Event_Description *event_desc[] = {
|
||||||
|
SIG_A_CHANGED,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Class_Description class_desc = {
|
||||||
|
"Simple",
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR,
|
||||||
|
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||||
|
event_desc,
|
||||||
|
sizeof(Private_Data),
|
||||||
|
_constructor,
|
||||||
|
_destructor,
|
||||||
|
_class_constructor,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef SIMPLE_H
|
||||||
|
#define SIMPLE_H
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SIMPLE_SUB_ID_A_SET,
|
||||||
|
SIMPLE_SUB_ID_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||||
|
|
||||||
|
#define SIMPLE_A_SET(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EOBJ_TYPECHECK(int, a)
|
||||||
|
|
||||||
|
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||||
|
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||||
|
|
||||||
|
#define SIMPLE_CLASS simple_class_get()
|
||||||
|
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,19 @@
|
||||||
|
LIST(APPEND EOBJ_CC_SOURCES
|
||||||
|
eobj.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(eobj SHARED ${EOBJ_CC_SOURCES})
|
||||||
|
target_link_libraries(eobj
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${EFL_COVERAGE_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(eobj PROPERTIES
|
||||||
|
COMPILE_FLAGS "${EFL_COVERAGE_CFLAGS}")
|
||||||
|
set_target_properties(eobj PROPERTIES
|
||||||
|
VERSION ${EOBJ_VERSION} SOVERSION ${EOBJ_VERSION_MAJOR})
|
||||||
|
set_target_properties(eobj PROPERTIES OUTPUT_NAME "eobj")
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,163 @@
|
||||||
|
#ifndef EOBJ_H
|
||||||
|
#define EOBJ_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
|
||||||
|
/* Check that the types are castable and cast them. */
|
||||||
|
#define EOBJ_TYPECHECK(type, x) \
|
||||||
|
({ \
|
||||||
|
type __x; \
|
||||||
|
__x = x; \
|
||||||
|
(void) __x; \
|
||||||
|
(type) x; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define EOBJ_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*arr))
|
||||||
|
|
||||||
|
typedef struct _Eobj Eobj;
|
||||||
|
typedef uintptr_t Eobj_Op;
|
||||||
|
|
||||||
|
typedef struct _Eobj_Class Eobj_Class;
|
||||||
|
typedef int Eobj_Class_Id;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR = 0,
|
||||||
|
EOBJ_CLASS_TYPE_REGULAR_NO_INSTANT,
|
||||||
|
EOBJ_CLASS_TYPE_INTERFACE,
|
||||||
|
EOBJ_CLASS_TYPE_MIXIN
|
||||||
|
} Eobj_Class_Type;
|
||||||
|
|
||||||
|
typedef void (*eobj_op_func_type)(Eobj *, Eobj_Op, va_list *list);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Eobj_Op op;
|
||||||
|
eobj_op_func_type func;
|
||||||
|
} Eobj_Op_Func_Description;
|
||||||
|
|
||||||
|
#define EOBJ_OP_FUNC_DESCRIPTION(op, func) { op, func }
|
||||||
|
#define EOBJ_OP_FUNC_DESCRIPTION_SENTINEL { 0, NULL }
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *name; /**< name used for lookups */
|
||||||
|
const char *type; /**< used for introspection purposes, documents what goes as callback event information (@c event_info) */
|
||||||
|
const char *doc; /**< documentation for introspection purposes */
|
||||||
|
} Eobj_Event_Description;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Eobj_Op sub_op;
|
||||||
|
const char *name;
|
||||||
|
/* FIXME: properly define the type so it'll support get/set and etc.
|
||||||
|
* Do I even need/want type? If so, do I need/want it here? docs aren't
|
||||||
|
* enough? */
|
||||||
|
const char *type;
|
||||||
|
const char *doc;
|
||||||
|
} Eobj_Op_Description;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
Eobj_Class_Type type;
|
||||||
|
struct {
|
||||||
|
Eobj_Op *base_op_id;
|
||||||
|
const Eobj_Op_Description *descs;
|
||||||
|
size_t count;
|
||||||
|
} ops;
|
||||||
|
const Eobj_Event_Description **events;
|
||||||
|
size_t private_size;
|
||||||
|
void (*constructor)(Eobj *obj);
|
||||||
|
void (*destructor)(Eobj *obj);
|
||||||
|
void (*class_constructor)(Eobj_Class *klass);
|
||||||
|
void (*class_destructor)(Eobj_Class *klass);
|
||||||
|
} Eobj_Class_Description;
|
||||||
|
|
||||||
|
#define EOBJ_CLASS_DESCRIPTION_OPS(base_op_id, op_descs, count) { base_op_id, op_descs, count }
|
||||||
|
|
||||||
|
#define EOBJ_OP_DESCRIPTION(op, type, doc) { op, #op, type, doc }
|
||||||
|
#define EOBJ_OP_DESCRIPTION_SENTINEL { 0, NULL, NULL, NULL }
|
||||||
|
|
||||||
|
#define EOBJ_EVENT_DESCRIPTION(name, type, doc) { name, type, doc }
|
||||||
|
|
||||||
|
EAPI Eina_Bool eobj_init(void);
|
||||||
|
EAPI Eina_Bool eobj_shutdown(void);
|
||||||
|
|
||||||
|
#define eobj_do(object, ...) eobj_do_internal(object, __VA_ARGS__, NULL)
|
||||||
|
#define eobj_class_do(object, klass, ...) eobj_class_do_internal(object, klass, __VA_ARGS__, NULL)
|
||||||
|
#define eobj_class_parent_do(object, klass, ...) eobj_class_do_internal(object, eobj_class_parent_get(klass), __VA_ARGS__, NULL)
|
||||||
|
|
||||||
|
EAPI Eina_Bool eobj_do_internal(Eobj *obj, ...);
|
||||||
|
|
||||||
|
EAPI Eina_Bool eobj_class_do_internal(Eobj *obj, const Eobj_Class *klass, ...);
|
||||||
|
|
||||||
|
EAPI const Eobj_Class *eobj_class_get(Eobj *obj);
|
||||||
|
EAPI const Eobj_Class *eobj_class_parent_get(const Eobj_Class *klass);
|
||||||
|
EAPI const char *eobj_class_name_get(const Eobj_Class *klass);
|
||||||
|
|
||||||
|
EAPI void eobj_constructor_super(Eobj *obj);
|
||||||
|
EAPI void eobj_destructor_super(Eobj *obj);
|
||||||
|
EAPI void eobj_constructor_error_set(Eobj *obj);
|
||||||
|
EAPI Eina_Bool eobj_constructor_error_get(const Eobj *obj);
|
||||||
|
|
||||||
|
EAPI Eobj_Class *eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...);
|
||||||
|
EAPI void eobj_class_free(Eobj_Class *klass);
|
||||||
|
EAPI void eobj_class_funcs_set(Eobj_Class *klass, const Eobj_Op_Func_Description *func_descs);
|
||||||
|
|
||||||
|
EAPI Eobj *eobj_add(const Eobj_Class *klass, Eobj *parent);
|
||||||
|
EAPI Eobj *eobj_parent_get(Eobj *obj);
|
||||||
|
EAPI void *eobj_data_get(Eobj *obj, const Eobj_Class *klass);
|
||||||
|
EAPI Eobj *eobj_ref(Eobj *obj);
|
||||||
|
EAPI void eobj_unref(Eobj *obj);
|
||||||
|
EAPI void eobj_del(Eobj *obj);
|
||||||
|
EAPI void *eobj_generic_data_set(Eobj *obj, const char *key, const void *data);
|
||||||
|
EAPI void *eobj_generic_data_get(const Eobj *obj, const char *key);
|
||||||
|
EAPI void *eobj_generic_data_del(Eobj *obj, const char *key);
|
||||||
|
|
||||||
|
#define EOBJ_CLASS_BASE eobj_base_class_get()
|
||||||
|
EAPI const Eobj_Class *eobj_base_class_get(void) EINA_CONST;
|
||||||
|
|
||||||
|
EAPI void eobj_composite_object_attach(Eobj *obj, Eobj *emb_obj);
|
||||||
|
EAPI void eobj_composite_object_detach(Eobj *obj, Eobj *emb_obj);
|
||||||
|
EAPI Eina_Bool eobj_composite_is(Eobj *emb_obj);
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
/**
|
||||||
|
* @def EOBJ_CALLBACK_PRIORITY_BEFORE
|
||||||
|
* Slightly more prioritized than default.
|
||||||
|
*/
|
||||||
|
#define EOBJ_CALLBACK_PRIORITY_BEFORE -100
|
||||||
|
/**
|
||||||
|
* @def EOBJ_CALLBACK_PRIORITY_DEFAULT
|
||||||
|
* Default callback priority level
|
||||||
|
*/
|
||||||
|
#define EOBJ_CALLBACK_PRIORITY_DEFAULT 0
|
||||||
|
/**
|
||||||
|
* @def EOBJ_CALLBACK_PRIORITY_AFTER
|
||||||
|
* Slightly less prioritized than default.
|
||||||
|
*/
|
||||||
|
#define EOBJ_CALLBACK_PRIORITY_AFTER 100
|
||||||
|
typedef short Eobj_Callback_Priority;
|
||||||
|
|
||||||
|
/* True meaning continue, False meaning stop callbacks. - Make it an enum? */
|
||||||
|
typedef Eina_Bool (*Eobj_Event_Cb)(void *data, Eobj *obj, const Eobj_Event_Description *desc, void *event_info);
|
||||||
|
|
||||||
|
EAPI Eina_Bool eobj_event_callback_forwarder_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
|
||||||
|
EAPI Eina_Bool eobj_event_callback_forwarder_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj *new_obj);
|
||||||
|
|
||||||
|
/* callbacks of the same priority are called in reverse order of creation. */
|
||||||
|
EAPI Eina_Bool eobj_event_callback_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb cb, const void *data);
|
||||||
|
EAPI Eina_Bool eobj_event_callback_priority_add(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Callback_Priority priority, Eobj_Event_Cb cb, const void *data);
|
||||||
|
EAPI void *eobj_event_callback_del(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func);
|
||||||
|
EAPI void *eobj_event_callback_del_full(Eobj *obj, const Eobj_Event_Description *desc, Eobj_Event_Cb func, const void *user_data);
|
||||||
|
EAPI Eina_Bool eobj_event_callback_call(Eobj *obj, const Eobj_Event_Description *desc, const void *event_info);
|
||||||
|
|
||||||
|
EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_ADD;
|
||||||
|
#define EOBJ_SIG_CALLBACK_ADD (&(_EOBJ_SIG_CALLBACK_ADD))
|
||||||
|
EAPI extern const Eobj_Event_Description _EOBJ_SIG_CALLBACK_DEL;
|
||||||
|
#define EOBJ_SIG_CALLBACK_DEL (&(_EOBJ_SIG_CALLBACK_DEL))
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,30 @@
|
||||||
|
if (CHECK_ENABLED)
|
||||||
|
|
||||||
|
LIST(APPEND EOBJ_SUITE_CC_SOURCES
|
||||||
|
eobj_suite.c
|
||||||
|
eobj_test_init.c
|
||||||
|
eobj_test_general.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(eobj_suite ${EOBJ_SUITE_CC_SOURCES})
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${EINA_INCLUDE_DIRS}
|
||||||
|
${EVAS_INCLUDE_DIRS}
|
||||||
|
${ELEMENTARY_INCLUDE_DIRS}
|
||||||
|
${CMAKE_SOURCE_DIR}/lib
|
||||||
|
${CHECK_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
get_target_property(eobj_LIB_FILE eobj LOCATION)
|
||||||
|
target_link_libraries(eobj_suite
|
||||||
|
${EINA_LIBRARIES}
|
||||||
|
${EVAS_LIBRARIES}
|
||||||
|
${ELEMENTARY_LIBRARIES}
|
||||||
|
${eobj_LIB_FILE}
|
||||||
|
${CHECK_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_test(eobj_suite eobj_suite)
|
||||||
|
add_dependencies(check eobj_suite)
|
||||||
|
endif (CHECK_ENABLED)
|
|
@ -0,0 +1,102 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
#include "eobj_suite.h"
|
||||||
|
|
||||||
|
typedef struct _Eobj_Test_Case Eobj_Test_Case;
|
||||||
|
|
||||||
|
struct _Eobj_Test_Case
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eobj_Test_Case etc[] = {
|
||||||
|
{ "Eobj init", eobj_test_init },
|
||||||
|
{ "Eobj general", eobj_test_general },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Eobj_Test_Case *itr;
|
||||||
|
|
||||||
|
itr = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; itr->test_case; itr++)
|
||||||
|
fprintf(stderr, "\t%s\n", itr->test_case);
|
||||||
|
}
|
||||||
|
static Eina_Bool
|
||||||
|
_use_test(int argc, const char **argv, const char *test_case)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (; argc > 0; argc--, argv++)
|
||||||
|
if (strcmp(test_case, *argv) == 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
eobj_suite_build(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
TCase *tc;
|
||||||
|
Suite *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
s = suite_create("Eobj");
|
||||||
|
|
||||||
|
for (i = 0; etc[i].test_case; ++i)
|
||||||
|
{
|
||||||
|
if (!_use_test(argc, argv, etc[i].test_case)) continue;
|
||||||
|
tc = tcase_create(etc[i].test_case);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
tcase_set_timeout(tc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
Suite *s;
|
||||||
|
SRunner *sr;
|
||||||
|
int i, failed_count;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
if ((strcmp(argv[i], "-h") == 0) ||
|
||||||
|
(strcmp(argv[i], "--help") == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
|
||||||
|
argv[0]);
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if ((strcmp(argv[i], "-l") == 0) ||
|
||||||
|
(strcmp(argv[i], "--list") == 0))
|
||||||
|
{
|
||||||
|
_list_tests();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = eobj_suite_build(argc - 1, (const char **)argv + 1);
|
||||||
|
sr = srunner_create(s);
|
||||||
|
|
||||||
|
srunner_run_all(sr, CK_ENV);
|
||||||
|
failed_count = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
|
||||||
|
return (failed_count == 0) ? 0 : 255;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef _EOBJ_SUITE_H
|
||||||
|
#define _EOBJ_SUITE_H
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
void eobj_test_init(TCase *tc);
|
||||||
|
void eobj_test_general(TCase *tc);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _EOBJ_SUITE_H */
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "eobj_suite.h"
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
START_TEST(eobj_simple)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eobj_test_general(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, eobj_simple);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "eobj_suite.h"
|
||||||
|
#include "eobj.h"
|
||||||
|
|
||||||
|
START_TEST(eobj_simple)
|
||||||
|
{
|
||||||
|
fail_if(!eobj_init()); /* one init by test suite */
|
||||||
|
fail_if(!eobj_shutdown());
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void eobj_test_init(TCase *tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, eobj_simple);
|
||||||
|
}
|
Loading…
Reference in New Issue