Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
Set up wpiformat (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored and PeterJohnson committed Aug 26, 2017
1 parent dd85b1e commit 06636a0
Show file tree
Hide file tree
Showing 75 changed files with 865 additions and 654 deletions.
82 changes: 53 additions & 29 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,65 +1,89 @@
---
Language: Cpp
# BasedOnStyle: Google
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: true
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: true
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: true
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
IndentWidth: 2
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Attach
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...

35 changes: 35 additions & 0 deletions .styleguide
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cppHeaderExtensions {
h
hpp
inc
}

cppSrcExtensions {
cpp
}

otherExtensions {
java
}

genFileExclude {
gmock/
src/arm-linux-jni/
src/main/native/cpp/jni/CameraServerJNI\.cpp$
}

licenseUpdateExclude {
src/main/native/cpp/default_init_allocator\.h$
}

includeGuardRoots {
src/main/native/cpp/
src/main/native/include/
}

includeOtherLibs {
^llvm/
^opencv2/
^support/
^tcpsockets/
}
6 changes: 6 additions & 0 deletions .styleguide-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) {year} FIRST. All Rights Reserved.{padding}*/
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
35 changes: 26 additions & 9 deletions examples/enum_usb/enum_usb.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#include "cscore.h"
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

#include <llvm/SmallString.h>
#include <llvm/raw_ostream.h>

#include "llvm/SmallString.h"
#include "llvm/raw_ostream.h"
#include "cscore.h"

