Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ generate:

.PHONY: aot
aot: gocmd $(STDLIB_TARGETS)
@echo "(map compile '[clojure.core clojure.core.async clojure.walk clojure.template clojure.uuid glojure.go.types glojure.go.io])" | \
@echo "(map compile '[clojure.core clojure.core.async clojure.string clojure.template clojure.test clojure.uuid clojure.walk glojure.go.types glojure.go.io])" | \
GLOJURE_USE_AOT=false GLOJURE_STDLIB_PATH=./pkg/stdlib $(GO_CMD) run -tags glj_no_aot_stdlib ./cmd/glj

.PHONY: build
Expand Down
6 changes: 3 additions & 3 deletions pkg/stdlib/clojure/core.glj
Original file line number Diff line number Diff line change
Expand Up @@ -6770,7 +6770,7 @@ fails, attempts to require sym's namespace and retries."
(load "core_print")
(do)
(load "core_deftype")
(load "protocols")
(load "core/protocols")
(do)

(defn stream-reduce!
Expand Down Expand Up @@ -7921,7 +7921,7 @@ fails, attempts to require sym's namespace and retries."
:added "1.11"}
^go/int64 [^go/string s]
(if (string? s)
(clojure.core/let [result__3648__auto__ (strconv.ParseInt s 10 64)] (if (result__3648__auto__ 1) nil (result__3648__auto__ 0)))
(clojure.core/let [result__3646__auto__ (strconv.ParseInt s 10 64)] (if (result__3646__auto__ 1) nil (result__3646__auto__ 0)))
(throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError (parsing-err s)))))

(defn parse-double
Expand All @@ -7932,7 +7932,7 @@ fails, attempts to require sym's namespace and retries."
:added "1.11"}
^go/float64 [^go/string s]
(if (string? s)
(clojure.core/let [result__3649__auto__ (strconv.ParseFloat s 64)] (if (result__3649__auto__ 1) nil (result__3649__auto__ 0)))
(clojure.core/let [result__3647__auto__ (strconv.ParseFloat s 64)] (if (result__3647__auto__ 1) nil (result__3647__auto__ 0)))
(throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError (parsing-err s)))))

(defn parse-uuid
Expand Down
4 changes: 2 additions & 2 deletions pkg/stdlib/clojure/core/loader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions pkg/stdlib/clojure/core/protocols/loader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 25 additions & 23 deletions pkg/stdlib/clojure/string.glj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
(ns clojure.string
(:refer-clojure :exclude (replace reverse))
(:import (regexp *Regexp)
(github.com:glojurelang:glojure:pkg:lang ToString NewIllegalArgumentError Char CharAt)))
#_(github.com:glojurelang:glojure:pkg:lang ToString NewIllegalArgumentError Char CharAt)
(github.com:glojurelang:glojure:pkg:lang)))

(set! *warn-on-reflection* true)

(defn- check-string
[maybe-s]
(if (nil? maybe-s)
(throw (NewIllegalArgumentError "cannot call clojure.string function on nil"))
(throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError "cannot call clojure.string function on nil"))
maybe-s))

(defn ^go/string reverse
Expand Down Expand Up @@ -45,7 +46,7 @@
(do (.appendReplacement m buffer (re-quote-replacement (f (re-groups m))))
(recur (.find m)))
(do (.appendTail m buffer)
(ToString buffer)))))
(github.com:glojurelang:glojure:pkg:lang.ToString buffer)))))
s)))

(defn ^go/string replace
Expand Down Expand Up @@ -76,12 +77,12 @@
[^go/string s match replacement]
(let [s (check-string s)]
(cond
(instance? Char match) (strings.ReplaceAll s match replacement)
(instance? github.com:glojurelang:glojure:pkg:lang.Char match) (strings.ReplaceAll s match replacement)
(instance? go/string match) (strings.ReplaceAll s match replacement)
(instance? *Regexp match) (if (instance? go/string replacement)
(.replaceAllString ^*Regexp match s replacement)
(replace-by s match replacement))
:else (throw (NewIllegalArgumentError (str "Invalid match arg: " match))))))
:else (throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError (str "Invalid match arg: " match))))))

(defn- replace-first-by
[^go/string s ^*Regexp re f]
Expand All @@ -95,16 +96,16 @@
s)))

