01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.core.client;
17:
18: final class Impl {
19:
20: private static int sNextHashId = 0;
21:
22: protected static int getNextHashId() {
23: return ++sNextHashId;
24: }
25:
26: /*
27: * We need a separate overload for JavaScriptObject, so that the hosted mode
28: * JSNI invocation system will know to unwrap the Java object back to its
29: * underlying JavaScript object.
30: */
31: static native int getHashCode(JavaScriptObject o) /*-{
32: return (o == null) ? 0 :
33: (o.$H ? o.$H : (o.$H = @com.google.gwt.core.client.Impl::getNextHashId()()));
34: }-*/;
35:
36: static native int getHashCode(Object o) /*-{
37: return (o == null) ? 0 :
38: (o.$H ? o.$H : (o.$H = @com.google.gwt.core.client.Impl::getNextHashId()()));
39: }-*/;
40:
41: static native String getHostPageBaseURL() /*-{
42: var s = $doc.location.href;
43:
44: // Pull off any hash.
45: var i = s.indexOf('#');
46: if (i != -1)
47: s = s.substring(0, i);
48:
49: // Pull off any query string.
50: i = s.indexOf('?');
51: if (i != -1)
52: s = s.substring(0, i);
53:
54: // Rip off everything after the last slash.
55: i = s.lastIndexOf('/');
56: if (i != -1)
57: s = s.substring(0, i);
58:
59: // Ensure a final slash if non-empty.
60: return s.length > 0 ? s + "/" : "";
61: }-*/;
62:
63: static native String getModuleBaseURL() /*-{
64: return $moduleBase;
65: }-*/;
66:
67: static native String getModuleName() /*-{
68: return $moduleName;
69: }-*/;
70: }
|