summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorDaniel Sikeler <d.sikeler94@gmail.com>2014-12-17 12:43:06 +0000
committerMatúš Kukan <matus.kukan@collabora.com>2014-12-22 13:28:37 +0100
commit2116f511bd97b4e7ee3137735f3937db1f2e97ab (patch)
tree5785771371540fdb6b21d7862d07a294d8062b53 /oox
parentc6fd07e0e46fa6ecba38cf7bd2f0e0312eaf7600 (diff)
Refactor building perfect hash tabels for tokens
moved the defines to be usable in more modules moved perl-script to be usable in more modules Change-Id: If893e4b7e9dc670646bdf097cb6fa5710e45f1ac
Diffstat (limited to 'oox')
-rw-r--r--oox/CustomTarget_generated.mk40
-rw-r--r--oox/source/token/tokens.pl65
2 files changed, 5 insertions, 100 deletions
diff --git a/oox/CustomTarget_generated.mk b/oox/CustomTarget_generated.mk
index 640f4e4232c3..462aef2e03a3 100644
--- a/oox/CustomTarget_generated.mk
+++ b/oox/CustomTarget_generated.mk
@@ -9,10 +9,7 @@
$(eval $(call gb_CustomTarget_CustomTarget,oox/generated))
-oox_SRC := $(SRCDIR)/oox/source/token
oox_MISC := $(call gb_CustomTarget_get_workdir,oox/generated)/misc
-oox_INC := $(call gb_CustomTarget_get_workdir,oox/generated)
-oox_GENHEADERPATH := $(oox_INC)/oox/token
$(oox_MISC)/vml-shape-types : \
$(SRCDIR)/oox/source/export/preset-definitions-to-shape-types.pl \
@@ -32,42 +29,15 @@ $(oox_MISC)/oox-drawingml-adj-names : \
mkdir -p $(dir $@)
perl $< --drawingml-adj-names-data $(filter-out $<,$^) > $@.in_progress 2> $@.log && mv $@.in_progress $@
-$(oox_INC)/tokenhash.inc : $(oox_MISC)/tokenhash.gperf
- $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,GPF,1)
- $(GPERF) --compare-strncmp --switch=2 --readonly-tables $< | sed -e 's/(char\*)0/(char\*)0, 0/g' | grep -v '^#line' > $@
+# Generate tokens for oox
+$(eval $(call gb_CustomTarget_token_hash,oox/generated,tokenhash.inc,tokenhash.gperf))
-define oox_GenTarget
-$(oox_MISC)/$(2)ids.inc $(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) $(if $(4),$(oox_INC)/$(4)names.inc) : \
- $(oox_GENHEADERPATH)/$(1).hxx
- @touch $$@
-
-$(oox_GENHEADERPATH)/$(1).hxx : $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt \
- $(oox_SRC)/$(1).hxx.head $(oox_SRC)/$(1).hxx.tail
- $$(call gb_Output_announce,$$(subst $(WORKDIR)/,,$$@),build,PRL,1)
- mkdir -p $(oox_MISC) $(oox_INC) $(oox_GENHEADERPATH)
- perl $(oox_SRC)/$(1).pl $(oox_SRC)/$(1).txt $(oox_MISC)/$(2)ids.inc \
- $(oox_INC)/$(2)names.inc $(if $(3),$(oox_MISC)/$(3)) \
- $(if $(4),$(oox_SRC)/$(4).txt $(oox_INC)/$(4)names.inc) \
- && cat $(oox_SRC)/$(1).hxx.head $(oox_MISC)/$(2)ids.inc \
- $(oox_SRC)/$(1).hxx.tail > $(oox_GENHEADERPATH)/$(1).hxx \
- && touch $$@
-endef
-
-$(eval $(call oox_GenTarget,namespaces,namespace,namespaces.txt,namespaces-strict))
-$(eval $(call oox_GenTarget,properties,property,))
-$(eval $(call oox_GenTarget,tokens,token,tokenhash.gperf))
+$(eval $(call gb_CustomTarget_generate_tokens,oox/generated,oox,oox/source/token,namespaces,namespace,namespaces.txt,namespaces-strict,namespaces.pl))
+$(eval $(call gb_CustomTarget_generate_tokens,oox/generated,oox,oox/source/token,properties,property,,,properties.pl))
+$(eval $(call gb_CustomTarget_generate_tokens,oox/generated,oox,oox/source/token,tokens,token,tokenhash.gperf))
$(call gb_CustomTarget_get_target,oox/generated) : \
$(oox_MISC)/oox-drawingml-adj-names \
$(oox_MISC)/vml-shape-types \
- $(oox_INC)/tokenhash.inc \
- $(oox_INC)/tokennames.inc \
- $(oox_INC)/namespacenames.inc \
- $(oox_INC)/namespaces-strictnames.inc \
- $(oox_INC)/propertynames.inc \
- $(oox_GENHEADERPATH)/tokens.hxx \
- $(oox_GENHEADERPATH)/namespaces.hxx \
- $(oox_GENHEADERPATH)/properties.hxx \
- $(oox_MISC)/namespaces.txt \
# vim: set noet sw=4 ts=4:
diff --git a/oox/source/token/tokens.pl b/oox/source/token/tokens.pl
deleted file mode 100644
index b6391a760358..000000000000
--- a/oox/source/token/tokens.pl
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$ARGV0 = shift @ARGV;
-$ARGV1 = shift @ARGV;
-$ARGV2 = shift @ARGV;
-$ARGV3 = shift @ARGV;
-
-open ( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!";
-open ( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!";
-open ( GPERFFILE, ">$ARGV3" ) or die "Error: cannot open output file: $!";
-
-print( GPERFFILE "%language=C++\n" );
-print( GPERFFILE "%global-table\n" );
-print( GPERFFILE "%null-strings\n" );
-print( GPERFFILE "%struct-type\n" );
-print( GPERFFILE "struct xmltoken {\n" );
-print( GPERFFILE " const sal_Char *name;\n" );
-print( GPERFFILE " sal_Int32 nToken;\n" );
-print( GPERFFILE "};\n" );
-print( GPERFFILE "%%\n" );
-
-open( INFILE, $ARGV0 ) or die "Error: cannot open input file: $!";
-
-$i = 0;
-while ( <INFILE> )
-{
- # trim newline
- chomp( $_ );
- # trim leading/trailing whitespace
- $_ =~ s/^\s*//g;
- $_ =~ s/\s*$//g;
- # check for valid characters
- $_ =~ /^[a-zA-Z0-9-_]+$/ or die "Error: invalid character in token '$_'";
- $id = "XML_$_";
- $id =~ s/-/_/g;
- $tokens{$_} = $id;
- print( IDFILE "const sal_Int32 $id = $i;\n" );
- print( NAMEFILE "\"$_\",\n" );
- print( GPERFFILE "$_,$id\n" );
- ++$i;
-}
-close ( INFILE );
-
-print( IDFILE "const sal_Int32 XML_TOKEN_COUNT = $i;\n" );
-print( GPERFFILE "%%\n" );
-
-close( IDFILE );
-close( NAMEFILE );
-close( GPERFFILE );