mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
switch to git no-history version
This commit is contained in:
45
src/utils/copyrights/cr_update.py
Normal file
45
src/utils/copyrights/cr_update.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# updates the copyright information for all .cs files
|
||||
# usage: call recursive_traversal, with the following parameters
|
||||
# parent directory, old copyright text content, new copyright text content
|
||||
|
||||
import os
|
||||
|
||||
excludedir = ["..\\Lib"]
|
||||
|
||||
def update_source(filename, oldcopyright, copyright):
|
||||
utfstr = chr(0xef)+chr(0xbb)+chr(0xbf)
|
||||
fdata = file(filename,"r+").read()
|
||||
isUTF = False
|
||||
if (fdata.startswith(utfstr)):
|
||||
isUTF = True
|
||||
fdata = fdata[3:]
|
||||
if (oldcopyright != None):
|
||||
if (fdata.startswith(oldcopyright)):
|
||||
fdata = fdata[len(oldcopyright):]
|
||||
if not (fdata.startswith(copyright)):
|
||||
print "updating "+filename
|
||||
fdata = copyright + fdata
|
||||
if (isUTF):
|
||||
file(filename,"w").write(utfstr+fdata)
|
||||
else:
|
||||
file(filename,"w").write(fdata)
|
||||
|
||||
def recursive_traversal(dir, oldcopyright, copyright):
|
||||
global excludedir
|
||||
fns = os.listdir(dir)
|
||||
print "listing "+dir
|
||||
for fn in fns:
|
||||
fullfn = os.path.join(dir,fn)
|
||||
if (fullfn in excludedir):
|
||||
continue
|
||||
if (os.path.isdir(fullfn)):
|
||||
recursive_traversal(fullfn, oldcopyright, copyright)
|
||||
else:
|
||||
if ( fullfn.endswith(".cpp") or fullfn.endswith(".h") or fullfn.endswith(".hpp") or fullfn.endswith(".C") or fullfn.endswith(".cxx") ):
|
||||
update_source(fullfn, oldcopyright, copyright)
|
||||
|
||||
|
||||
oldcright = file("oldcr.txt","r+").read()
|
||||
cright = file("newcr.txt","r+").read()
|
||||
recursive_traversal("../../", oldcright, cright)
|
||||
exit()
|
||||
27
src/utils/copyrights/newcr.txt
Normal file
27
src/utils/copyrights/newcr.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
24
src/utils/copyrights/oldcr.txt
Normal file
24
src/utils/copyrights/oldcr.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
37
src/utils/make_recipe/CMakeLists.txt
Normal file
37
src/utils/make_recipe/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
set(HEADERS
|
||||
)
|
||||
|
||||
SET(SOURCES
|
||||
)
|
||||
|
||||
|
||||
## Build target tar file ##
|
||||
set(CMAKE_TAR_FILE "recipe.tar.gz")
|
||||
add_custom_command(OUTPUT recipe_tar_data.o
|
||||
COMMAND tar -zcvf ${CMAKE_TAR_FILE} -C "${CMAKE_CURRENT_SOURCE_DIR}/src" CMakeLists.txt main.cpp -C ${PROJECT_SOURCE_DIR} CMakeConfig.in.h
|
||||
## -C ${PROJECT_SOURCE_DIR} CMake
|
||||
COMMAND objcopy --input binary --output elf64-x86-64 --binary-architecture i386 ${CMAKE_TAR_FILE} ${CMAKE_CURRENT_BINARY_DIR}/recipe_tar_data.o
|
||||
)
|
||||
|
||||
add_library(recipe_tar_data STATIC recipe_tar_data.o)
|
||||
set_source_files_properties(recipe_tar_data.o PROPERTIES EXTERNAL_OBJECT true GENERATED true)
|
||||
set_target_properties(recipe_tar_data PROPERTIES LINKER_LANGUAGE C)
|
||||
|
||||
|
||||
set(CMAKE_TAR_FILE "cmake.tar.gz")
|
||||
add_custom_command(OUTPUT cmake_tar_data.o
|
||||
COMMAND tar -zcvf ${CMAKE_TAR_FILE} -C ${PROJECT_SOURCE_DIR} CMake "--exclude=CMake/.svn"
|
||||
COMMAND objcopy --input binary --output elf64-x86-64 --binary-architecture i386 ${CMAKE_TAR_FILE} ${CMAKE_CURRENT_BINARY_DIR}/cmake_tar_data.o
|
||||
)
|
||||
|
||||
add_library(cmake_tar_data STATIC cmake_tar_data.o)
|
||||
set_source_files_properties(cmake_tar_data.o PROPERTIES EXTERNAL_OBJECT true GENERATED true)
|
||||
set_target_properties(cmake_tar_data PROPERTIES LINKER_LANGUAGE C)
|
||||
|
||||
|
||||
|
||||
uLib_add_target(uLib_config main.cpp)
|
||||
target_link_libraries(uLib_config cmake_tar_data)
|
||||
target_link_libraries(uLib_config recipe_tar_data)
|
||||
target_link_libraries(uLib_config ${PACKAGE_LIBPREFIX}Core)
|
||||
|
||||
137
src/utils/make_recipe/main.cpp
Normal file
137
src/utils/make_recipe/main.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "Core/Options.h"
|
||||
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
extern "C" {
|
||||
extern char _binary_recipe_tar_gz_start;
|
||||
extern char _binary_recipe_tar_gz_end;
|
||||
extern char _binary_cmake_tar_gz_start;
|
||||
extern char _binary_cmake_tar_gz_end;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
static struct Parameters : Options
|
||||
{
|
||||
std::string project;
|
||||
Parameters(const char *hello = "Program options") : Options(hello) {
|
||||
add_options()
|
||||
("help,h", "printout help")
|
||||
// GENERAL //
|
||||
("project,p", &project, std::string(), "name of project")
|
||||
("cmake,k", "cmake recipe project")
|
||||
("cmake-modules,K", "only builds cmake modules directory")
|
||||
("libs", "get mutom linker flags")
|
||||
("cflags", "get compiler flags")
|
||||
;
|
||||
}
|
||||
} p;
|
||||
} // namespace
|
||||
|
||||
|
||||
static std::string system_pipe(std::string cmd) {
|
||||
FILE *pipe = popen(cmd.c_str(),"r");
|
||||
if(pipe) {
|
||||
std::stringstream ss;
|
||||
int c = fgetc (pipe);
|
||||
while (c != EOF) {
|
||||
if(c != '\n') ss << (char)c;
|
||||
c = fgetc (pipe);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
else return std::string("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
p.parse_command_line(argc,argv);
|
||||
|
||||
if(p.project != "") {
|
||||
char dir[300];
|
||||
sprintf(dir,"mkdir %s",p.project.c_str());
|
||||
system(dir);
|
||||
chdir(p.project.c_str());
|
||||
}
|
||||
|
||||
if(p.count("cmake") || p.count("cmake-modules")) {
|
||||
std::ofstream file;
|
||||
file.open("_cmake.tar.gz", std::ios::out | std::ios::binary );
|
||||
char* ptr = &_binary_cmake_tar_gz_start;
|
||||
while ( ptr != &_binary_cmake_tar_gz_end )
|
||||
file << *ptr++;
|
||||
file.close();
|
||||
|
||||
std::cout << "Deploing CMake files .... \n";
|
||||
system("tar -zxvf _cmake.tar.gz");
|
||||
system("rm _cmake.tar.gz");
|
||||
std::cout << "done ... \n";
|
||||
}
|
||||
|
||||
if(p.count("cmake")) {
|
||||
std::ofstream file;
|
||||
file.open("_recipe.tar.gz", std::ios::out | std::ios::binary );
|
||||
char* ptr = &_binary_recipe_tar_gz_start;
|
||||
while ( ptr != &_binary_recipe_tar_gz_end )
|
||||
file << *ptr++;
|
||||
file.close();
|
||||
|
||||
std::cout << "Deploing recipe files .... \n";
|
||||
system("tar -zxvf _recipe.tar.gz");
|
||||
system("rm _recipe.tar.gz");
|
||||
std::cout << "done ... \n";
|
||||
}
|
||||
|
||||
if(p.count("cflags")) {
|
||||
std::cout
|
||||
<< system_pipe("cmake --find-package -DCMAKE_PREFIX_PATH=/usr/local/lib/cmake/mutom-0.2 -DNAME=uLib -DLANGUAGE=C -DCOMPILER_ID=GNU -DMODE=COMPILE")
|
||||
<< system_pipe("cmake --find-package -DCMAKE_PREFIX_PATH=/usr/local/lib/cmake/mutom-0.2 -DNAME=IB -DLANGUAGE=C -DCOMPILER_ID=GNU -DMODE=COMPILE");
|
||||
}
|
||||
|
||||
if(p.count("libs")) {
|
||||
std::cout
|
||||
<< system_pipe("cmake --find-package -DCMAKE_PREFIX_PATH=/usr/local/lib/cmake/mutom-0.2 -DNAME=uLib -DLANGUAGE=C -DCOMPILER_ID=GNU -DMODE=LINK")
|
||||
<< system_pipe("cmake --find-package -DCMAKE_PREFIX_PATH=/usr/local/lib/cmake/mutom-0.2 -DNAME=IB -DLANGUAGE=C -DCOMPILER_ID=GNU -DMODE=LINK");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1
src/utils/make_recipe/src/CMake
Symbolic link
1
src/utils/make_recipe/src/CMake
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../CMake
|
||||
104
src/utils/make_recipe/src/CMakeLists.txt
Normal file
104
src/utils/make_recipe/src/CMakeLists.txt
Normal file
@@ -0,0 +1,104 @@
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
project(hello_world)
|
||||
set(SOURCES
|
||||
# put your sources here
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set(DICTIONARY_HEADERS
|
||||
# put dictionary headers here
|
||||
)
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
|
||||
include(uLibDebugMacro)
|
||||
include(uLibCommon)
|
||||
include(uLibFindDependencies)
|
||||
include(uLibConfigHeader)
|
||||
include(uLibGenerateRMake)
|
||||
|
||||
|
||||
## MUDULE FIND PACKAGE ------------------------------------------------------ ##
|
||||
#find_package(uLib REQUIRED) # not working at the moment
|
||||
|
||||
## CONFIG FIND PACKAGE ------------------------------------------------------ ##
|
||||
#set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake")
|
||||
unset(ULIB_CONFIG)
|
||||
find_package(ULIB 0.2 CONFIG
|
||||
NAMES uLib
|
||||
PATH_SUFFIXES mutom-0.2
|
||||
)
|
||||
if(ULIB_CONFIG)
|
||||
set(ULIB_FOUND true)
|
||||
endif()
|
||||
|
||||
unset(IB_CONFIG)
|
||||
find_package(IB 0.2 CONFIG
|
||||
PATH_SUFFIXES mutom-0.2
|
||||
)
|
||||
if(IB_CONFIG)
|
||||
set(IB_FOUND true)
|
||||
endif()
|
||||
|
||||
|
||||
## PROJECT EXECUTABLE ------------------------------------------------------- ##
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
if(ULIB_FOUND)
|
||||
include_directories(${ULIB_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
############################################################################
|
||||
## ULIB MODULES ##
|
||||
mutomCore
|
||||
mutomMath
|
||||
mutomDetectors
|
||||
# mutomVtk
|
||||
############################################################################
|
||||
|
||||
############################################################################
|
||||
# MANUAL INLCLUDE EXTERNAL DEPENDENCIES
|
||||
# ${Boost_SERIALIZATION_LIBRARY}
|
||||
# ${Boost_SIGNALS_LIBRARY}
|
||||
# ${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
# ${Geant4_LIBRARIES}
|
||||
# ${ROOT_LIBRARIES}
|
||||
# ${VTK_LIBRARIES} # all VTK libs
|
||||
############################################################################
|
||||
)
|
||||
endif(ULIB_FOUND)
|
||||
|
||||
if(IB_FOUND)
|
||||
include_directories(${IB_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} mutomIB )
|
||||
endif()
|
||||
|
||||
|
||||
## ROOT DICTIONARY COMPILE -------------------------------------------------- ##
|
||||
if(ROOT_FOUND AND DICTIONARY_HEADERS)
|
||||
include(FindROOTv6)
|
||||
message("----------- Building Root Dictionary ----------")
|
||||
debug(DICTIONARY_HEADERS)
|
||||
debug(ROOT_CINT_EXECUTABLE)
|
||||
add_library(dictionary STATIC RootDict.cxx)
|
||||
add_custom_command(OUTPUT RootDict.cxx RootDict.h
|
||||
COMMAND ${ROOT_CINT_EXECUTABLE} -f RootDict.cxx -c -p ${DICTIONARY_HEADERS} Linkdef.h
|
||||
)
|
||||
#root_generate_dictionary(RootDict ${DICTIONARY_HEADERS} LINKDEF Linkdef.h)
|
||||
set_source_files_properties(RootDict.cxx PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(RootDict.h PROPERTIES GENERATED TRUE)
|
||||
target_link_libraries(${PROJECT_NAME} dictionary)
|
||||
endif(ROOT_FOUND AND DICTIONARY_HEADERS)
|
||||
|
||||
|
||||
|
||||
|
||||
36
src/utils/make_recipe/src/main.cpp
Normal file
36
src/utils/make_recipe/src/main.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <Core/Object.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::cout << "hello uLib user\n";
|
||||
return 0;
|
||||
}
|
||||
24
src/utils/moc/Makefile
Normal file
24
src/utils/moc/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
# Makefile example -- scanner and parser.
|
||||
#
|
||||
CXX = g++ -D_DEBUG
|
||||
LEX = flex
|
||||
YACC = bison -y -t
|
||||
YFLAGS = -d
|
||||
objects = parse.o scan.o
|
||||
|
||||
moc: $(objects)
|
||||
$(CXX) -o $@ $(objects) -lfl
|
||||
|
||||
parse.o: parse.y
|
||||
|
||||
# parse.h: parse.c
|
||||
# mv -f y.tab.h parse.h
|
||||
|
||||
scan.o: scan.l
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o parse.tab.c parse.tab.h
|
||||
|
||||
92
src/utils/moc/moc_actions.h
Normal file
92
src/utils/moc/moc_actions.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#ifndef MOC_ACTION_H
|
||||
#define MOC_ACTION_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG( ... ) { printf(" /*["); printf( __VA_ARGS__ ); printf("]*/ "); }
|
||||
#else
|
||||
#define DEBUG( ... ) ;
|
||||
#endif
|
||||
|
||||
#define CONCAT( dest , ... ) string_append(dest, __VA_ARGS__, NULL)
|
||||
|
||||
char * string_append(char *first, ... ) {
|
||||
va_list ap;
|
||||
va_start (ap, first); /* Initialize the argument list. */
|
||||
|
||||
char *str_in = first;
|
||||
char *str = malloc(sizeof(char) * strlen(str_in));
|
||||
strcat(str,str_in);
|
||||
|
||||
str_in = va_arg (ap,char *);
|
||||
while (str_in) {
|
||||
char *tmp = malloc(sizeof(char) * (strlen(str)+strlen(str_in)) );
|
||||
memcpy(tmp,str,strlen(str));
|
||||
memcpy(tmp+strlen(str),str_in,strlen(str_in));
|
||||
free(str);
|
||||
str = tmp;
|
||||
str_in = va_arg (ap,char *);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ACTIONS //
|
||||
|
||||
|
||||
|
||||
#define SIMPLE_DECLARATION simple_declaration_action
|
||||
|
||||
static int simple_declaration_action(const char *type, const char *ids);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// move to implementation .. //
|
||||
static int simple_declaration_action(const char *type, const char *ids) {
|
||||
DEBUG("simple_declaration -> type:\"%s\" decl:\"%s\" ",type,ids);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // MOC_ACTION_H
|
||||
1257
src/utils/moc/parse.y
Normal file
1257
src/utils/moc/parse.y
Normal file
File diff suppressed because it is too large
Load Diff
51
src/utils/moc/sample.cpp
Normal file
51
src/utils/moc/sample.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
|
||||
typedef int TestInt;
|
||||
|
||||
class DerivedObject {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
ULIB_OBJECT_PARAMETERS(test)
|
||||
{
|
||||
Bubu *a;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
ULIB_OBJECT_PARAMETERS(prova) {
|
||||
int a,b;
|
||||
char *c;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
252
src/utils/moc/scan.l
Normal file
252
src/utils/moc/scan.l
Normal file
@@ -0,0 +1,252 @@
|
||||
%option stack
|
||||
%{
|
||||
/* preamble */
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "y.tab.h"
|
||||
|
||||
#define PRINT(str) { printf("%s",str); }
|
||||
#define ENSTATE(st) { yy_push_state(YY_START); BEGIN(st); /*printf("ST[%i]",YY_START);*/ }
|
||||
#define EXSTATE { BEGIN(yy_top_state()); yy_pop_state(); /*printf("ST[%i]",YY_START);*/ }
|
||||
|
||||
#define SCANTEXT { fill_sval(); }
|
||||
#define MATCH(name) { ECHO; SCANTEXT; return name; }
|
||||
|
||||
int lineno;
|
||||
int moc_level = 0;
|
||||
|
||||
static int yywrap(void);
|
||||
static void skip_until_eol(void);
|
||||
static void skip_comment(void);
|
||||
static int check_identifier(const char *);
|
||||
static int fill_sval();
|
||||
%}
|
||||
|
||||
blank [\t\f\v\r ]+
|
||||
anyunch <*>.
|
||||
|
||||
intsuffix ([uU][lL]?)|([lL][uU]?)
|
||||
fracconst ([0-9]*\.[0-9]+)|([0-9]+\.)
|
||||
exppart [eE][-+]?[0-9]+
|
||||
floatsuffix [fFlL]
|
||||
chartext ([^'])|(\\.)
|
||||
stringtext ([^"])|(\\.)
|
||||
|
||||
digit [0-9]
|
||||
hex [0-9A-Fa-f]
|
||||
letter [A-Z_a-z]
|
||||
simple_escape_sequence (\\\'|\\\"|\\\?|\\\\|\\a|\\b|\\f|\\n|\\r|\\t|\\v)
|
||||
octal_escape_sequence (\\[0-7]|\\[0-7][0-7]|\\[0-7][0-7][0-7])
|
||||
hexadecimal_escape_sequence (\\x{hex}+)
|
||||
escape_sequence ({simple_escape_sequence}|{octal_escape_sequence}|{hexadecimal_escape_sequence})
|
||||
universal_character_name (\\u{hex}{hex}{hex}{hex}|\\U{hex}{hex}{hex}{hex}{hex}{hex}{hex}{hex})
|
||||
non_digit ({letter}|{universal_character_name})
|
||||
identifier ({non_digit}({non_digit}|{digit})*)
|
||||
|
||||
begin_comment "/*"
|
||||
end_comment "*/"
|
||||
begin_inline_comment "//"
|
||||
end_inline_comment "\n"
|
||||
|
||||
|
||||
%s moc
|
||||
%x cmt
|
||||
%x inlcmt
|
||||
|
||||
%%
|
||||
|
||||
"\n" { ++lineno; ECHO; }
|
||||
{blank} ECHO;
|
||||
|
||||
{begin_comment} { ENSTATE(cmt); ECHO; }
|
||||
<cmt>{end_comment} { EXSTATE; ECHO; }
|
||||
|
||||
{begin_inline_comment} { ENSTATE(inlcmt); ECHO; }
|
||||
<inlcmt>{end_inline_comment} { EXSTATE; ECHO; }
|
||||
|
||||
|
||||
property { ECHO; ENSTATE(moc); return MOC_PROPERTY; }
|
||||
ULIB_OBJECT_PARAMETERS { ECHO; ENSTATE(moc); return MOC_OBJECT_PARAMETERS; }
|
||||
<moc>{
|
||||
"{" { moc_level++; MATCH('{'); }
|
||||
"}" { if(!--moc_level)EXSTATE; MATCH('}'); }
|
||||
|
||||
"<%" { MATCH('{'); }
|
||||
"%>" { MATCH('}'); }
|
||||
"[" { MATCH('['); }
|
||||
"<:" { MATCH('['); }
|
||||
"]" { MATCH(']'); }
|
||||
":>" { MATCH(']'); }
|
||||
"(" { MATCH('('); }
|
||||
")" { MATCH(')'); }
|
||||
";" { MATCH(';'); }
|
||||
"::" { MATCH(COLONCOLON); }
|
||||
":" { MATCH(':'); }
|
||||
"..." { MATCH(ELLIPSIS); }
|
||||
"?" { MATCH('?'); }
|
||||
"." { MATCH('.'); }
|
||||
".*" { MATCH(DOTSTAR); }
|
||||
"+" { MATCH('+'); }
|
||||
"-" { MATCH('-'); }
|
||||
"*" { MATCH('*'); }
|
||||
"/" { MATCH('/'); }
|
||||
"%" { MATCH('%'); }
|
||||
"^" { MATCH('^'); }
|
||||
"xor" { MATCH('^'); }
|
||||
"&" { MATCH('&'); }
|
||||
"bitand" { MATCH('&'); }
|
||||
"|" { MATCH('|'); }
|
||||
"bitor" { MATCH('|'); }
|
||||
"~" { MATCH('~'); }
|
||||
"compl" { MATCH('~'); }
|
||||
"!" { MATCH('!'); }
|
||||
"not" { MATCH('!'); }
|
||||
"=" { MATCH('='); }
|
||||
"<" { MATCH('<'); }
|
||||
">" { MATCH('>'); }
|
||||
"+=" { MATCH(ADDEQ); }
|
||||
"-=" { MATCH(SUBEQ); }
|
||||
"*=" { MATCH(MULEQ); }
|
||||
"/=" { MATCH(DIVEQ); }
|
||||
"%=" { MATCH(MODEQ); }
|
||||
"^=" { MATCH(XOREQ); }
|
||||
"xor_eq" { MATCH(XOREQ); }
|
||||
"&=" { MATCH(ANDEQ); }
|
||||
"and_eq" { MATCH(ANDEQ); }
|
||||
"|=" { MATCH(OREQ); }
|
||||
"or_eq" { MATCH(OREQ); }
|
||||
"<<" { MATCH(SL); }
|
||||
">>" { MATCH(SR); }
|
||||
"<<=" { MATCH(SLEQ); }
|
||||
">>=" { MATCH(SREQ); }
|
||||
"==" { MATCH(EQ); }
|
||||
"!=" { MATCH(NOTEQ); }
|
||||
"not_eq" { MATCH(NOTEQ); }
|
||||
"<=" { MATCH(LTEQ); }
|
||||
">=" { MATCH(GTEQ); }
|
||||
"&&" { MATCH(ANDAND); }
|
||||
"and" { MATCH(ANDAND); }
|
||||
"||" { MATCH(OROR); }
|
||||
"or" { MATCH(OROR); }
|
||||
"++" { MATCH(PLUSPLUS); }
|
||||
"--" { MATCH(MINUSMINUS); }
|
||||
"," { MATCH(','); }
|
||||
"->*" { MATCH(ARROWSTAR); }
|
||||
"->" { MATCH(ARROW); }
|
||||
|
||||
"asm" { MATCH(ASM); }
|
||||
"auto" { MATCH(AUTO); }
|
||||
"bool" { MATCH(BOOL); }
|
||||
"break" { MATCH(BREAK); }
|
||||
"case" { MATCH(CASE); }
|
||||
"catch" { MATCH(CATCH); }
|
||||
"char" { MATCH(CHAR); }
|
||||
"class" { MATCH(CLASS); }
|
||||
"const" { MATCH(CONST); }
|
||||
"const_cast" { MATCH(CONST_CAST); }
|
||||
"continue" { MATCH(CONTINUE); }
|
||||
"default" { MATCH(DEFAULT); }
|
||||
"delete" { MATCH(DELETE); }
|
||||
"do" { MATCH(DO); }
|
||||
"double" { MATCH(DOUBLE); }
|
||||
"dynamic_cast" { MATCH(DYNAMIC_CAST); }
|
||||
"else" { MATCH(ELSE); }
|
||||
"enum" { MATCH(ENUM); }
|
||||
"explicit" { MATCH(EXPLICIT); }
|
||||
"export" { MATCH(EXPORT); }
|
||||
"extern" { MATCH(EXTERN); }
|
||||
"false" { MATCH(FALSE); }
|
||||
"float" { MATCH(FLOAT); }
|
||||
"for" { MATCH(FOR); }
|
||||
"friend" { MATCH(FRIEND); }
|
||||
"goto" { MATCH(GOTO); }
|
||||
"if" { MATCH(IF); }
|
||||
"inline" { MATCH(INLINE); }
|
||||
"int" { MATCH(INT); }
|
||||
"long" { MATCH(LONG); }
|
||||
"mutable" { MATCH(MUTABLE); }
|
||||
"namespace" { MATCH(NAMESPACE); }
|
||||
"new" { MATCH(NEW); }
|
||||
"operator" { MATCH(OPERATOR); }
|
||||
"private" { MATCH(PRIVATE); }
|
||||
"protected" { MATCH(PROTECTED); }
|
||||
"public" { MATCH(PUBLIC); }
|
||||
"register" { MATCH(REGISTER); }
|
||||
"reinterpret_cast" { MATCH(REINTERPRET_CAST); }
|
||||
"return" { MATCH(RETURN); }
|
||||
"short" { MATCH(SHORT); }
|
||||
"signed" { MATCH(SIGNED); }
|
||||
"sizeof" { MATCH(SIZEOF); }
|
||||
"static" { MATCH(STATIC); }
|
||||
"static_cast" { MATCH(STATIC_CAST); }
|
||||
"struct" { MATCH(STRUCT); }
|
||||
"switch" { MATCH(SWITCH); }
|
||||
"template" { MATCH(TEMPLATE); }
|
||||
"this" { MATCH(THIS); }
|
||||
"throw" { MATCH(THROW); }
|
||||
"true" { MATCH(TRUE); }
|
||||
"try" { MATCH(TRY); }
|
||||
"typedef" { MATCH(TYPEDEF); }
|
||||
"typeid" { MATCH(TYPEID); }
|
||||
"typename" { MATCH(TYPENAME); }
|
||||
"union" { MATCH(UNION); }
|
||||
"unsigned" { MATCH(UNSIGNED); }
|
||||
"using" { MATCH(USING); }
|
||||
"virtual" { MATCH(VIRTUAL); }
|
||||
"void" { MATCH(VOID); }
|
||||
"volatile" { MATCH(VOLATILE); }
|
||||
"wchar_t" { MATCH(WCHAR_T); }
|
||||
"while" { MATCH(WHILE); }
|
||||
[a-zA-Z_][a-zA-Z_0-9]* { ECHO; return check_identifier(yytext); }
|
||||
|
||||
"0"[xX][0-9a-fA-F]+{intsuffix}? { ECHO; return INTEGER; }
|
||||
"0"[0-7]+{intsuffix}? { ECHO; return INTEGER; }
|
||||
[0-9]+{intsuffix}? { ECHO; return INTEGER; }
|
||||
|
||||
{fracconst}{exppart}?{floatsuffix}? { ECHO; return FLOATING; }
|
||||
[0-9]+{exppart}{floatsuffix}? { ECHO; return FLOATING; }
|
||||
|
||||
"'"{chartext}*"'" { ECHO; return CHARACTER; }
|
||||
"L'"{chartext}*"'" { ECHO; return CHARACTER; }
|
||||
"\""{stringtext}*"\"" { ECHO; return STRING; }
|
||||
"L\""{stringtext}*"\"" { ECHO; return STRING; }
|
||||
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
static int yywrap(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int fill_sval() {
|
||||
int len = strlen(yytext);
|
||||
if(len) {
|
||||
yylval.sval = malloc(len);
|
||||
strncpy(yylval.sval, yytext, len);
|
||||
}
|
||||
else {
|
||||
yylval.sval = strdup("");
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static int check_identifier(const char *s)
|
||||
{
|
||||
/*
|
||||
switch (s[0]) {
|
||||
case 'D': return TYPEDEF_NAME;
|
||||
case 'N': return NAMESPACE_NAME;
|
||||
case 'C': return CLASS_NAME;
|
||||
case 'E': return ENUM_NAME;
|
||||
case 'T': return TEMPLATE_NAME;
|
||||
}
|
||||
*/
|
||||
|
||||
yylval.sval = malloc(strlen(yytext));
|
||||
strncpy(yylval.sval, yytext, strlen(yytext));
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user