FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jruby/core/src/main/java/org/jruby/util/Inspector.java at master · jruby/jruby · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
jruby
/
jruby
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
946
Star
3.9k
Code
Issues
840
Pull requests
109
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
jruby
/
core
/
src
/
main
/
java
/
org
/
jruby
/
util
/
Inspector.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (51 loc) · 2.79 KB
Breadcrumbs
jruby
/
core
/
src
/
main
/
java
/
org
/
jruby
/
util
/
Inspector.java
Copy path
File metadata and controls
61 lines (51 loc) · 2.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package
org
.
jruby
.
util
;
import
org
.
jcodings
.
specific
.
USASCIIEncoding
;
import
org
.
jruby
.
Ruby
;
import
org
.
jruby
.
RubyModule
;
import
org
.
jruby
.
RubyString
;
import
org
.
jruby
.
runtime
.
ThreadContext
;
import
static
org
.
jruby
.
util
.
io
.
EncodingUtils
.
encStrBufCat
;
public
class
Inspector
{
public
static
final
ByteList
EMPTY_ARRAY_BL
=
new
ByteList
(
new
byte
[] {
'['
,
']'
},
USASCIIEncoding
.
INSTANCE
,
false
);
public
static
final
ByteList
RECURSIVE_ARRAY_BL
=
new
ByteList
(
new
byte
[] {
'['
,
'.'
,
'.'
,
'.'
,
']'
},
USASCIIEncoding
.
INSTANCE
,
false
);
public
static
final
ByteList
EMPTY_HASH_BL
=
new
ByteList
(
new
byte
[] {
'{'
,
'}'
},
USASCIIEncoding
.
INSTANCE
,
false
);
public
static
final
ByteList
RECURSIVE_HASH_BL
=
new
ByteList
(
new
byte
[] {
'{'
,
'.'
,
'.'
,
'.'
,
'}'
},
USASCIIEncoding
.
INSTANCE
,
false
);
private
static
final
byte
[]
COLON_ZERO_X
= {
':'
,
'0'
,
'x'
};
public
static
final
byte
[]
COLON
= {
':'
};
public
static
final
byte
[]
SPACE
= {
' '
};
public
static
final
byte
[]
SLASH
= {
'/'
};
public
static
final
byte
[]
COLON_SPACE
= {
':'
,
' '
};
public
static
final
byte
[]
GT
= {
'>'
};
public
static
final
byte
[]
COMMA
= {
','
};
public
static
final
byte
[]
COMMA_SPACE
= {
','
,
' '
};
public
static
final
byte
[]
BEG_BRACKET
= {
'['
};
public
static
final
byte
[]
END_BRACKET
= {
']'
};
public
static
final
byte
[]
END_BRACKET_GT
= {
']'
,
'>'
};
public
static
final
byte
[]
SPACE_HASHROCKET_SPACE
= {
' '
,
'='
,
'>'
,
' '
};
public
static
final
byte
[]
SPACE_DOT_DOT_DOT_GT
=
" ...>"
.
getBytes
();
public
static
final
byte
[]
EQUALS
=
"="
.
getBytes
();
public
static
final
byte
[]
SIZE_EQUALS
=
"size="
.
getBytes
();
// e.g.: #<Object:0x5a1c0542
public
static
RubyString
inspectPrefix
(
final
ThreadContext
context
,
final
RubyModule
type
,
final
int
hash
) {
final
Ruby
runtime
=
context
.
runtime
;
RubyString
buf
=
inspectPrefixTypeOnly
(
context
,
type
);
encStrBufCat
(
runtime
,
buf
,
COLON_ZERO_X
);
// :0x
encStrBufCat
(
runtime
,
buf
,
ConvertBytes
.
longToHexBytes
(
hash
));
return
buf
;
}
// e.g. #<Java::JavaUtil::Vector:
public
static
RubyString
inspectPrefix
(
final
ThreadContext
context
,
final
RubyModule
type
) {
final
Ruby
runtime
=
context
.
runtime
;
RubyString
buf
=
inspectPrefixTypeOnly
(
context
,
type
);
encStrBufCat
(
runtime
,
buf
,
COLON
);
// :
return
buf
;
}
public
static
RubyString
inspectPrefixTypeOnly
(
final
ThreadContext
context
,
final
RubyModule
type
) {
RubyString
name
=
RubyStringBuilder
.
types
(
context
,
type
);
// minimal: "#<Object:0x5a1c0542>"
RubyString
buf
=
RubyString
.
newStringLight
(
context
.
runtime
,
2
+
name
.
length
() +
3
+
8
+
1
,
USASCIIEncoding
.
INSTANCE
);
RubyString
rubyString
=
buf
.
cat
(
'#'
).
cat
(
'<'
);
rubyString
.
catWithCodeRange
(
name
);
return
buf
;
}
}
Back
|
FazBrowse Home
|
New Git URL