|
982 | 982 | (if-not (= 'js x)
|
983 | 983 | (with-meta 'js
|
984 | 984 | {:prefix (conj (->> (string/split (name x) #"\.")
|
985 |
| - (map symbol) vec) |
986 |
| - 'prototype)}) |
| 985 | + (map symbol) vec))}) |
987 | 986 | x))
|
988 | 987 |
|
989 | 988 | (defn ->type-set
|
|
1030 | 1029 | boolean Boolean
|
1031 | 1030 | symbol Symbol})
|
1032 | 1031 |
|
1033 |
| -(defn extern-var-info |
| 1032 | +(defn resolve-extern |
| 1033 | + "Given a foreign js property list, return a resolved js property list and the |
| 1034 | + extern var info" |
1034 | 1035 | ([pre externs]
|
1035 | 1036 | (let [pre (if-some [me (find
|
1036 | 1037 | (get-in externs '[Window prototype])
|
|
1039 | 1040 | (into [tag 'prototype] (next pre))
|
1040 | 1041 | pre)
|
1041 | 1042 | pre)]
|
1042 |
| - (extern-var-info pre externs externs nil))) |
1043 |
| - ([pre externs top info] |
| 1043 | + (resolve-extern pre externs externs {:resolved [] :info nil}))) |
| 1044 | + ([pre externs top ret] |
1044 | 1045 | (cond
|
1045 |
| - (empty? pre) info |
| 1046 | + (empty? pre) ret |
1046 | 1047 | :else
|
1047 | 1048 | (let [x (first pre)
|
1048 | 1049 | me (find externs x)]
|
|
1052 | 1053 | (let [[x' externs'] me
|
1053 | 1054 | info' (meta x')]
|
1054 | 1055 | (if (and (= 'Function (:tag info')) (:ctor info'))
|
1055 |
| - (or (extern-var-info (into '[prototype] (next pre)) externs' top nil) |
1056 |
| - (extern-var-info (next pre) externs' top info') |
1057 |
| - ;; check base type if it exists |
| 1056 | + (or |
| 1057 | + ;; first look for a property on the prototype |
| 1058 | + (resolve-extern (into '[prototype] (next pre)) externs' top |
| 1059 | + (-> ret |
| 1060 | + (update :resolved conj 'prototype) |
| 1061 | + (assoc :info nil))) |
| 1062 | + ;; then check for "static" property |
| 1063 | + (resolve-extern (next pre) externs' top |
| 1064 | + (-> ret |
| 1065 | + (update :resolved conj x) |
| 1066 | + (assoc :info info'))) |
| 1067 | + ;; finally check the super class if there is one |
1058 | 1068 | (when-let [super (:super info')]
|
1059 |
| - (extern-var-info (into [super] (next pre)) externs top nil))) |
1060 |
| - (recur (next pre) externs' top info')))))))) |
| 1069 | + (resolve-extern (into [super] (next pre)) externs top |
| 1070 | + (-> ret |
| 1071 | + (update :resolved conj x) |
| 1072 | + (assoc :info nil))))) |
| 1073 | + (recur (next pre) externs' top |
| 1074 | + (-> ret |
| 1075 | + (update :resolved conj x) |
| 1076 | + (assoc :info info')))))))))) |
1061 | 1077 |
|
1062 | 1078 | (defn has-extern?*
|
1063 | 1079 | [pre externs]
|
1064 |
| - (boolean (extern-var-info pre externs))) |
| 1080 | + (boolean (resolve-extern pre externs))) |
1065 | 1081 |
|
1066 | 1082 | (defn has-extern?
|
1067 | 1083 | ([pre]
|
|
0 commit comments