Skip to content

Commit b3dbb1f

Browse files
restyled-commitsiphydf
authored andcommitted
cleanup: Restyled by all restylers.
1 parent 1fddb99 commit b3dbb1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2641
-3387
lines changed

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33

44
org.gradle.parallel=true
55
org.gradle.caching=true
6-

lib/src/cpp/src/Tox4j.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
#include <jni.h>
2-
32
#include <tox/tox.h>
43

5-
64
/*
75
* Do setup here. Caching of needed java method IDs etc should be done in this
86
* function. It is guaranteed to be called when the library is loaded, and
97
* nothing else will be called before this function is called.
108
*/
11-
jint
12-
JNI_OnLoad (JavaVM *, void *)
13-
{
14-
if (!TOX_VERSION_IS_ABI_COMPATIBLE ())
15-
return -1;
9+
jint JNI_OnLoad(JavaVM *, void *) {
10+
if (!TOX_VERSION_IS_ABI_COMPATIBLE()) return -1;
1611
return JNI_VERSION_1_4;
1712
}
1813

1914
#ifdef HAVE_COVERAGE
20-
extern "C" void __gcov_flush ();
15+
extern "C" void __gcov_flush();
2116
#endif
2217

23-
void
24-
JNI_OnUnload (JavaVM *, void *)
25-
{
18+
void JNI_OnUnload(JavaVM *, void *) {
2619
#ifdef HAVE_COVERAGE
27-
__gcov_flush ();
20+
__gcov_flush();
2821
#endif
2922
}

lib/src/cpp/src/ToxAv/ToxAv.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ using namespace av;
44

55
ToxInstances<tox::av_ptr, std::unique_ptr<Events>> av::instances;
66

7-
template<> char const *module_name<ToxAV>() { return "av"; }
8-
template<> char const *exn_prefix<ToxAV>() { return "av"; }
7+
template <>
8+
char const *module_name<ToxAV>() {
9+
return "av";
10+
}
11+
template <>
12+
char const *exn_prefix<ToxAV>() {
13+
return "av";
14+
}
915

10-
void
11-
reference_symbols_av ()
12-
{
13-
int toxav_finalize; // For Java only.
16+
void reference_symbols_av() {
17+
int toxav_finalize; // For Java only.
1418

15-
#define JAVA_METHOD_REF(NAME) unused (JAVA_METHOD_NAME (NAME));
16-
#define CXX_FUNCTION_REF(NAME) unused (NAME);
19+
#define JAVA_METHOD_REF(NAME) unused(JAVA_METHOD_NAME(NAME));
20+
#define CXX_FUNCTION_REF(NAME) unused(NAME);
1721
#include "generated/natives.h"
1822
#undef CXX_FUNCTION_REF
1923
#undef JAVA_METHOD_REF

lib/src/cpp/src/ToxAv/ToxAv.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212

1313
#ifndef SUBSYSTEM
1414
#define SUBSYSTEM TOXAV
15-
#define CLASS ToxAv
16-
#define PREFIX toxav
15+
#define CLASS ToxAv
16+
#define PREFIX toxav
1717
#endif
1818

19-
void reference_symbols_av ();
19+
void reference_symbols_av();
2020

21-
namespace av
22-
{
23-
namespace proto = im::tox::tox4j::av::proto;
21+
namespace av {
22+
namespace proto = im::tox::tox4j::av::proto;
2423

25-
using Events = proto::AvEvents;
24+
using Events = proto::AvEvents;
2625

27-
extern ToxInstances<tox::av_ptr, std::unique_ptr<Events>> instances;
28-
}
26+
extern ToxInstances<tox::av_ptr, std::unique_ptr<Events>> instances;
27+
} // namespace av

lib/src/cpp/src/ToxAv/av.cpp

Lines changed: 52 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,150 +7,122 @@ using namespace av;
77
* Method: toxavIterationInterval
88
* Signature: (I)I
99
*/
10-
TOX_METHOD (jint, IterationInterval,
11-
jint instanceNumber)
12-
{
13-
return instances.with_instance_noerr (env, instanceNumber,
14-
toxav_iteration_interval);
10+
TOX_METHOD(jint, IterationInterval, jint instanceNumber) {
11+
return instances.with_instance_noerr(env, instanceNumber, toxav_iteration_interval);
1512
}
1613

1714
/*
1815
* Class: im_tox_tox4j_impl_ToxAvJni
1916
* Method: toxavIterate
2017
* Signature: (I)[B
2118
*/
22-
TOX_METHOD (jbyteArray, Iterate,
23-
jint instanceNumber)
24-
{
25-
return instances.with_instance (env, instanceNumber,
26-
[=] (ToxAV *av, Events &events) -> jbyteArray
27-
{
28-
InstanceLogEntry log_entry (instanceNumber, toxav_iterate, av);
19+
TOX_METHOD(jbyteArray, Iterate, jint instanceNumber) {
20+
return instances.with_instance(env, instanceNumber, [=](ToxAV *av, Events &events) -> jbyteArray {
21+
InstanceLogEntry log_entry(instanceNumber, toxav_iterate, av);
2922

3023
#if 0
3124
log_entry.print_result (toxav_iterate, av, &events);
3225
#else
33-
log_entry.print_result (toxav_iterate, av);
26+
log_entry.print_result(toxav_iterate, av);
3427
#endif
35-
if (events.ByteSizeLong () == 0)
36-
return nullptr;
28+
if (events.ByteSizeLong() == 0) return nullptr;
3729

38-
std::vector<char> buffer (events.ByteSizeLong ());
39-
events.SerializeToArray (buffer.data (), buffer.size ());
40-
events.Clear ();
30+
std::vector<char> buffer(events.ByteSizeLong());
31+
events.SerializeToArray(buffer.data(), buffer.size());
32+
events.Clear();
4133

42-
return toJavaArray (env, buffer);
43-
}
44-
);
34+
return toJavaArray(env, buffer);
35+
});
4536
}
4637

4738
/*
4839
* Class: im_tox_tox4j_impl_ToxAvJni
4940
* Method: toxavCall
5041
* Signature: (IIII)V
5142
*/
52-
TOX_METHOD (void, Call,
53-
jint instanceNumber, jint friendNumber, jint audioBitRate, jint videoBitRate)
54-
{
55-
return instances.with_instance_ign (env, instanceNumber,
56-
toxav_call, friendNumber, audioBitRate, videoBitRate
57-
);
43+
TOX_METHOD(void, Call, jint instanceNumber, jint friendNumber, jint audioBitRate,
44+
jint videoBitRate) {
45+
return instances.with_instance_ign(env, instanceNumber, toxav_call, friendNumber, audioBitRate,
46+
videoBitRate);
5847
}
5948

6049
/*
6150
* Class: im_tox_tox4j_impl_ToxAvJni
6251
* Method: toxavAnswer
6352
* Signature: (IIII)V
6453
*/
65-
TOX_METHOD (void, Answer,
66-
jint instanceNumber, jint friendNumber, jint audioBitRate, jint videoBitRate)
67-
{
68-
return instances.with_instance_ign (env, instanceNumber,
69-
toxav_answer, friendNumber, audioBitRate, videoBitRate
70-
);
54+
TOX_METHOD(void, Answer, jint instanceNumber, jint friendNumber, jint audioBitRate,
55+
jint videoBitRate) {
56+
return instances.with_instance_ign(env, instanceNumber, toxav_answer, friendNumber, audioBitRate,
57+
videoBitRate);
7158
}
7259

7360
/*
7461
* Class: im_tox_tox4j_impl_ToxAvJni
7562
* Method: toxavCallControl
7663
* Signature: (III)V
7764
*/
78-
TOX_METHOD (void, CallControl,
79-
jint instanceNumber, jint friendNumber, jint control)
80-
{
81-
return instances.with_instance_ign (env, instanceNumber,
82-
toxav_call_control, friendNumber, Enum::valueOf<TOXAV_CALL_CONTROL> (env, control)
83-
);
65+
TOX_METHOD(void, CallControl, jint instanceNumber, jint friendNumber, jint control) {
66+
return instances.with_instance_ign(env, instanceNumber, toxav_call_control, friendNumber,
67+
Enum::valueOf<TOXAV_CALL_CONTROL>(env, control));
8468
}
8569

8670
/*
8771
* Class: im_tox_tox4j_impl_ToxAvJni
8872
* Method: toxavAudioSetBitRate
8973
* Signature: (III)V
9074
*/
91-
TOX_METHOD (void, AudioSetBitRate,
92-
jint instanceNumber, jint friendNumber, jint audioBitRate)
93-
{
94-
return instances.with_instance_ign (env, instanceNumber,
95-
toxav_audio_set_bit_rate, friendNumber, audioBitRate
96-
);
75+
TOX_METHOD(void, AudioSetBitRate, jint instanceNumber, jint friendNumber, jint audioBitRate) {
76+
return instances.with_instance_ign(env, instanceNumber, toxav_audio_set_bit_rate, friendNumber,
77+
audioBitRate);
9778
}
9879

9980
/*
10081
* Class: im_tox_tox4j_impl_ToxAvJni
10182
* Method: toxavVideoSetBitRate
10283
* Signature: (III)V
10384
*/
104-
TOX_METHOD (void, VideoSetBitRate,
105-
jint instanceNumber, jint friendNumber, jint videoBitRate)
106-
{
107-
return instances.with_instance_ign (env, instanceNumber,
108-
toxav_video_set_bit_rate, friendNumber, videoBitRate
109-
);
85+
TOX_METHOD(void, VideoSetBitRate, jint instanceNumber, jint friendNumber, jint videoBitRate) {
86+
return instances.with_instance_ign(env, instanceNumber, toxav_video_set_bit_rate, friendNumber,
87+
videoBitRate);
11088
}
11189

11290
/*
11391
* Class: im_tox_tox4j_impl_ToxAvJni
11492
* Method: toxavAudioSendFrame
11593
* Signature: (II[SIII)V
11694
*/
117-
TOX_METHOD (void, AudioSendFrame,
118-
jint instanceNumber, jint friendNumber, jshortArray pcm, jint sampleCount, jint channels, jint samplingRate)
119-
{
120-
tox4j_assert (sampleCount >= 0);
121-
tox4j_assert (channels >= 0);
122-
tox4j_assert (channels <= 255);
123-
tox4j_assert (samplingRate >= 0);
124-
125-
auto pcmData = fromJavaArray (env, pcm);
126-
if (pcmData.size () != size_t (sampleCount * channels))
127-
return throw_tox_exception<ToxAV> (env, TOXAV_ERR_SEND_FRAME_INVALID);
128-
129-
return instances.with_instance_ign (env, instanceNumber,
130-
toxav_audio_send_frame, friendNumber, pcmData, sampleCount, channels, samplingRate
131-
);
95+
TOX_METHOD(void, AudioSendFrame, jint instanceNumber, jint friendNumber, jshortArray pcm,
96+
jint sampleCount, jint channels, jint samplingRate) {
97+
tox4j_assert(sampleCount >= 0);
98+
tox4j_assert(channels >= 0);
99+
tox4j_assert(channels <= 255);
100+
tox4j_assert(samplingRate >= 0);
101+
102+
auto pcmData = fromJavaArray(env, pcm);
103+
if (pcmData.size() != size_t(sampleCount * channels))
104+
return throw_tox_exception<ToxAV>(env, TOXAV_ERR_SEND_FRAME_INVALID);
105+
106+
return instances.with_instance_ign(env, instanceNumber, toxav_audio_send_frame, friendNumber,
107+
pcmData, sampleCount, channels, samplingRate);
132108
}
133109

134110
/*
135111
* Class: im_tox_tox4j_impl_ToxAvJni
136112
* Method: toxavVideoSendFrame
137113
* Signature: (IIII[B[B[B[B)V
138114
*/
139-
TOX_METHOD (void, VideoSendFrame,
140-
jint instanceNumber, jint friendNumber, jint width, jint height, jbyteArray y, jbyteArray u, jbyteArray v)
141-
{
115+
TOX_METHOD(void, VideoSendFrame, jint instanceNumber, jint friendNumber, jint width, jint height,
116+
jbyteArray y, jbyteArray u, jbyteArray v) {
142117
size_t ySize = width * height;
143118
size_t uvSize = (width / 2) * (height / 2);
144119

145-
auto yData = fromJavaArray (env, y);
146-
auto uData = fromJavaArray (env, u);
147-
auto vData = fromJavaArray (env, v);
148-
if (yData.size () != ySize ||
149-
uData.size () != uvSize ||
150-
vData.size () != uvSize)
151-
return throw_tox_exception<ToxAV> (env, TOXAV_ERR_SEND_FRAME_INVALID);
152-
153-
return instances.with_instance_ign (env, instanceNumber,
154-
toxav_video_send_frame, friendNumber, width, height, yData, uData, vData
155-
);
120+
auto yData = fromJavaArray(env, y);
121+
auto uData = fromJavaArray(env, u);
122+
auto vData = fromJavaArray(env, v);
123+
if (yData.size() != ySize || uData.size() != uvSize || vData.size() != uvSize)
124+
return throw_tox_exception<ToxAV>(env, TOXAV_ERR_SEND_FRAME_INVALID);
125+
126+
return instances.with_instance_ign(env, instanceNumber, toxav_video_send_frame, friendNumber,
127+
width, height, yData, uData, vData);
156128
}

lib/src/cpp/src/ToxAv/debug.cpp

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
#include "ToxAv.h"
2-
31
#include <algorithm>
42
#include <vector>
53

6-
template<>
7-
void
8-
print_arg<ToxAV *> (protolog::Value &value, ToxAV *const &tox)
9-
{
4+
#include "ToxAv.h"
5+
6+
template <>
7+
void print_arg<ToxAV *>(protolog::Value &value, ToxAV *const &tox) {
108
static std::vector<ToxAV *> ids;
11-
auto found = std::find (ids.begin (), ids.end (), tox);
12-
if (found == ids.end ())
13-
{
14-
ids.push_back (tox);
15-
found = ids.end () - 1;
16-
}
17-
value.set_v_string ("@" + std::to_string (found - ids.begin () + 1));
9+
auto found = std::find(ids.begin(), ids.end(), tox);
10+
if (found == ids.end()) {
11+
ids.push_back(tox);
12+
found = ids.end() - 1;
13+
}
14+
value.set_v_string("@" + std::to_string(found - ids.begin() + 1));
1815
}
1916

20-
template<>
21-
void
22-
print_arg<int16_t const *> (protolog::Value &value, int16_t const *const &data)
23-
{
17+
template <>
18+
void print_arg<int16_t const *>(protolog::Value &value, int16_t const *const &data) {
2419
if (data == nullptr)
25-
value.set_v_string ("<null>");
20+
value.set_v_string("<null>");
2621
else
27-
value.set_v_string ("<audio samples>");
22+
value.set_v_string("<audio samples>");
2823
}
2924

30-
template<>
31-
void
32-
print_arg<av::Events *> (protolog::Value &value, av::Events *const &events)
33-
{
25+
template <>
26+
void print_arg<av::Events *>(protolog::Value &value, av::Events *const &events) {
3427
if (events == nullptr)
35-
value.set_v_string ("<null>");
28+
value.set_v_string("<null>");
3629
else
37-
value.set_v_string ("<av::Events[" + std::to_string (events->ByteSizeLong ()) + "]>");
30+
value.set_v_string("<av::Events[" + std::to_string(events->ByteSizeLong()) + "]>");
3831
}

0 commit comments

Comments
 (0)