Skip to content

Fully generated clients #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
Language: Cpp
# BasedOnStyle: Mozilla
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 4
DerivePointerAlignment: false
FixNamespaceComments : true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 100000
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.1)
project(aws-iot-device-sdk-cpp-v2 CXX)

if (UNIX AND NOT APPLE)
include(GNUInstallDirs)
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake")

if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

set(IS_SUBDIRECTORY_INCLUDE true)
find_package(aws-crt-cpp REQUIRED)

add_subdirectory(jobs)
add_subdirectory(shadow)
add_subdirectory(samples/jobs/describe_job_execution)
add_subdirectory(samples/shadow/shadow_sync)

112 changes: 112 additions & 0 deletions jobs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
cmake_minimum_required(VERSION 3.1)
project(IotJobs-cpp CXX)

set(RUNTIME_DIRECTORY bin)

if (UNIX AND NOT APPLE)
include(GNUInstallDirs)
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")

if (${CMAKE_INSTALL_LIBDIR} STREQUAL "lib64")
set(FIND_LIBRARY_USE_LIB64_PATHS true)
endif()
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake")

if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

file(GLOB AWS_IOTJOBS_HEADERS
"include/aws/iotjobs/*.h"
)

file(GLOB AWS_IOTJOBS_SRC
"source/*.cpp"
)

file(GLOB AWS_IOTJOBS_CPP_SRC
${AWS_IOTJOBS_SRC}
)

if (WIN32)
if (MSVC)
source_group("Header Files\\aws\\iotjobs\\" FILES ${AWS_IOTJOBS_HEADERS})

source_group("Source Files" FILES ${AWS_IOTJOBS_SRC})
endif ()
endif()

add_library(IotJobs-cpp ${AWS_IOTJOBS_CPP_SRC})

set_target_properties(IotJobs-cpp PROPERTIES LINKER_LANGUAGE CXX)

set(CMAKE_C_FLAGS_DEBUGOPT "")

#set warnings
if (MSVC)
target_compile_options(IotJobs-cpp PRIVATE /W4 /WX)
else ()
target_compile_options(IotJobs-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotJobs-cpp PRIVATE "-DDEBUG_BUILD")
endif ()

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotJobs-cpp PUBLIC "-DAWS_IOTJOBS_USE_IMPORT_EXPORT")
target_compile_definitions(IotJobs-cpp PRIVATE "-DAWS_IOTJOBS_EXPORTS")

install(TARGETS IotJobs-cpp
EXPORT IotJobs-cpp-targets
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Development
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_SKIP
COMPONENT Runtime
RUNTIME
DESTINATION ${RUNTIME_DIRECTORY}
COMPONENT Runtime)

install(TARGETS IotJobs-cpp
EXPORT IotJobs-cpp-targets
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_ONLY
COMPONENT Development)
else()
install(TARGETS IotJobs-cpp
EXPORT IotJobs-cpp-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Development)
endif()

target_include_directories(IotJobs-cpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

if (NOT IS_SUBDIRECTORY_INCLUDE)
find_package(aws-crt-cpp REQUIRED)
endif()

target_link_libraries(IotJobs-cpp AWS::aws-crt-cpp)

install(FILES ${AWS_IOTJOBS_HEADERS} DESTINATION "include/aws/iotjobs/" COMPONENT Development)


install(EXPORT "IotJobs-cpp-targets"
DESTINATION "lib/IotJobs-cpp/cmake/"
NAMESPACE AWS::)

configure_file("cmake/IotJobs-cpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/IotJobs-cpp-config.cmake"
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/IotJobs-cpp-config.cmake"
DESTINATION "lib/IotJobs-cpp/cmake/"
COMPONENT Development)
5 changes: 5 additions & 0 deletions jobs/cmake/IotJobs-cpp-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)

find_dependency(aws-crt-cpp)

include(${CMAKE_CURRENT_LIST_DIR}/IotJobs-cpp-targets.cmake)
48 changes: 48 additions & 0 deletions jobs/include/aws/iotjobs/DescribeJobExecutionRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once
/* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.

* This file is generated
*/

#include <aws/iotjobs/Exports.h>

#include <aws/crt/JsonObject.h>
#include <aws/crt/StlAllocator.h>