int main() {
CS_Status status = 0;
Expand All @@ -17,7 +24,8 @@ int main() {
llvm::outs() << " " << prop.GetName();
switch (prop.GetKind()) {
case cs::VideoProperty::kBoolean:
llvm::outs() << " (bool): " << "value=" << prop.Get()
llvm::outs() << " (bool): "
<< "value=" << prop.Get()
<< " default=" << prop.GetDefault();
break;
case cs::VideoProperty::kInteger:
Expand All @@ -30,7 +38,8 @@ int main() {
llvm::outs() << " (string): " << prop.GetString(buf);
break;
case cs::VideoProperty::kEnum: {
llvm::outs() << " (enum): " << "value=" << prop.Get();
llvm::outs() << " (enum): "
<< "value=" << prop.Get();
auto choices = prop.GetChoices();
for (size_t i = 0; i < choices.size(); ++i) {
if (choices[i].empty()) continue;
Expand All @@ -48,10 +57,18 @@ int main() {
for (const auto& mode : camera.EnumerateVideoModes()) {
llvm::outs() << " PixelFormat:";
switch (mode.pixelFormat) {
case cs::VideoMode::kMJPEG: llvm::outs() << "MJPEG"; break;
case cs::VideoMode::kYUYV: llvm::outs() << "YUYV"; break;
case cs::VideoMode::kRGB565: llvm::outs() << "RGB565"; break;
default: llvm::outs() << "Unknown"; break;
case cs::VideoMode::kMJPEG:
llvm::outs() << "MJPEG";
break;
case cs::VideoMode::kYUYV:
llvm::outs() << "YUYV";
break;
case cs::VideoMode::kRGB565:
llvm::outs() << "RGB565";
break;
default:
llvm::outs() << "Unknown";
break;
}
llvm::outs() << " Width:" << mode.width;
llvm::outs() << " Height:" << mode.height;
Expand Down
17 changes: 13 additions & 4 deletions examples/httpcvstream/httpcvstream.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#include "cscore.h"
#include "opencv2/core/core.hpp"
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

#include <cstdio>
#include <iostream>
#include <stdio.h>

#include <opencv2/core/core.hpp>

#include "cscore.h"

int main() {
cs::HttpCamera camera{"httpcam", "http://localhost:8081/?action=stream"};
Expand All @@ -21,7 +29,8 @@ int main() {
std::cout << "error: " << cvsink.GetError() << std::endl;
continue;
}
std::cout << "got frame at time " << time << " size " << test.size() << std::endl;
std::cout << "got frame at time " << time << " size " << test.size()
<< std::endl;
cv::flip(test, flip, 0);
cvsource.PutFrame(flip);
}
Expand Down
27 changes: 18 additions & 9 deletions examples/settings/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

#include <chrono>
#include <thread>

#include "cscore.h"
#include <llvm/SmallString.h>
#include <llvm/raw_ostream.h>

#include "llvm/SmallString.h"
#include "llvm/raw_ostream.h"
#include "cscore.h"

int main(int argc, char** argv) {
if (argc < 2) {
Expand All @@ -25,9 +32,9 @@ int main(int argc, char** argv) {
int arg = 2;
llvm::StringRef propName;
for (; arg < argc && llvm::StringRef{argv[arg]} != "--"; ++arg) {
if (propName.empty())
if (propName.empty()) {
propName = argv[arg];
else {
} else {
llvm::StringRef propVal{argv[arg]};
int intVal;
if (propVal.getAsInteger(10, intVal))
Expand All @@ -46,9 +53,9 @@ int main(int argc, char** argv) {
// Set rest
propName = llvm::StringRef{};
for (; arg < argc; ++arg) {
if (propName.empty())
if (propName.empty()) {
propName = argv[arg];
else {
} else {
llvm::StringRef propVal{argv[arg]};
int intVal;
if (propVal.getAsInteger(10, intVal))
Expand All @@ -66,7 +73,8 @@ int main(int argc, char** argv) {
llvm::outs() << " " << prop.GetName();
switch (prop.GetKind()) {
case cs::VideoProperty::kBoolean:
llvm::outs() << " (bool): " << "value=" << prop.Get()
llvm::outs() << " (bool): "
<< "value=" << prop.Get()
<< " default=" << prop.GetDefault();
break;
case cs::VideoProperty::kInteger:
Expand All @@ -79,7 +87,8 @@ int main(int argc, char** argv) {
llvm::outs() << " (string): " << prop.GetString(buf);
break;
case cs::VideoProperty::kEnum: {
llvm::outs() << " (enum): " << "value=" << prop.Get();
llvm::outs() << " (enum): "
<< "value=" << prop.Get();
auto choices = prop.GetChoices();
for (size_t i = 0; i < choices.size(); ++i) {
if (choices[i].empty()) continue;
Expand Down
17 changes: 13 additions & 4 deletions examples/usbcvstream/usbcvstream.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#include "cscore.h"
#include "opencv2/core/core.hpp"
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

#include <cstdio>
#include <iostream>
#include <stdio.h>

#include <opencv2/core/core.hpp>

#include "cscore.h"

int main() {
cs::UsbCamera camera{"usbcam", 0};
Expand All @@ -23,7 +31,8 @@ int main() {
std::cout << "error: " << cvsink.GetError() << std::endl;
continue;
}
std::cout << "got frame at time " << time << " size " << test.size() << std::endl;
std::cout << "got frame at time " << time << " size " << test.size()
<< std::endl;
cv::flip(test, flip, 0);
cvsource.PutFrame(flip);
}
Expand Down
15 changes: 11 additions & 4 deletions examples/usbstream/usbstream.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include "cscore.h"
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

#include <cstdio>

#include <stdio.h>
#include <llvm/raw_ostream.h>

#include "llvm/raw_ostream.h"
#include "cscore.h"

int main() {
llvm::outs() << "hostname: " << cs::GetHostname() << '\n';
Expand All @@ -14,5 +21,5 @@ int main() {
cs::MjpegServer mjpegServer{"httpserver", 8081};
mjpegServer.SetSource(camera);

getchar();
std::getchar();
}
7 changes: 7 additions & 0 deletions src/dev/java/edu/wpi/cscore/DevMain.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package edu.wpi.cscore;

import edu.wpi.cscore.CameraServerJNI;
Expand Down
Loading

0 comments on commit 06636a0

Please sign in to comment.