17e90fac2SAndrew Rist#************************************************************** 27e90fac2SAndrew Rist# 37e90fac2SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 47e90fac2SAndrew Rist# or more contributor license agreements. See the NOTICE file 57e90fac2SAndrew Rist# distributed with this work for additional information 67e90fac2SAndrew Rist# regarding copyright ownership. The ASF licenses this file 77e90fac2SAndrew Rist# to you under the Apache License, Version 2.0 (the 87e90fac2SAndrew Rist# "License"); you may not use this file except in compliance 97e90fac2SAndrew Rist# with the License. You may obtain a copy of the License at 107e90fac2SAndrew Rist# 117e90fac2SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 127e90fac2SAndrew Rist# 137e90fac2SAndrew Rist# Unless required by applicable law or agreed to in writing, 147e90fac2SAndrew Rist# software distributed under the License is distributed on an 157e90fac2SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 167e90fac2SAndrew Rist# KIND, either express or implied. See the License for the 177e90fac2SAndrew Rist# specific language governing permissions and limitations 187e90fac2SAndrew Rist# under the License. 197e90fac2SAndrew Rist# 207e90fac2SAndrew Rist#************************************************************** 217e90fac2SAndrew Rist 227e90fac2SAndrew Rist 23cdf0e10cSrcweir 24*b63233d8Sdamjan# operation mode (1 = identifiers, 2 = names, 3 = plain) 25*b63233d8Sdamjan$op = shift @ARGV; 26*b63233d8Sdamjandie "Error: invalid operation" unless( $op >= 1 && $op <= 3); 27cdf0e10cSrcweir 28*b63233d8Sdamjan# number of bits to shift the namespace identifier 29*b63233d8Sdamjan$shift = 16; 30*b63233d8Sdamjan 31*b63233d8Sdamjanif( $op == 1 ) { 32*b63233d8Sdamjan print( "const size_t NMSP_SHIFT = $shift;\n" ); 33*b63233d8Sdamjan} 34cdf0e10cSrcweir 35*b63233d8Sdamjan$i = 1; 36*b63233d8Sdamjanwhile( <> ) { 37cdf0e10cSrcweir # trim newline 38cdf0e10cSrcweir chomp( $_ ); 39cdf0e10cSrcweir # trim leading/trailing whitespace 40cdf0e10cSrcweir $_ =~ s/^\s*//g; 41cdf0e10cSrcweir $_ =~ s/\s*$//g; 42cdf0e10cSrcweir # trim comments 43cdf0e10cSrcweir $_ =~ s/^#.*//; 44cdf0e10cSrcweir # skip empty lines 45*b63233d8Sdamjan if( $_ ) { 46cdf0e10cSrcweir # check for valid characters 47*b63233d8Sdamjan $_ =~ /^([a-zA-Z]+)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid entry: '$_'"; 48*b63233d8Sdamjan # generate output 49*b63233d8Sdamjan $id = $i << $shift; 50*b63233d8Sdamjan if( $op == 1 ) { print( "const sal_Int32 NMSP_$1 = $i << NMSP_SHIFT;\n" ); } 51*b63233d8Sdamjan elsif( $op == 2 ) { print( "{ $id, \"$2\" },\n" ); } 52*b63233d8Sdamjan elsif( $op == 3 ) { print( "$id $1 $2\n" ); } 53*b63233d8Sdamjan ++$i; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir} 56