Skip to content

Commit

Permalink
Merge pull request jupyter-xeus#480 from SylvainCorlay/format-update
Browse files Browse the repository at this point in the history
Clang format and minor fixes in include styles
  • Loading branch information
SylvainCorlay authored Apr 4, 2023
2 parents 092c31b + 66ccd07 commit 019fabf
Show file tree
Hide file tree
Showing 29 changed files with 608 additions and 456 deletions.
78 changes: 78 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
BasedOnStyle: Mozilla

AccessModifierOffset: '-4'
AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
# Forbid one line lambdas because clang-format makes a weird split when
# single instructions lambdas are too long.
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: AfterComma
BreakStringLiterals: false
ColumnLimit: '110'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Always
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: true
IndentCaseLabels: true
IndentWidth: '4'
IndentWrappedFunctionNames: false
InsertBraces: true
InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
Language: Cpp
MaxEmptyLinesToKeep: '2'
NamespaceIndentation: All
ObjCBlockIndentWidth: '4'
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PackConstructorInitializers: Never
PenaltyBreakAssignment: 100000
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 10
PenaltyBreakOpenParenthesis: 0
PenaltyBreakTemplateDeclaration: 0
PenaltyExcessCharacter: 10
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 10
PointerAlignment: Left
QualifierAlignment: Custom # Experimental
QualifierOrder: [inline, static, constexpr, const, volatile, type]
ReflowComments: true
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: '2'
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++14
TabWidth: '4'
UseTab: Never
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Content for the quick help is available for the standard library, and can be mad

### Jupyter interactive widgets

A C++ backend for the Jupyter interactive widgets is available in the [`xwidgets`](https://github.com/QuantStack/xwidgets/) package.
A C++ backend for the Jupyter interactive widgets is available in the [`xwidgets`](https://github.com/jupyter-xeus/xwidgets/) package.

![Widgets](widgets.gif)

Expand Down
2 changes: 0 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def setup(app):
copyright = '2017, Johan Mabille, Loic Gouarin and Sylvain Corlay'
author = 'Johan Mabille, Loic Gouarin and Sylvain Corlay'

html_logo = 'quantstack-white.svg'

exclude_patterns = []
highlight_language = 'c++'
pygments_style = 'sphinx'
Expand Down
52 changes: 0 additions & 52 deletions docs/source/quantstack-white.svg

This file was deleted.

41 changes: 15 additions & 26 deletions include/xcpp/xdisplay.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/***************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
/****************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XCPP_DISPLAY_HPP
#define XCPP_DISPLAY_HPP

#include "nlohmann/json.hpp"
#include <nlohmann/json.hpp>

#include "xmime.hpp"

Expand All @@ -22,38 +22,27 @@ namespace xcpp
void display(const T& t)
{
using ::xcpp::mime_bundle_repr;
xeus::get_interpreter().display_data(
mime_bundle_repr(t),
nl::json::object(),
nl::json::object()
);
xeus::get_interpreter().display_data(mime_bundle_repr(t), nl::json::object(), nl::json::object());
}

template <class T>
void display(const T& t, xeus::xguid id, bool update=false)
void display(const T& t, xeus::xguid id, bool update = false)
{
nl::json transient;
transient["display_id"] = id;
using ::xcpp::mime_bundle_repr;
if (update)
{
xeus::get_interpreter().update_display_data(
mime_bundle_repr(t),
nl::json::object(),
std::move(transient)
);
xeus::get_interpreter()
.update_display_data(mime_bundle_repr(t), nl::json::object(), std::move(transient));
}
else
{
xeus::get_interpreter().display_data(
mime_bundle_repr(t),
nl::json::object(),
std::move(transient)
);
xeus::get_interpreter().display_data(mime_bundle_repr(t), nl::json::object(), std::move(transient));
}
}

inline void clear_output(bool wait=false)
inline void clear_output(bool wait = false)
{
xeus::get_interpreter().clear_output(wait);
}
Expand Down
20 changes: 10 additions & 10 deletions include/xcpp/xmime.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/***************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
/****************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XCPP_MIME_HPP
#define XCPP_MIME_HPP

#include <complex>
#include <sstream>

#include "nlohmann/json.hpp"
#include <cling/Interpreter/RuntimePrintValue.h>

#include "cling/Interpreter/RuntimePrintValue.h"
#include "nlohmann/json.hpp"

namespace nl = nlohmann;

Expand Down
16 changes: 8 additions & 8 deletions include/xeus-cling/xbuffer.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/***********************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/
/************************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/

#ifndef XCPP_MESSAGING_BUFFER_HPP
#define XCPP_MESSAGING_BUFFER_HPP
Expand Down
39 changes: 22 additions & 17 deletions include/xeus-cling/xeus_cling_config.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/***********************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/
/************************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/

#ifndef XEUS_CLING_CONFIG_HPP
#define XEUS_CLING_CONFIG_HPP
Expand All @@ -21,18 +21,23 @@
#define XEUS_CLING_STRINGIFY(a) XEUS_CLING_STRINGIFY_IMPL(a)
#define XEUS_CLING_STRINGIFY_IMPL(a) #a

#define XEUS_CLING_VERSION XEUS_CLING_STRINGIFY(XEUS_CLING_CONCATENATE(XEUS_CLING_VERSION_MAJOR, \
XEUS_CLING_CONCATENATE(.,XEUS_CLING_CONCATENATE(XEUS_CLING_VERSION_MINOR, \
XEUS_CLING_CONCATENATE(.,XEUS_CLING_VERSION_PATCH)))))
#define XEUS_CLING_VERSION \
XEUS_CLING_STRINGIFY(XEUS_CLING_CONCATENATE( \
XEUS_CLING_VERSION_MAJOR, \
XEUS_CLING_CONCATENATE( \
., \
XEUS_CLING_CONCATENATE(XEUS_CLING_VERSION_MINOR, XEUS_CLING_CONCATENATE(., XEUS_CLING_VERSION_PATCH)) \
) \
))

#ifdef _WIN32
#ifdef XEUS_CLING_EXPORTS
#define XEUS_CLING_API __declspec(dllexport)
#else
#define XEUS_CLING_API __declspec(dllimport)
#endif
#ifdef XEUS_CLING_EXPORTS
#define XEUS_CLING_API __declspec(dllexport)
#else
#define XEUS_CLING_API
#define XEUS_CLING_API __declspec(dllimport)
#endif
#else
#define XEUS_CLING_API
#endif

#endif
20 changes: 10 additions & 10 deletions include/xeus-cling/xholder_cling.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/***********************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/
/************************************************************************************
* Copyright (c) 2016, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
* Copyright (c) 2016, QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
************************************************************************************/

#ifndef XCPP_HOLDER_CLING_HPP
#define XCPP_HOLDER_CLING_HPP

#include <regex>

#include "nlohmann/json.hpp"
#include <nlohmann/json.hpp>

#include "xeus-cling/xpreamble.hpp"
#include "xpreamble.hpp"

namespace nl = nlohmann;

Expand Down
Loading

0 comments on commit 019fabf

Please sign in to comment.