and fix some mistakes in existing comments.
Signed-off-by: Jean Privat <jean@pryen.org>
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# Manage options on the command line
+# Management of options on the command line
module opts
# Super class of all option's class
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# Acces of the environement variables of the process
+# Access to the environment variables of the process
module environ
import symbol
# TODO prevoir une structure pour recup tout un environ, le modifier et le passer a process
redef class Symbol
- # Return environement value for this symbol
- # If there is no such environement value, then return ""
+ # Return environment value for this symbol
+ # If there is no such environment value, then return ""
fun environ: String
do
var res = to_s.to_cstring.get_environ
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module handle simple system calls
-# Standard input and output can be handleb trougth streams.
+# Invocation and management of operating system sub-processes.
+# Standard input and output can be handled through streams.
package exec
import stream
-# Simple sub-processus
+# Simple sub-process
class Process
- # The pid of the processus
+ # The pid of the process
fun id: Int do return data.id
- # Is the processus finished?
+ # Is the process finished?
fun is_finished: Bool do return data.is_finished
- # wait the terminaison of the process
+ # Wait the termination of the process
fun wait
do
data.wait
return data.status
end
- # launch a command with some arguments
+ # Launch a command with some arguments
init(command: String, arguments: String...)
do
execute(command, arguments, 0)
end
- # launch a simple command without arguments
+ # Launch a simple command without arguments
init init_(command: String)
do
execute(command, null, 0)
end
- # Internal code to handle execusion
+ # Internal code to handle execution
protected init execute(command: String, arguments: nullable Array[String], pipeflags: Int)
do
var args = new Buffer
private fun basic_exec_execute(p: NativeString, av: NativeString, ac: Int, pf: Int): NativeProcess is extern "exec_Process_Process_basic_exec_execute_4"
end
-# stdout of the processus is readable
+# stdout of the process is readable
class IProcess
super Process
super IStream
end
end
-# stdin of the processus is writable
+# stdin of the process is writable
class OProcess
super Process
super OStream
end
redef class Sys
- # Execute a shell command and return it's error code
+ # Execute a shell command and return its error code
fun system(command: String): Int
do
return command.to_cstring.system
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module handle file input and output
+# File manipulations (create, read, write, etc.)
package file
intrude import stream
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# This file is free software, which comes along with NIT. This software is
+# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. You can modify it is you want, provided this header
+# is kept unaltered, and a notification of the changes is added.
+# You are allowed to redistribute it and sell it, alone or is a part of
+# another product.
+
+# Access to the Nit internal garbage collection mechanism
+module gc
+
import kernel
redef class Sys
+ # Initiate a garbage collection
fun force_garbage_collection is intern
end
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module is about hashable things.
-# It introduces an hash funtion in objects.
+# Hashable things.
+# It introduces an hash function in objects.
package hash
import kernel
redef class Object
# The hash code of the object.
- # Assuming that a = b -> a.hash = b.hash
+ # Assuming that a == b -> a.hash == b.hash
##
- # Without redefinition, it is the `id' of the instance.
+ # Without redefinition, it is based on the `object_id' of the instance.
fun hash: Int do return object_id / 8
end
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
+# Most minimal classes and methods.
# This module is the root of the standard module hierarchy.
package kernel
# The identifier is used internally to provide a hash value.
fun object_id: Int is intern
- # Return true is `self' and `other' have the same dynamic type.
+ # Return true if `self' and `other' have the same dynamic type.
# Unless specific code, you should not use this method.
fun is_same_type(other: Object): Bool is intern
# Have `self' and `other' the same value?
##
# The exact meaning of "same value" is let to the subclasses.
- # Implicitly, the default implementation, is ==
+ # Implicitly, the default implementation, is `is'
fun ==(other: nullable Object): Bool do return self is other
# Have `self' and `other' different values?
##
- # != is equivalent with "not =".
+ # != is equivalent with "not ==".
fun !=(other: nullable Object): Bool do return not (self == other)
# Display self on stdout (debug only).
- # This method MUST not be used by programs, it is here for debugging only and can be removed without any notice
+ # This method MUST not be used by programs, it is here for debugging
+ # only and can be removed without any notice
fun output
do
'<'.output
end
# Display class name on stdout (debug only).
- # This method MUST not be used by programs, it is here for debugging only and can be removed without any notice
+ # This method MUST not be used by programs, it is here for debugging
+ # only and can be removed without any notice
fun output_class_name is intern
# Quit the program with a specific return code
# The previous element.
fun prec: OTHER do return self - 1
- # The `i' th successor element.
+ # The `i'-th successor element.
fun +(i: Int): OTHER is abstract
- # The `i' th previous element.
+ # The `i'-th previous element.
fun -(i: Int): OTHER is abstract
# The distance between self and d.
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module is implicitely imported by every module.
+# Standard classes and methods used by default by Nit programs and libraries.
+# This module is implicitly imported by every module.
package standard
import environ
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module handle abstract input and output streams
+# Input and output streams of characters
package stream
import string
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module is about character strings.
+# Basic manipulations of strings of characters
package string
intrude import collection # FIXME should be collection::array
end
end
- # Create a substring with the string beginning at the 'from' position
+ # Create a substring from `self' beginning at the 'from' position
#
# "abcd".substring(1) # --> "bcd"
# "abcd".substring(-1) # --> "abcd"
return substring(from, length - from)
end
- # is this string a substring of the 'of' string from pos 'pos'
+ # Is `self' a substring of the `str' string from pos `pos'
#
# "bc".is_substring("abcd",1) # --> true
# "bc".is_substring("abcd",2) # --> false
end
end
- # String to upper case
+ # A upper case version of `self'
fun to_upper: String
do
var s = new Buffer.with_capacity(length)
return s.to_s
end
- # String to lower case
+ # A lower case version of `self'
fun to_lower : String
do
var s = new Buffer.with_capacity(length)
end
end
-
+# Immutable strings of characters.
class String
super Comparable
super AbstractString
fun to_f : Float is extern import String::to_cstring
end
-# Strings are arrays of characters.
+# Mutable strings of characters.
class Buffer
super AbstractString
super Comparable
###############################################################################
redef class Object
- # fun class_name: String is extern intern # The name of the class
-
# User readable representation of `self'.
fun to_s: String do return inspect
private fun native_class_name: NativeString is intern
# The class name of the object.
- # FIXME: real type information is not available at runtime. Therefore, for instance, an instance of List[Bool] has just "List" for classname
+ # FIXME: real type information is not available at runtime.
+ # Therefore, for instance, an instance of List[Bool] has just
+ # "List" for class_name
fun class_name: String do return new String.from_cstring(native_class_name)
# Developer readable representation of `self'.
- # Usualy, it uses the form "<CLASSNAME:#OBJECTID bla bla bla>"
+ # Usually, it uses the form "<CLASSNAME:#OBJECTID bla bla bla>"
fun inspect: String
do
return "<{inspect_head}>"
end
redef class Map[K,V]
- # Concatenate couple of 'key value' separate by 'couple_sep' and separate each couple with `sep'.
+ # Concatenate couple of 'key value'.
+ # key and value are separated by 'couple_sep'.
+ # each couple is separated each couple with `sep'.
fun join(sep: String, couple_sep: String): String
do
if is_empty then return ""
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module is about string search and matching.
-# It includes some good features
+# Basic string search, match and replace.
package string_search
import string
-# Patterns are string motifs.
+# Patterns are abstract string motifs (include `String' and `Char').
interface Pattern
# Search `self' into `s' from a certain position.
# Return the position of the first character of the matching section.
end
end
-# BM_Pattern are precompiled string motif for the Boyer-Moore Fast String Searching Algorithm
-# (cf. A Fast String Searching Algorithm, with R.S. Boyer.
-# Communications of the Association for Computing Machinery, 20(10), 1977, pp. 762-772.)
-# see also http://www.cs.utexas.edu/users/moore/best-ideas/string-searching/index.html
+# BM_Pattern are pre-compiled string motif for the Boyer-Moore algorithm.
+# (cf. A Fast String Searching Algorithm, with R.S. Boyer. Communications
+# of the Association for Computing Machinery, 20(10), 1977, pp. 762-772.)
+# http://www.cs.utexas.edu/users/moore/best-ideas/string-searching/index.html
class BM_Pattern
super Pattern
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# This module introduce the Symbol class
+# Symbol classes
+# FIXME: Should be deprecated soon
package symbol
import string
end
end
-# A symbol is a unique unmutable string
+# A symbol is a unique immutable string
class Symbol
var _string: String
redef fun to_s do return _string.to_s
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-# Manage time and dates
+# Management of time and dates
package time
import kernel
redef class Object
+ # Unix time: the number of seconds elapsed since January 1, 1970
protected fun get_time: Int is extern "kernel_Any_Any_get_time_0"
end