@@ -116,6 +116,67 @@ SET ( FUNCTIONS
116116 "G_zero"
117117)
118118
119+ # List of functions which are implemented in qgsgrassgislib.cpp and
120+ # thus we only need prototype
121+ SET ( FUNCTION_PROTOTYPES
122+ "G__gisinit"
123+ "G_parser"
124+ "G_set_error_routine"
125+ "G_warning"
126+ "G_fatal_error"
127+ "G_done_msg"
128+ "*G_find_cell2"
129+ "*G_find_cell"
130+ "G_open_cell_old"
131+ "G_close_cell"
132+ "G_open_raster_new"
133+ "G_open_cell_new"
134+ "G_raster_map_is_fp"
135+ "G_read_fp_range"
136+ "G_read_range"
137+ "G_debug"
138+ "G_message"
139+ "G_verbose_message"
140+ "G_set_quant_rules"
141+ "G_get_raster_row"
142+ "G_get_raster_row_nomask"
143+ "G_get_c_raster_row"
144+ "G_get_c_raster_row_nomask"
145+ "G_get_f_raster_row"
146+ "G_get_f_raster_row_nomask"
147+ "G_get_d_raster_row"
148+ "G_get_d_raster_row_nomask"
149+ "G_get_map_row"
150+ "G_get_map_row_nomask"
151+ "G_put_raster_row"
152+ "G_check_input_output_name"
153+ "G_get_cellhd"
154+ "G_database_units_to_meters_factor"
155+ "G_begin_distance_calculations"
156+ "G_distance"
157+ "G_legal_filename"
158+ "G_tempfile"
159+ "G_mapset"
160+ "G_location"
161+ "G_write_colors"
162+ "G_quantize_fp_map_range"
163+ "G_read_raster_cats"
164+ "G_write_raster_cats"
165+ "G_short_history"
166+ "G_write_history"
167+ "G_maskfd"
168+ "G_command_history"
169+ "G_set_cats_title"
170+ "G_read_history"
171+ "G_read_colors"
172+ "G_make_aspect_fp_colors"
173+ )
174+
175+ SET ( FUNCTIONS_ALL
176+ ${FUNCTIONS}
177+ ${FUNCTION_PROTOTYPES}
178+ )
179+
119180# Read GRASS header file and create functions mapping
120181FILE (READ "${GRASS_INCLUDE_DIR} /grass/gisdefs.h" HEADER_FILE)
121182
@@ -130,7 +191,7 @@ LIST ( APPEND PROTOTYPES "#define GRASS_GISDEFS_H\n" )
130191LIST ( APPEND PROTOTYPES "extern \" C\"\n " )
131192LIST ( APPEND PROTOTYPES "{\n " )
132193LIST ( APPEND PROTOTYPES "#include <grass/gis.h>\n " )
133- LIST ( APPEND PROTOTYPES "int GRASS_LIB_EXPORT G_set_error_routine(int (*)(const char *, int))\;\n " )
194+ # LIST ( APPEND PROTOTYPES "int GRASS_LIB_EXPORT G_set_error_routine(int (*)(const char *, int))\;\n" )
134195
135196SET ( FUNCTIONS_MAP "// Auto generated by cmake, do not edit\n " )
136197LIST ( APPEND FUNCTIONS_MAP "#include \" qgsgrassgislibfunctions.h\"\n " )
@@ -144,9 +205,8 @@ FOREACH( ROW ${HEADER_FILE} )
144205 #MESSAGE (STATUS, "ROW: ${ROW}")
145206 # Parse function declaration
146207 STRING ( REGEX REPLACE ".*(G_[^\\ (]*)\\ (.*" "\\ 1" FUNCTION_NAME "${ROW} " )
147- FOREACH ( FN ${FUNCTIONS } )
208+ FOREACH ( FN ${FUNCTIONS_ALL } )
148209 IF ( "${FN} " STREQUAL "${FUNCTION_NAME} " )
149- LIST ( APPEND FUNCTIONS_MAP "// ${ROW} \n " )
150210 # \\*? and \\** patterns do not work, why?
151211 STRING ( REGEX REPLACE "^[ \t ]*(.*)G_.*" "\\ 1" FUNCTION_TYPE "${ROW} " )
152212 STRING ( REGEX REPLACE "\\ *" "" FUNCTION_TYPE "${FUNCTION_TYPE} " )
@@ -170,15 +230,21 @@ FOREACH( ROW ${HEADER_FILE} )
170230 STRING ( REPLACE ";" ", " PARAM_NAMES "${PARAM_NAMES} " )
171231 STRING ( REPLACE ";" ", " PARAMS "${PARAMS} " )
172232
173- # Declare function type
174- LIST ( APPEND FUNCTIONS_MAP "typedef ${FUNCTION_TYPE} ${POINTER} ${FUNCTION_NAME} _type(${PARAM_TYPES} )\;\n\n " )
175- LIST ( APPEND FUNCTIONS_MAP "${FUNCTION_TYPE} GRASS_LIB_EXPORT ${POINTER} ${FUNCTION_NAME} ( ${PARAMS} ) {\n " )
233+ # Declare all
176234 LIST ( APPEND PROTOTYPES "${FUNCTION_TYPE} GRASS_LIB_EXPORT ${POINTER} ${FUNCTION_NAME} ( ${PARAM_TYPES} )\;\n " )
177- #LIST ( APPEND FUNCTIONS_MAP " QgsDebugMsg( \"Entered\" )\;\n" )
178235
179- LIST ( APPEND FUNCTIONS_MAP " ${FUNCTION_NAME} _type* fn = (${FUNCTION_NAME} _type*) cast_to_fptr (QgsGrassGisLib::instance()->resolve( \" ${FUNCTION_NAME} \" ))\;\n " )
180- LIST ( APPEND FUNCTIONS_MAP " return fn( ${PARAM_NAMES} )\;\n " )
181- LIST ( APPEND FUNCTIONS_MAP "}\n\n " )
236+ # Define only those not implemented in qgsgrassgislib.cpp
237+ LIST (FIND FUNCTIONS "${FUNCTION_NAME} " FUNCTION_IDX)
238+ IF ( ${FUNCTION_IDX} GREATER -1 )
239+ LIST ( APPEND FUNCTIONS_MAP "// ${ROW} \n " )
240+ # Declare function type
241+ LIST ( APPEND FUNCTIONS_MAP "typedef ${FUNCTION_TYPE} ${POINTER} ${FUNCTION_NAME} _type(${PARAM_TYPES} )\;\n\n " )
242+ LIST ( APPEND FUNCTIONS_MAP "${FUNCTION_TYPE} GRASS_LIB_EXPORT ${POINTER} ${FUNCTION_NAME} ( ${PARAMS} ) {\n " )
243+ #LIST ( APPEND FUNCTIONS_MAP " QgsDebugMsg( \"Entered\" )\;\n" )
244+ LIST ( APPEND FUNCTIONS_MAP " ${FUNCTION_NAME} _type* fn = (${FUNCTION_NAME} _type*) cast_to_fptr (QgsGrassGisLib::instance()->resolve( \" ${FUNCTION_NAME} \" ))\;\n " )
245+ LIST ( APPEND FUNCTIONS_MAP " return fn( ${PARAM_NAMES} )\;\n " )
246+ LIST ( APPEND FUNCTIONS_MAP "}\n\n " )
247+ ENDIF ( ${FUNCTION_IDX} GREATER -1 )
182248 ENDIF ( "${FN} " STREQUAL "${FUNCTION_NAME} " )
183249 ENDFOREACH ( FN )
184250ENDFOREACH ( ROW )
0 commit comments