First NIT release and new clean mercurial repository
[nit.git] / lib / standard / environ.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2006 Floréal Morandat <morandat@lirmm.fr>
4 # Copyright 2008 Jean Privat <jean@pryen.org>
5 #
6 # This file is free software, which comes along with NIT. This software is
7 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
10 # is kept unaltered, and a notification of the changes is added.
11 # You are allowed to redistribute it and sell it, alone or is a part of
12 # another product.
13
14 import symbol
15
16 # TODO prevoir une structure pour recup tout un environ, le modifier et le passer a process
17
18 redef class Symbol
19 # Return environement valued for this symbol
20 meth environ: String
21 do
22 environ_default = "" # FIXME: Why this ?!?
23 return new String.from_cstring(to_s.to_cstring.get_environ)
24 end
25
26 # set environement value for this symbol
27 meth environ=(v: String) do to_s.to_cstring.set_environ(v.to_cstring, 1)
28
29 # set default environement value for this symbol
30 meth environ_default=(v: String) do to_s.to_cstring.set_environ(v.to_cstring, 0)
31
32 # Unset the environement value of this symbol
33 meth unset do to_s.to_cstring.unset_environ
34 end
35
36 redef class NativeString
37 # Refinned to add environement bindings
38 private meth get_environ: NativeString is extern "string_NativeString_NativeString_get_environ_0"
39 private meth put_environ is extern "string_NativeString_NativeString_put_environ_0" # this one is a bit compilcated to use ... so we dosen't use
40 private meth unset_environ is extern "string_NativeString_NativeString_unset_environ_0"
41 private meth set_environ(value : NativeString, overwrite : Int) is extern "string_NativeString_NativeString_set_environ_2"
42 end