Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

  1. #!perl
  2. print `p4 edit ../public/tier1/utlstringtoken_generated_contructors.h`;
  3. open( FOUT, ">../public/tier1/utlstringtoken_generated_contructors.h" ) || die "cant open output file";
  4. print FOUT "//===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//\n";
  5. print FOUT "//\n";
  6. print FOUT "// Purpose: inlines for compile-time hashing of constant strings\n";
  7. print FOUT "//\n";
  8. print FOUT "// $NoKeywords: \$\n";
  9. print FOUT "//\n";
  10. print FOUT "//===========================================================================//\n";
  11. print FOUT "// DO NOT EDIT THIS FILE - IT IS GENERATED BY RUNNING GENERATE_CONSTRUCTORS.PL\n\n";
  12. print FOUT "#define TOLOWERU( c ) ( ( uint32 ) ( ( ( c >= 'A' ) && ( c <= 'Z' ) )? c + 32 : c ) )\n";
  13. # generate for lengths 1 to 30
  14. for( $i = 1; $i < 30; $i++ )
  15. {
  16. $len = $i - 1;
  17. print FOUT "FORCEINLINE CUtlStringToken( const char ( \&str )[$i] )\n{\n";
  18. print FOUT "\tconst uint32 m = 0x5bd1e995;\n";
  19. print FOUT "\tuint32 h = STRINGTOKEN_MURMURHASH_SEED ^ $len;\n";
  20. $curpos = 0;
  21. print FOUT "\tuint32 k;\n" if ( $len >= 4 );
  22. print FOUT "\tconst int r = 24;\n" if ( $len >= 4 );
  23. while( $len >= 4)
  24. {
  25. print FOUT "\tk = TOLOWERU( str[ $curpos ] ) + ( TOLOWERU( str[ $curpos + 1 ] ) << 8 ) + ( TOLOWERU( str[ $curpos + 2 ] ) << 16 ) +";
  26. print FOUT "( TOLOWERU( str[ $curpos + 3 ] ) << 24 );\n";
  27. print FOUT "\tk *= m;\n";
  28. print FOUT "\tk ^= k >> r;\n";
  29. print FOUT "\tk *= m;\n";
  30. print FOUT "\th *= m;\n";
  31. print FOUT "\th ^= k;\n";
  32. $curpos += 4;
  33. $len -= 4;
  34. }
  35. print FOUT "\th ^= TOLOWERU( str[ $curpos + 2 ] ) << 16;\n" if ( $len >= 3 );
  36. print FOUT "\th ^= TOLOWERU( str[ $curpos + 1 ] ) << 8;\n" if ( $len >= 2 );
  37. print FOUT "\th ^= TOLOWERU( str[ $curpos + 0 ] );\n" if ( $len >= 1 );
  38. print FOUT "\th *= m;\n" if ( $len >= 1 );
  39. print FOUT "\th ^= h >> 13;\n";
  40. print FOUT "\th *= m;\n";
  41. print FOUT "\th ^= h >> 15;\n";
  42. print FOUT "\tm_nHashCode = h;\n}\n\n";
  43. }