(defn- replace-first-char
[^go/string s ^Char match replace]
(let [s (ToString s)
[^go/string s ^github.com:glojurelang:glojure:pkg:lang.Char match replace]
(let [s (github.com:glojurelang:glojure:pkg:lang.ToString s)
i (strings.Index s (int match))]
(if (= -1 i)
s
(str (subs s 0 i) replace (subs s (inc i))))))

(defn- replace-first-str
[^go/string s ^go/string match ^go/string replace]
(let [^go/string s (ToString s)
(let [^go/string s (github.com:glojurelang:glojure:pkg:lang.ToString s)
i (strings.Index s match)]
(if (= -1 i)
s
Expand Down Expand Up @@ -139,11 +140,11 @@
[^go/string s match replacement]
(let [s (check-string s)]
(cond
(instance? Char match)
(instance? github.com:glojurelang:glojure:pkg:lang.Char match)
(replace-first-char s match replacement)
(instance? go/string match)
(replace-first-str s (ToString ^go/string match)
(ToString ^go/string replacement))
(replace-first-str s (github.com:glojurelang:glojure:pkg:lang.ToString ^go/string match)
(github.com:glojurelang:glojure:pkg:lang.ToString ^go/string replacement))
(instance? *Regexp match)
(if (instance? go/string replacement)
(let [done (atom false)]
Expand All @@ -155,7 +156,7 @@
(reset! done true)
(.ReplaceAllString ^*Regexp match m replacement))))))
(replace-first-by s match replacement))
:else (throw (NewIllegalArgumentError (str "Invalid match arg: " match))))))
:else (throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError (str "Invalid match arg: " match))))))


(defn ^go/string join
Expand Down Expand Up @@ -195,16 +196,17 @@
the maximum number of parts. Not lazy. Returns vector of the parts.
Trailing empty strings are not returned - pass limit of -1 to return all."
{:added "1.2"}
([^go/string s ^*Regexp re]
([^go/string s ^regexp.*Regexp re]
(github.com:glojurelang:glojure:pkg:lang.CreateOwningLazilyPersistentVector (.split re s -1)))
([ ^go/string s ^*Regexp re limit]
([ ^go/string s ^regexp.*Regexp re limit]
(github.com:glojurelang:glojure:pkg:lang.CreateOwningLazilyPersistentVector (.split re s limit))))

(defn split-lines
"Splits s on \\n or \\r\\n. Trailing empty lines are not returned."
{:added "1.2"}
[^go/string s]
(split s #"\r?\n"))
#_(split s #"\r?\n")
(split s (re-pattern "\\r?\\n")))

(defn ^go/string trim
"Removes whitespace from both ends of string."
Expand Down Expand Up @@ -239,7 +241,7 @@
(loop [index (int 0)]
(if (= (count s) index)
true
(if (unicode.IsSpace (CharAt s index))
(if (unicode.IsSpace (github.com:glojurelang:glojure:pkg:lang.CharAt s index))
(recur (inc index))
false)))
true))
Expand All @@ -263,8 +265,8 @@
([^go/string s value]
(let [s (check-string s)
result ^long
(if (instance? Char value)
(strings.IndexRune s ^go/rune (go/rune ^Char value))
(if (instance? github.com:glojurelang:glojure:pkg:lang.Char value)
(strings.IndexRune s ^go/rune (go/rune ^github.com:glojurelang:glojure:pkg:lang.Char value))
(strings.Index s ^go/string value))]
(if (= result -1)
nil
Expand All @@ -273,8 +275,8 @@
(let [from-index (min (count s) (max 0 (unchecked-int from-index)))
s (subs (check-string s) from-index)
result ^long
(if (instance? Char value)
(strings.IndexRune s ^go/rune (go/rune ^Char value))
(if (instance? github.com:glojurelang:glojure:pkg:lang.Char value)
(strings.IndexRune s ^go/rune (go/rune ^github.com:glojurelang:glojure:pkg:lang.Char value))
(strings.Index s ^go/string value))]
(if (= result -1)
nil
Expand Down Expand Up @@ -302,16 +304,16 @@
"True if s starts with substr."
{:added "1.8"}
[^go/string s ^go/string substr]
(strings.HasPrefix (ToString s) substr))
(strings.HasPrefix (github.com:glojurelang:glojure:pkg:lang.ToString s) substr))

(defn ends-with?
"True if s ends with substr."
{:added "1.8"}
[^go/string s ^go/string substr]
(strings.HasSuffix (ToString s) substr))
(strings.HasSuffix (github.com:glojurelang:glojure:pkg:lang.ToString s) substr))

(defn includes?
"True if s includes substr."
{:added "1.8"}
[^go/string s ^go/string substr]
(strings.Contains (ToString s) substr))
(strings.Contains (github.com:glojurelang:glojure:pkg:lang.ToString s) substr))
Loading