github.com/mmatczuk/gohan@v0.0.0-20170206152520-30e45d9bdb69/extension/gohanscript/autogen/lib_atomic.go (about)

     1  package autogen
     2  
     3  // AUTO GENERATED CODE DO NOT MODIFY MANUALLY
     4  import (
     5  	"github.com/cloudwan/gohan/extension/gohanscript"
     6  	"github.com/cloudwan/gohan/extension/gohanscript/lib"
     7  	"github.com/cloudwan/gohan/util"
     8  	"github.com/streamrail/concurrent-map"
     9  )
    10  
    11  func init() {
    12  
    13  	gohanscript.RegisterStmtParser("make_map",
    14  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
    15  			return func(context *gohanscript.Context) (interface{}, error) {
    16  
    17  				result1 :=
    18  					lib.MakeMap()
    19  
    20  				return result1, nil
    21  
    22  			}, nil
    23  		})
    24  	gohanscript.RegisterMiniGoFunc("MakeMap",
    25  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
    26  
    27  			result1 :=
    28  				lib.MakeMap()
    29  			return []interface{}{
    30  				result1}
    31  
    32  		})
    33  
    34  	gohanscript.RegisterStmtParser("map_set",
    35  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
    36  			return func(context *gohanscript.Context) (interface{}, error) {
    37  
    38  				var m cmap.ConcurrentMap
    39  				im := stmt.Arg("m", context)
    40  				if im != nil {
    41  					m = im.(cmap.ConcurrentMap)
    42  				}
    43  				var key string
    44  				ikey := stmt.Arg("key", context)
    45  				if ikey != nil {
    46  					key = ikey.(string)
    47  				}
    48  				var value interface{}
    49  				ivalue := stmt.Arg("value", context)
    50  				if ivalue != nil {
    51  					value = ivalue.(interface{})
    52  				}
    53  
    54  				lib.MapSet(
    55  					m, key, value)
    56  				return nil, nil
    57  
    58  			}, nil
    59  		})
    60  	gohanscript.RegisterMiniGoFunc("MapSet",
    61  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
    62  
    63  			m, _ := args[0].(cmap.ConcurrentMap)
    64  			key, _ := args[0].(string)
    65  			value, _ := args[0].(interface{})
    66  
    67  			lib.MapSet(
    68  				m, key, value)
    69  			return nil
    70  
    71  		})
    72  
    73  	gohanscript.RegisterStmtParser("map_get",
    74  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
    75  			return func(context *gohanscript.Context) (interface{}, error) {
    76  
    77  				var m cmap.ConcurrentMap
    78  				im := stmt.Arg("m", context)
    79  				if im != nil {
    80  					m = im.(cmap.ConcurrentMap)
    81  				}
    82  				var key string
    83  				ikey := stmt.Arg("key", context)
    84  				if ikey != nil {
    85  					key = ikey.(string)
    86  				}
    87  
    88  				result1 :=
    89  					lib.MapGet(
    90  						m, key)
    91  
    92  				return result1, nil
    93  
    94  			}, nil
    95  		})
    96  	gohanscript.RegisterMiniGoFunc("MapGet",
    97  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
    98  
    99  			m, _ := args[0].(cmap.ConcurrentMap)
   100  			key, _ := args[0].(string)
   101  
   102  			result1 :=
   103  				lib.MapGet(
   104  					m, key)
   105  			return []interface{}{
   106  				result1}
   107  
   108  		})
   109  
   110  	gohanscript.RegisterStmtParser("map_has",
   111  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
   112  			return func(context *gohanscript.Context) (interface{}, error) {
   113  
   114  				var m cmap.ConcurrentMap
   115  				im := stmt.Arg("m", context)
   116  				if im != nil {
   117  					m = im.(cmap.ConcurrentMap)
   118  				}
   119  				var key string
   120  				ikey := stmt.Arg("key", context)
   121  				if ikey != nil {
   122  					key = ikey.(string)
   123  				}
   124  
   125  				result1 :=
   126  					lib.MapHas(
   127  						m, key)
   128  
   129  				return result1, nil
   130  
   131  			}, nil
   132  		})
   133  	gohanscript.RegisterMiniGoFunc("MapHas",
   134  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
   135  
   136  			m, _ := args[0].(cmap.ConcurrentMap)
   137  			key, _ := args[0].(string)
   138  
   139  			result1 :=
   140  				lib.MapHas(
   141  					m, key)
   142  			return []interface{}{
   143  				result1}
   144  
   145  		})
   146  
   147  	gohanscript.RegisterStmtParser("map_remove",
   148  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
   149  			return func(context *gohanscript.Context) (interface{}, error) {
   150  
   151  				var m cmap.ConcurrentMap
   152  				im := stmt.Arg("m", context)
   153  				if im != nil {
   154  					m = im.(cmap.ConcurrentMap)
   155  				}
   156  				var key string
   157  				ikey := stmt.Arg("key", context)
   158  				if ikey != nil {
   159  					key = ikey.(string)
   160  				}
   161  
   162  				lib.MapRemove(
   163  					m, key)
   164  				return nil, nil
   165  
   166  			}, nil
   167  		})
   168  	gohanscript.RegisterMiniGoFunc("MapRemove",
   169  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
   170  
   171  			m, _ := args[0].(cmap.ConcurrentMap)
   172  			key, _ := args[0].(string)
   173  
   174  			lib.MapRemove(
   175  				m, key)
   176  			return nil
   177  
   178  		})
   179  
   180  	gohanscript.RegisterStmtParser("make_counter",
   181  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
   182  			return func(context *gohanscript.Context) (interface{}, error) {
   183  
   184  				var value int
   185  				ivalue := stmt.Arg("value", context)
   186  				if ivalue != nil {
   187  					value = ivalue.(int)
   188  				}
   189  
   190  				result1 :=
   191  					lib.MakeCounter(
   192  						value)
   193  
   194  				return result1, nil
   195  
   196  			}, nil
   197  		})
   198  	gohanscript.RegisterMiniGoFunc("MakeCounter",
   199  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
   200  
   201  			value, _ := args[0].(int)
   202  
   203  			result1 :=
   204  				lib.MakeCounter(
   205  					value)
   206  			return []interface{}{
   207  				result1}
   208  
   209  		})
   210  
   211  	gohanscript.RegisterStmtParser("counter_add",
   212  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
   213  			return func(context *gohanscript.Context) (interface{}, error) {
   214  
   215  				var counter *util.Counter
   216  				icounter := stmt.Arg("counter", context)
   217  				if icounter != nil {
   218  					counter = icounter.(*util.Counter)
   219  				}
   220  				var value int
   221  				ivalue := stmt.Arg("value", context)
   222  				if ivalue != nil {
   223  					value = ivalue.(int)
   224  				}
   225  
   226  				lib.CounterAdd(
   227  					counter, value)
   228  				return nil, nil
   229  
   230  			}, nil
   231  		})
   232  	gohanscript.RegisterMiniGoFunc("CounterAdd",
   233  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
   234  
   235  			counter, _ := args[0].(*util.Counter)
   236  			value, _ := args[0].(int)
   237  
   238  			lib.CounterAdd(
   239  				counter, value)
   240  			return nil
   241  
   242  		})
   243  
   244  	gohanscript.RegisterStmtParser("counter_value",
   245  		func(stmt *gohanscript.Stmt) (func(*gohanscript.Context) (interface{}, error), error) {
   246  			return func(context *gohanscript.Context) (interface{}, error) {
   247  
   248  				var counter *util.Counter
   249  				icounter := stmt.Arg("counter", context)
   250  				if icounter != nil {
   251  					counter = icounter.(*util.Counter)
   252  				}
   253  
   254  				result1 :=
   255  					lib.CounterValue(
   256  						counter)
   257  
   258  				return result1, nil
   259  
   260  			}, nil
   261  		})
   262  	gohanscript.RegisterMiniGoFunc("CounterValue",
   263  		func(vm *gohanscript.VM, args []interface{}) []interface{} {
   264  
   265  			counter, _ := args[0].(*util.Counter)
   266  
   267  			result1 :=
   268  				lib.CounterValue(
   269  					counter)
   270  			return []interface{}{
   271  				result1}
   272  
   273  		})
   274  
   275  }