namespace Aws
{
namespace Iotjobs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird namespace capitalization

In the model, it's written namespace aws.iotjobs because Java doesn't capitalize namepaces. Neither does python, so that worked well for me. since c++ doesn't really have a style, maybe just stick with all-lowercase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're going to come back to this once we figure out the smithy model namespacing stuff.

{

class AWS_IOTJOBS_API DescribeJobExecutionRequest final
{
public:
DescribeJobExecutionRequest() = default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super trivial: I heard it helps compile times if you mark things default in the cpp file instead. Otherwise anyone including the header generates the code for the default implementations.

DescribeJobExecutionRequest:: DescribeJobExecutionRequest() = default;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer


DescribeJobExecutionRequest(const Crt::JsonView &doc);
DescribeJobExecutionRequest &operator=(const Crt::JsonView &doc);

void SerializeToObject(Crt::JsonObject &doc) const;

Aws::Crt::Optional<bool> IncludeJobDocument;
Aws::Crt::Optional<Aws::Crt::String> JobId;
Aws::Crt::Optional<Aws::Crt::String> ClientToken;
Aws::Crt::Optional<int64_t> ExecutionNumber;
Aws::Crt::Optional<Aws::Crt::String> ThingName;

private:
static void LoadFromObject(DescribeJobExecutionRequest &obj, const Crt::JsonView &doc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial style questions about static void LoadFromObject:

  1. Why have this function at all, you could just put the implementation in the constructor?
  2. Why is this static, but SerializeToObject isn't static?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer

};
} // namespace Iotjobs
} // namespace Aws
48 changes: 48 additions & 0 deletions jobs/include/aws/iotjobs/DescribeJobExecutionResponse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once
/* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.

* This file is generated
*/
#include <aws/crt/DateTime.h>
#include <aws/iotjobs/JobExecutionData.h>

#include <aws/iotjobs/Exports.h>

#include <aws/crt/JsonObject.h>
#include <aws/crt/StlAllocator.h>

namespace Aws
{
namespace Iotjobs
{

class AWS_IOTJOBS_API DescribeJobExecutionResponse final
{
public:
DescribeJobExecutionResponse() = default;

DescribeJobExecutionResponse(const Crt::JsonView &doc);
DescribeJobExecutionResponse &operator=(const Crt::JsonView &doc);

void SerializeToObject(Crt::JsonObject &doc) const;

Aws::Crt::Optional<Aws::Iotjobs::JobExecutionData> Execution;
Aws::Crt::Optional<Aws::Crt::String> ClientToken;
Aws::Crt::Optional<Aws::Crt::DateTime> Timestamp;

private:
static void LoadFromObject(DescribeJobExecutionResponse &obj, const Crt::JsonView &doc);
};
} // namespace Iotjobs
} // namespace Aws
45 changes: 45 additions & 0 deletions jobs/include/aws/iotjobs/DescribeJobExecutionSubscriptionRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once
/* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.

* This file is generated
*/

#include <aws/iotjobs/Exports.h>

#include <aws/crt/JsonObject.h>
#include <aws/crt/StlAllocator.h>

namespace Aws
{
namespace Iotjobs
{

class AWS_IOTJOBS_API DescribeJobExecutionSubscriptionRequest final
{
public:
DescribeJobExecutionSubscriptionRequest() = default;

DescribeJobExecutionSubscriptionRequest(const Crt::JsonView &doc);
DescribeJobExecutionSubscriptionRequest &operator=(const Crt::JsonView &doc);

void SerializeToObject(Crt::JsonObject &doc) const;

Aws::Crt::Optional<Aws::Crt::String> ThingName;
Aws::Crt::Optional<Aws::Crt::String> JobId;

private:
static void LoadFromObject(DescribeJobExecutionSubscriptionRequest &obj, const Crt::JsonView &doc);
};
} // namespace Iotjobs
} // namespace Aws
31 changes: 31 additions & 0 deletions jobs/include/aws/iotjobs/Exports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once
/* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.

* This file is generated
*/

#if defined(AWS_IOTJOBS_USE_WINDOWS_DLL_SEMANTICS) || defined(WIN32)
# ifdef AWS_IOTJOBS_USE_IMPORT_EXPORT
# ifdef AWS_IOTJOBS_EXPORTS
# define AWS_IOTJOBS_API __declspec(dllexport)
# else
# define AWS_IOTJOBS_API __declspec(dllimport)
# endif /* AWS_IOTJOBS_EXPORTS */
# else
# define AWS_IOTJOBS_API
# endif /* AWS_IOTJOBS_USE_IMPORT_EXPORT */

#else /* defined (AWS_IOTJOBS_USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32) */
# define AWS_IOTJOBS_API
#endif /* defined (AWS_IOTJOBS__USE_WINDOWS_DLL_SEMANTICS) || defined (WIN32) */
Loading