vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

TableField

moyack · 507

0 Members and 1 Guest are viewing this topic.

TableField
on: February 22, 2012, 11:42:49 PM
Category: Variables
Language: vJASS

Related Topics or Resources



by

Code: jass
  1. library TableField /* v1.0.0.1
  2. ************************************************************************************
  3. *
  4. *       */ uses /*
  5. *
  6. *               */ Table        /*
  7. *               */ Init         /*
  8. *
  9. ************************************************************************************
  10. *
  11. *       //! textmacro CREATE_TABLE_FIELD takes ACCESS_MODIFIER, TYPE, NAME, RETURN_TYPE
  12. *               -       creates a table field surrounded by method operators
  13. *
  14. *       //! textmacro INITIALIZE_TABLE_FIELD takes NAME
  15. *               -       initializes table field
  16. *               -       used in onInit
  17. *
  18. *       //! textmacro CREATE_TABLE_FIELD_ARRAY takes TYPE, NAME, RETURN_TYPE
  19. *               -       creates a struct that acts as an array
  20. *               -       not used in a struct
  21. *
  22. *       //! textmacro USE_TABLE_FIELD_ARRAY takes ACCESS_MODIFIER, NAME
  23. *               -       creates a field of a struct array
  24. *               -       used in a struct
  25. *
  26. ************************************************************************************/
  27.         //! textmacro CREATE_TABLE_FIELD takes ACCESS_MODIFIER, TYPE, NAME, RETURN_TYPE
  28.                 private static Table t$NAME$
  29.                        
  30.                 $ACCESS_MODIFIER$ method operator $NAME$ takes nothing returns $RETURN_TYPE$
  31.                         return t$NAME$.$TYPE$[this]
  32.                 endmethod
  33.                 $ACCESS_MODIFIER$ method operator $NAME$= takes $RETURN_TYPE$ value returns nothing
  34.                         set t$NAME$.$TYPE$[this] = value
  35.                 endmethod
  36.                 $ACCESS_MODIFIER$ method $NAME$_clear takes nothing returns nothing
  37.                         call t$NAME$.$TYPE$.remove(this)
  38.                 endmethod
  39.         //! endtextmacro
  40.        
  41.         //! textmacro CREATE_TABLE_FIELD_ARRAY takes TYPE, NAME, RETURN_TYPE
  42.                 private struct T$NAME$ extends array
  43.                         private static Table table
  44.                        
  45.                         method operator [] takes integer index returns $RETURN_TYPE$
  46.                                 return table.$TYPE$[index]
  47.                         endmethod
  48.                         method operator []= takes integer index, $RETURN_TYPE$ value returns nothing
  49.                                 set table.$TYPE$[index] = value
  50.                         endmethod
  51.                         static method remove takes integer index returns nothing
  52.                                 call table.$TYPE$.remove(index)
  53.                         endmethod
  54.                         static method clear takes nothing returns nothing
  55.                                 call table.flush()
  56.                         endmethod
  57.                        
  58.                         private static method init takes nothing returns nothing
  59.                                 set table = Table.create()
  60.                         endmethod
  61.                        
  62.                         implement Init
  63.                 endstruct
  64.         //! endtextmacro
  65.        
  66.         //! textmacro USE_TABLE_FIELD_ARRAY takes ACCESS_MODIFIER, NAME
  67.                 $ACCESS_MODIFIER$ static T$NAME$ $NAME$ = 0
  68.         //! endtextmacro
  69.        
  70.         //! textmacro INITIALIZE_TABLE_FIELD takes NAME
  71.                 set t$NAME$ = Table.create()
  72.         //! endtextmacro
  73. endlibrary
« Last Edit: December 19, 2017, 12:56:18 AM by moyack »



 

Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)