25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

65 satır
2.4 KiB

  1. #!/bin/sh
  2. cat > lhash_macros.h << EOF
  3. /* Copyright (c) 2014, Google Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  12. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  14. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  15. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  16. #if !defined(IN_LHASH_H)
  17. #error "Don't include this file directly. Include lhash.h"
  18. #endif
  19. EOF
  20. output_lhash () {
  21. type=$1
  22. cat >> lhash_macros.h << EOF
  23. /* ${type} */
  24. #define lh_${type}_new(hash, comp)\\
  25. ((LHASH_OF(${type})*) lh_new(CHECKED_CAST(lhash_hash_func, uint32_t (*) (const ${type} *), hash), CHECKED_CAST(lhash_cmp_func, int (*) (const ${type} *a, const ${type} *b), comp)))
  26. #define lh_${type}_free(lh)\\
  27. lh_free(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh));
  28. #define lh_${type}_num_items(lh)\\
  29. lh_num_items(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh))
  30. #define lh_${type}_retrieve(lh, data)\\
  31. ((${type}*) lh_retrieve(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void*, ${type}*, data)))
  32. #define lh_${type}_insert(lh, old_data, data)\\
  33. lh_insert(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void**, ${type}**, old_data), CHECKED_CAST(void*, ${type}*, data))
  34. #define lh_${type}_delete(lh, data)\\
  35. ((${type}*) lh_delete(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void*, ${type}*, data)))
  36. #define lh_${type}_doall(lh, func)\\
  37. lh_doall(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void (*)(void*), void (*) (${type}*), func));
  38. #define lh_${type}_doall_arg(lh, func, arg)\\
  39. lh_doall_arg(CHECKED_CAST(_LHASH*, LHASH_OF(${type})*, lh), CHECKED_CAST(void (*)(void*, void*), void (*) (${type}*, void*), func), arg);
  40. EOF
  41. }
  42. lhash_types=$(cat lhash.h | grep '^ \* LHASH_OF:' | sed -e 's/.*LHASH_OF://' -e 's/ .*//')
  43. for type in $lhash_types; do
  44. echo Hash of ${type}
  45. output_lhash "${type}"
  46. done
  47. clang-format -i lhash_macros.h