Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
35eca08d
Commit
35eca08d
authored
Aug 28, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
java/*: add `noexcept`
parent
7137ca37
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
50 additions
and
44 deletions
+50
-44
Class.hxx
src/java/Class.hxx
+5
-5
Exception.hxx
src/java/Exception.hxx
+2
-2
File.cxx
src/java/File.cxx
+3
-3
File.hxx
src/java/File.hxx
+4
-4
Global.cxx
src/java/Global.cxx
+2
-2
Global.hxx
src/java/Global.hxx
+4
-4
Object.hxx
src/java/Object.hxx
+3
-2
Ref.hxx
src/java/Ref.hxx
+21
-17
String.cxx
src/java/String.cxx
+1
-1
String.hxx
src/java/String.hxx
+5
-4
No files found.
src/java/Class.hxx
View file @
35eca08d
/*
/*
* Copyright
(C)
2010-2018 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2010-2018 Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -41,10 +41,10 @@ namespace Java {
...
@@ -41,10 +41,10 @@ namespace Java {
*/
*/
class
Class
:
public
LocalRef
<
jclass
>
{
class
Class
:
public
LocalRef
<
jclass
>
{
public
:
public
:
Class
(
JNIEnv
*
env
,
jclass
cls
)
Class
(
JNIEnv
*
env
,
jclass
cls
)
noexcept
:
LocalRef
<
jclass
>
(
env
,
cls
)
{}
:
LocalRef
<
jclass
>
(
env
,
cls
)
{}
Class
(
JNIEnv
*
env
,
const
char
*
name
)
Class
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
:
LocalRef
<
jclass
>
(
env
,
env
->
FindClass
(
name
))
{}
:
LocalRef
<
jclass
>
(
env
,
env
->
FindClass
(
name
))
{}
};
};
...
@@ -53,7 +53,7 @@ namespace Java {
...
@@ -53,7 +53,7 @@ namespace Java {
*/
*/
class
TrivialClass
:
public
TrivialRef
<
jclass
>
{
class
TrivialClass
:
public
TrivialRef
<
jclass
>
{
public
:
public
:
void
Find
(
JNIEnv
*
env
,
const
char
*
name
)
{
void
Find
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
{
assert
(
env
!=
nullptr
);
assert
(
env
!=
nullptr
);
assert
(
name
!=
nullptr
);
assert
(
name
!=
nullptr
);
...
@@ -64,7 +64,7 @@ namespace Java {
...
@@ -64,7 +64,7 @@ namespace Java {
env
->
DeleteLocalRef
(
cls
);
env
->
DeleteLocalRef
(
cls
);
}
}
bool
FindOptional
(
JNIEnv
*
env
,
const
char
*
name
)
{
bool
FindOptional
(
JNIEnv
*
env
,
const
char
*
name
)
noexcept
{
assert
(
env
!=
nullptr
);
assert
(
env
!=
nullptr
);
assert
(
name
!=
nullptr
);
assert
(
name
!=
nullptr
);
...
...
src/java/Exception.hxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2012
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -38,7 +38,7 @@ namespace Java {
...
@@ -38,7 +38,7 @@ namespace Java {
*
*
* @return true if an exception was found (and discarded)
* @return true if an exception was found (and discarded)
*/
*/
static
inline
bool
DiscardException
(
JNIEnv
*
env
)
{
static
inline
bool
DiscardException
(
JNIEnv
*
env
)
noexcept
{
bool
result
=
env
->
ExceptionCheck
();
bool
result
=
env
->
ExceptionCheck
();
if
(
result
)
if
(
result
)
env
->
ExceptionClear
();
env
->
ExceptionClear
();
...
...
src/java/File.cxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2014
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
jmethodID
Java
::
File
::
getAbsolutePath_method
;
jmethodID
Java
::
File
::
getAbsolutePath_method
;
void
void
Java
::
File
::
Initialise
(
JNIEnv
*
env
)
Java
::
File
::
Initialise
(
JNIEnv
*
env
)
noexcept
{
{
Class
cls
(
env
,
"java/io/File"
);
Class
cls
(
env
,
"java/io/File"
);
...
@@ -47,7 +47,7 @@ Java::File::Initialise(JNIEnv *env)
...
@@ -47,7 +47,7 @@ Java::File::Initialise(JNIEnv *env)
}
}
AllocatedPath
AllocatedPath
Java
::
File
::
ToAbsolutePath
(
JNIEnv
*
env
,
jobject
_file
)
Java
::
File
::
ToAbsolutePath
(
JNIEnv
*
env
,
jobject
_file
)
noexcept
{
{
assert
(
env
!=
nullptr
);
assert
(
env
!=
nullptr
);
assert
(
_file
!=
nullptr
);
assert
(
_file
!=
nullptr
);
...
...
src/java/File.hxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2014
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -45,10 +45,10 @@ namespace Java {
...
@@ -45,10 +45,10 @@ namespace Java {
public
:
public
:
gcc_nonnull_all
gcc_nonnull_all
static
void
Initialise
(
JNIEnv
*
env
);
static
void
Initialise
(
JNIEnv
*
env
)
noexcept
;
gcc_nonnull_all
gcc_nonnull_all
static
jstring
getAbsolutePath
(
JNIEnv
*
env
,
jobject
file
)
{
static
jstring
getAbsolutePath
(
JNIEnv
*
env
,
jobject
file
)
noexcept
{
return
(
jstring
)
env
->
CallObjectMethod
(
file
,
return
(
jstring
)
env
->
CallObjectMethod
(
file
,
getAbsolutePath_method
);
getAbsolutePath_method
);
}
}
...
@@ -59,7 +59,7 @@ namespace Java {
...
@@ -59,7 +59,7 @@ namespace Java {
*/
*/
gcc_pure
gcc_nonnull_all
gcc_pure
gcc_nonnull_all
static
AllocatedPath
ToAbsolutePath
(
JNIEnv
*
env
,
static
AllocatedPath
ToAbsolutePath
(
JNIEnv
*
env
,
jobject
file
);
jobject
file
)
noexcept
;
};
};
}
}
...
...
src/java/Global.cxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2011
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
namespace
Java
{
namespace
Java
{
JavaVM
*
jvm
;
JavaVM
*
jvm
;
void
Init
(
JNIEnv
*
env
)
void
Init
(
JNIEnv
*
env
)
noexcept
{
{
env
->
GetJavaVM
(
&
jvm
);
env
->
GetJavaVM
(
&
jvm
);
}
}
...
...
src/java/Global.hxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2011
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -37,17 +37,17 @@
...
@@ -37,17 +37,17 @@
namespace
Java
{
namespace
Java
{
extern
JavaVM
*
jvm
;
extern
JavaVM
*
jvm
;
void
Init
(
JNIEnv
*
env
);
void
Init
(
JNIEnv
*
env
)
noexcept
;
static
inline
void
static
inline
void
DetachCurrentThread
()
DetachCurrentThread
()
noexcept
{
{
if
(
jvm
!=
nullptr
)
if
(
jvm
!=
nullptr
)
jvm
->
DetachCurrentThread
();
jvm
->
DetachCurrentThread
();
}
}
static
inline
gcc_pure
static
inline
gcc_pure
JNIEnv
*
GetEnv
()
JNIEnv
*
GetEnv
()
noexcept
{
{
JNIEnv
*
env
;
JNIEnv
*
env
;
jvm
->
AttachCurrentThread
(
&
env
,
nullptr
);
jvm
->
AttachCurrentThread
(
&
env
,
nullptr
);
...
...
src/java/Object.hxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2011
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -48,7 +48,8 @@ namespace Java {
...
@@ -48,7 +48,8 @@ namespace Java {
*/
*/
Object
()
=
default
;
Object
()
=
default
;
Object
(
JNIEnv
*
env
,
jobject
obj
)
:
GlobalRef
<
jobject
>
(
env
,
obj
)
{}
Object
(
JNIEnv
*
env
,
jobject
obj
)
noexcept
:
GlobalRef
<
jobject
>
(
env
,
obj
)
{}
};
};
}
}
...
...
src/java/Ref.hxx
View file @
35eca08d
/*
/*
* Copyright
(C) 2010-2011
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2010-2018
Max Kellermann <max.kellermann@gmail.com>
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -49,23 +49,25 @@ namespace Java {
...
@@ -49,23 +49,25 @@ namespace Java {
/**
/**
* The local reference is obtained by the caller.
* The local reference is obtained by the caller.
*/
*/
LocalRef
(
JNIEnv
*
_env
,
T
_value
)
:
env
(
_env
),
value
(
_value
)
{
LocalRef
(
JNIEnv
*
_env
,
T
_value
)
noexcept
:
env
(
_env
),
value
(
_value
)
{
assert
(
env
!=
nullptr
);
assert
(
env
!=
nullptr
);
assert
(
value
!=
nullptr
);
assert
(
value
!=
nullptr
);
}
}
~
LocalRef
()
{
~
LocalRef
()
noexcept
{
env
->
DeleteLocalRef
(
value
);
env
->
DeleteLocalRef
(
value
);
}
}
LocalRef
(
const
LocalRef
&
other
)
=
delete
;
LocalRef
(
const
LocalRef
&
other
)
=
delete
;
LocalRef
&
operator
=
(
const
LocalRef
&
other
)
=
delete
;
LocalRef
&
operator
=
(
const
LocalRef
&
other
)
=
delete
;
T
Get
()
const
{
T
Get
()
const
noexcept
{
return
value
;
return
value
;
}
}
operator
T
()
const
{
operator
T
()
const
noexcept
{
return
value
;
return
value
;
}
}
};
};
...
@@ -84,14 +86,16 @@ namespace Java {
...
@@ -84,14 +86,16 @@ namespace Java {
*/
*/
GlobalRef
()
=
default
;
GlobalRef
()
=
default
;
GlobalRef
(
JNIEnv
*
env
,
T
_value
)
:
value
(
_value
)
{
GlobalRef
(
JNIEnv
*
env
,
T
_value
)
noexcept
:
value
(
_value
)
{
assert
(
env
!=
nullptr
);
assert
(
env
!=
nullptr
);
assert
(
value
!=
nullptr
);
assert
(
value
!=
nullptr
);
value
=
(
T
)
env
->
NewGlobalRef
(
value
);
value
=
(
T
)
env
->
NewGlobalRef
(
value
);
}
}
~
GlobalRef
()
{
~
GlobalRef
()
noexcept
{
GetEnv
()
->
DeleteGlobalRef
(
value
);
GetEnv
()
->
DeleteGlobalRef
(
value
);
}
}
...
@@ -102,17 +106,17 @@ namespace Java {
...
@@ -102,17 +106,17 @@ namespace Java {
* Sets the object, ignoring the previous value. This is only
* Sets the object, ignoring the previous value. This is only
* allowed once after the default constructor was used.
* allowed once after the default constructor was used.
*/
*/
void
Set
(
JNIEnv
*
env
,
T
_value
)
{
void
Set
(
JNIEnv
*
env
,
T
_value
)
noexcept
{
assert
(
_value
!=
nullptr
);
assert
(
_value
!=
nullptr
);
value
=
(
T
)
env
->
NewGlobalRef
(
_value
);
value
=
(
T
)
env
->
NewGlobalRef
(
_value
);
}
}
T
Get
()
const
{
T
Get
()
const
noexcept
{
return
value
;
return
value
;
}
}
operator
T
()
const
{
operator
T
()
const
noexcept
{
return
value
;
return
value
;
}
}
};
};
...
@@ -129,12 +133,12 @@ namespace Java {
...
@@ -129,12 +133,12 @@ namespace Java {
T
value
;
T
value
;
public
:
public
:
constexpr
TrivialRef
()
{}
;
TrivialRef
()
=
default
;
TrivialRef
(
const
TrivialRef
&
other
)
=
delete
;
TrivialRef
(
const
TrivialRef
&
other
)
=
delete
;
TrivialRef
&
operator
=
(
const
TrivialRef
&
other
)
=
delete
;
TrivialRef
&
operator
=
(
const
TrivialRef
&
other
)
=
delete
;
bool
IsDefined
()
const
{
bool
IsDefined
()
const
noexcept
{
return
value
!=
nullptr
;
return
value
!=
nullptr
;
}
}
...
@@ -142,7 +146,7 @@ namespace Java {
...
@@ -142,7 +146,7 @@ namespace Java {
* Obtain a global reference on the specified object and store it.
* Obtain a global reference on the specified object and store it.
* This object must not be set already.
* This object must not be set already.
*/
*/
void
Set
(
JNIEnv
*
env
,
T
_value
)
{
void
Set
(
JNIEnv
*
env
,
T
_value
)
noexcept
{
assert
(
value
==
nullptr
);
assert
(
value
==
nullptr
);
assert
(
_value
!=
nullptr
);
assert
(
_value
!=
nullptr
);
...
@@ -152,7 +156,7 @@ namespace Java {
...
@@ -152,7 +156,7 @@ namespace Java {
/**
/**
* Release the global reference and clear this object.
* Release the global reference and clear this object.
*/
*/
void
Clear
(
JNIEnv
*
env
)
{
void
Clear
(
JNIEnv
*
env
)
noexcept
{
assert
(
value
!=
nullptr
);
assert
(
value
!=
nullptr
);
env
->
DeleteGlobalRef
(
value
);
env
->
DeleteGlobalRef
(
value
);
...
@@ -163,16 +167,16 @@ namespace Java {
...
@@ -163,16 +167,16 @@ namespace Java {
* Release the global reference and clear this object. It is
* Release the global reference and clear this object. It is
* allowed to call this method without ever calling Set().
* allowed to call this method without ever calling Set().
*/
*/
void
ClearOptional
(
JNIEnv
*
env
)
{
void
ClearOptional
(
JNIEnv
*
env
)
noexcept
{
if
(
value
!=
nullptr
)
if
(
value
!=
nullptr
)
Clear
(
env
);
Clear
(
env
);
}
}
T
Get
()
const
{
T
Get
()
const
noexcept
{
return
value
;
return
value
;
}
}
operator
T
()
const
{
operator
T
()
const
noexcept
{
return
value
;
return
value
;
}
}
};
};
...
...
src/java/String.cxx
View file @
35eca08d
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
char
*
char
*
Java
::
String
::
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
Java
::
String
::
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
char
*
buffer
,
size_t
max_size
)
char
*
buffer
,
size_t
max_size
)
noexcept
{
{
const
char
*
p
=
env
->
GetStringUTFChars
(
value
,
nullptr
);
const
char
*
p
=
env
->
GetStringUTFChars
(
value
,
nullptr
);
if
(
p
==
nullptr
)
if
(
p
==
nullptr
)
...
...
src/java/String.hxx
View file @
35eca08d
...
@@ -42,10 +42,10 @@ namespace Java {
...
@@ -42,10 +42,10 @@ namespace Java {
*/
*/
class
String
:
public
LocalRef
<
jstring
>
{
class
String
:
public
LocalRef
<
jstring
>
{
public
:
public
:
String
(
JNIEnv
*
env
,
jstring
value
)
String
(
JNIEnv
*
env
,
jstring
value
)
noexcept
:
LocalRef
<
jstring
>
(
env
,
value
)
{}
:
LocalRef
<
jstring
>
(
env
,
value
)
{}
String
(
JNIEnv
*
_env
,
const
char
*
_value
)
String
(
JNIEnv
*
_env
,
const
char
*
_value
)
noexcept
:
LocalRef
<
jstring
>
(
_env
,
_env
->
NewStringUTF
(
_value
))
{}
:
LocalRef
<
jstring
>
(
_env
,
_env
->
NewStringUTF
(
_value
))
{}
/**
/**
...
@@ -56,7 +56,7 @@ namespace Java {
...
@@ -56,7 +56,7 @@ namespace Java {
* nullptr on error
* nullptr on error
*/
*/
static
char
*
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
static
char
*
CopyTo
(
JNIEnv
*
env
,
jstring
value
,
char
*
buffer
,
size_t
max_size
);
char
*
buffer
,
size_t
max_size
)
noexcept
;
/**
/**
* Copy the value to the specified buffer. Truncates
* Copy the value to the specified buffer. Truncates
...
@@ -65,7 +65,8 @@ namespace Java {
...
@@ -65,7 +65,8 @@ namespace Java {
* @return a pointer to the terminating null byte,
* @return a pointer to the terminating null byte,
* nullptr on error
* nullptr on error
*/
*/
char
*
CopyTo
(
JNIEnv
*
env
,
char
*
buffer
,
size_t
max_size
)
{
char
*
CopyTo
(
JNIEnv
*
env
,
char
*
buffer
,
size_t
max_size
)
noexcept
{
return
CopyTo
(
env
,
Get
(),
buffer
,
max_size
);
return
CopyTo
(
env
,
Get
(),
buffer
,
max_size
);
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment