aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/ffi.jvm.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/documentation/lux/ffi.jvm.lux')
-rw-r--r--stdlib/source/documentation/lux/ffi.jvm.lux242
1 files changed, 123 insertions, 119 deletions
diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux
index ca1841a0b..d05e9e72d 100644
--- a/stdlib/source/documentation/lux/ffi.jvm.lux
+++ b/stdlib/source/documentation/lux/ffi.jvm.lux
@@ -95,176 +95,180 @@
($.definition /.class
"Allows defining JVM classes in Lux code."
- [(class "final" (TestClass A) [Runnable]
- ... Fields
- ("private" foo boolean)
- ("private" bar A)
- ("private" baz java/lang/Object)
- ... Methods
- ("public" [] (new [value A]) []
- (exec
- (:= ::foo true)
- (:= ::bar value)
- (:= ::baz "")
- []))
- ("public" (virtual) java/lang/Object
- "")
- ("public" "static" (static) java/lang/Object
- "")
- (Runnable [] (run) void
- [])
- )
-
- "The tuple corresponds to parent interfaces."
- "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed."
- "Fields and methods defined in the class can be used with special syntax."
- "For example:"
- "::resolved, for accessing the 'resolved' field."
- "(:= ::resolved true) for modifying it."
- "(::new! []) for calling the class's constructor."
- "(::resolve! container [value]) for calling the 'resolve' method."])
+ ($.example (class "final" (TestClass A) [Runnable]
+ ... Fields
+ ("private" foo boolean)
+ ("private" bar A)
+ ("private" baz java/lang/Object)
+ ... Methods
+ ("public" [] (new [value A]) []
+ (exec
+ (:= ::foo true)
+ (:= ::bar value)
+ (:= ::baz "")
+ []))
+ ("public" (virtual) java/lang/Object
+ "")
+ ("public" "static" (static) java/lang/Object
+ "")
+ (Runnable [] (run) void
+ [])
+ ))
+ ($.comment "The tuple corresponds to parent interfaces.")
+ ($.comment "An optional super-class can be specified before the tuple. If not specified, java.lang.Object will be assumed.")
+ ($.comment "Fields and methods defined in the class can be used with special syntax.")
+ ($.comment "For example:")
+ ($.comment "::resolved, for accessing the 'resolved' field.")
+ ($.comment "(:= ::resolved true) for modifying it.")
+ ($.comment "(::new! []) for calling the class's constructor.")
+ ($.comment "(::resolve! container [value]) for calling the 'resolve' method."))
($.definition /.interface
"Allows defining JVM interfaces."
- [(interface TestInterface
- ([] foo [boolean String] void "throws" [Exception]))])
+ ($.example (interface TestInterface
+ ([] foo [boolean String] void "throws" [Exception]))))
($.definition /.object
"Allows defining anonymous classes."
- ["The 1st tuple corresponds to class-level type-variables."
- "The 2nd tuple corresponds to parent interfaces."
- "The 3rd tuple corresponds to arguments to the super class constructor."
- "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed."
- (object [] [Runnable]
- []
- (Runnable [] (run self) void
- (exec
- (do_something some_value)
- [])))])
+ ($.comment "The 1st tuple corresponds to class-level type-variables.")
+ ($.comment "The 2nd tuple corresponds to parent interfaces.")
+ ($.comment "The 3rd tuple corresponds to arguments to the super class constructor.")
+ ($.comment "An optional super-class can be specified before the 1st tuple. If not specified, java.lang.Object will be assumed.")
+ ($.example (object [] [Runnable]
+ []
+ (Runnable [] (run self) void
+ (exec
+ (do_something some_value)
+ [])))))
($.definition /.null
"The null pointer."
- [(null)])
+ ($.example (null)))
($.definition /.null?
"Test for the null pointer."
- [(= true
- (null? (null)))]
- [(= false
- (null? "YOLO"))])
+ ($.example (= true
+ (null? (null))))
+ ($.example (= false
+ (null? "YOLO"))))
($.definition /.???
"Takes a (potentially null) ObjectType reference and creates a (Maybe ObjectType) for it."
- [(= (??? (is java/lang/String (null)))
- {.#None})]
- [(= (??? "YOLO")
- {.#Some "YOLO"})])
+ ($.example (= (??? (is java/lang/String (null)))
+ {.#None}))
+ ($.example (= (??? "YOLO")
+ {.#Some "YOLO"})))
($.definition /.!!!
(format "Takes a (Maybe ObjectType) and returns a ObjectType."
\n "A .#None would get translated into a (null).")
- [(= (null)
- (!!! (??? (is java/lang/Thread (null)))))]
- [(= "foo"
- (!!! (??? "foo")))])
+ ($.example (= (null)
+ (!!! (??? (is java/lang/Thread (null))))))
+ ($.example (= "foo"
+ (!!! (??? "foo")))))
($.definition /.as
(format "Checks whether an object is an instance of a particular class."
\n "Caveat emptor: Cannot check for polymorphism, so avoid using parameterized classes.")
- [(when (as String "YOLO")
- {.#Some value_as_string}
- {.#None})])
+ ($.example (when (as String "YOLO")
+ {.#Some value_as_string}
+ {.#None})))
($.definition /.synchronized
"Evaluates body, while holding a lock on a given object."
- [(synchronized object_to_be_locked
- (exec
- (do something)
- (dosomething else)
- (finish the computation)))])
+ ($.example (synchronized object_to_be_locked
+ (exec
+ (do something)
+ (dosomething else)
+ (finish the computation)))))
($.definition /.to
"Call a variety of methods on an object. Then, return the object."
- [(to object
- (ClassName::method1 arg0 arg1 arg2)
- (ClassName::method2 arg3 arg4 arg5))])
+ ($.example (to object
+ (ClassName::method1 arg0 arg1 arg2)
+ (ClassName::method2 arg3 arg4 arg5))))
($.definition /.import
"Allows importing JVM classes, and using them as types."
- ["Their methods, fields and enum options can also be imported."
- (import java/lang/Object
- "[1]::[0]"
- (new [])
- (equals [java/lang/Object] boolean)
- (wait [int] "io" "try" void))]
- ["Special options can also be given for the return values."
- "'?' means that the values will be returned inside a Maybe type. That way, null becomes .#None."
- "'try' means that the computation might throw an exception, and the return value will be wrapped by the Try type."
- "'io' means the computation has side effects, and will be wrapped by the IO type."
- "These options must show up in the following order ['io' 'try' '?'] (although, each option can be used independently)."
- (import java/lang/String
- "[1]::[0]"
- (new [[byte]])
- ("static" valueOf [char] java/lang/String)
- ("static" valueOf "as" int_valueOf [int] java/lang/String))
-
- (import (java/util/List e)
- "[1]::[0]"
- (size [] int)
- (get [int] e))
-
- (import (java/util/ArrayList a)
- "[1]::[0]"
- ([T] toArray [[T]] [T]))]
- ["The class-type that is generated is of the fully-qualified name."
- "This avoids a clash between the java.util.List type, and Lux's own List type."
- "All enum options to be imported must be specified."
- (import java/lang/Character$UnicodeScript
- "[1]::[0]"
- ("enum" ARABIC CYRILLIC LATIN))]
- ["It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars."
- "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes)."
- (import (lux/concurrency/async/JvmAsync A)
- "[1]::[0]"
- (resolve [A] boolean)
- (poll [] A)
- (wasResolved [] boolean)
- (waitOn [lux/Function] void)
- ("static" [A] make [A] (lux/concurrency/async/JvmAsync A)))]
- ["Also, the names of the imported members will look like Class::member"
- (java/lang/Object::new [])
- (java/lang/Object::equals [other_object] my_object)
- (java/util/List::size [] my_list)
- java/lang/Character$UnicodeScript::LATIN])
+
+ ($.comment "Their methods, fields and enum options can also be imported.")
+ ($.example (import java/lang/Object
+ "[1]::[0]"
+ (new [])
+ (equals [java/lang/Object] boolean)
+ (wait [int] "io" "try" void)))
+
+ ($.comment "Special options can also be given for the return values.")
+ ($.comment "'?' means that the values will be returned inside a Maybe type. That way, null becomes .#None.")
+ ($.comment "'try' means that the computation might throw an exception, and the return value will be wrapped by the Try type.")
+ ($.comment "'io' means the computation has side effects, and will be wrapped by the IO type.")
+ ($.comment "These options must show up in the following order ['io' 'try' '?'] (although, each option can be used independently).")
+ ($.example (import java/lang/String
+ "[1]::[0]"
+ (new [[byte]])
+ ("static" valueOf [char] java/lang/String)
+ ("static" valueOf "as" int_valueOf [int] java/lang/String)))
+
+ ($.example (import (java/util/List e)
+ "[1]::[0]"
+ (size [] int)
+ (get [int] e)))
+
+ ($.example (import (java/util/ArrayList a)
+ "[1]::[0]"
+ ([T] toArray [[T]] [T])))
+
+ ($.comment "The class-type that is generated is of the fully-qualified name.")
+ ($.comment "This avoids a clash between the java.util.List type, and Lux's own List type.")
+ ($.comment "All enum options to be imported must be specified.")
+ ($.example (import java/lang/Character$UnicodeScript
+ "[1]::[0]"
+ ("enum" ARABIC CYRILLIC LATIN)))
+
+ ($.comment "It should also be noted, the only types that may show up in method arguments or return values may be Java classes, arrays, primitives, void or type-vars.")
+ ($.comment "Lux types, such as Maybe cannot be named (otherwise, they'd be confused for Java classes).")
+ ($.example (import (lux/concurrency/async/JvmAsync A)
+ "[1]::[0]"
+ (resolve [A] boolean)
+ (poll [] A)
+ (wasResolved [] boolean)
+ (waitOn [lux/Function] void)
+ ("static" [A] make [A] (lux/concurrency/async/JvmAsync A))))
+
+ ($.comment "Also, the names of the imported members will look like Class::member")
+ ($.example (java/lang/Object::new []))
+ ($.example (java/lang/Object::equals [other_object] my_object))
+ ($.example (java/util/List::size [] my_list))
+ ($.example java/lang/Character$UnicodeScript::LATIN))
($.definition /.array
"Create an array of the given type, with the given size."
- [(array java/lang/Object 10)])
+ ($.example (array java/lang/Object 10)))
($.definition /.length
"Gives the length of an array."
- [(length my_array)])
+ ($.example (length my_array)))
($.definition /.read!
"Loads an element from an array."
- [(read! 10 my_array)])
+ ($.example (read! 10 my_array)))
($.definition /.write!
"Stores an element into an array."
- [(write! 10 my_object my_array)])
+ ($.example (write! 10 my_object my_array)))
($.definition /.class_for
"Loads the class as a java.lang.Class object."
- [(class_for java/lang/String)])
+ ($.example (class_for java/lang/String)))
($.definition /.type
""
- [(is Type
- (type java/lang/String))])
+ ($.example (is Type
+ (type java/lang/String))))
($.definition /.is
""
- [(is java/lang/Object
- (is java/lang/String
- ???))])
+ ($.example (is java/lang/Object
+ (is java/lang/String
+ ???))))
)))