-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ListBuilder/Parser and StructBuilder/Parser (#11231)
* Add ListBuilder/Parser and StructBuilder/Parser --Fix ListBuilder naming, which should be ArrayBuilder --Add ListBuilder/Parser and StructBuilder/Praser, the enablement for them would be follow-up PR * Fix java codegen missing in master * address comments
- Loading branch information
1 parent
38070da
commit 5e7a97e
Showing
35 changed files
with
569 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
|
||
#include "ArrayBuilder.h" | ||
|
||
#include <inttypes.h> | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
CHIP_ERROR ArrayBuilder::Init(TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse) | ||
{ | ||
mpWriter = apWriter; | ||
mError = mpWriter->StartContainer(TLV::ContextTag(aContextTagToUse), chip::TLV::kTLVType_Array, mOuterContainerType); | ||
|
||
return mError; | ||
} | ||
|
||
CHIP_ERROR ArrayBuilder::Init(TLV::TLVWriter * const apWriter) | ||
{ | ||
mpWriter = apWriter; | ||
mError = mpWriter->StartContainer(TLV::AnonymousTag, chip::TLV::kTLVType_Array, mOuterContainerType); | ||
|
||
return mError; | ||
} | ||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Builder.h" | ||
#include "Parser.h" | ||
#include <app/util/basic-types.h> | ||
#include <lib/core/CHIPCore.h> | ||
#include <lib/core/CHIPTLV.h> | ||
#include <lib/support/CodeUtils.h> | ||
#include <lib/support/logging/CHIPLogging.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
class ArrayBuilder : public Builder | ||
{ | ||
public: | ||
/** | ||
* Init the TLV array container with an particular context tag. | ||
* Required to implement arrays of arrays, and to test ArrayBuilder. | ||
* | ||
* @param[in] apWriter Pointer to the TLVWriter that is encoding the message. | ||
* @param[in] aContextTagToUse A contextTag to use. | ||
* | ||
* @return CHIP_ERROR codes returned by chip::TLV objects. | ||
*/ | ||
|
||
CHIP_ERROR Init(TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse); | ||
/** | ||
* Init the TLV array container with an anonymous tag. | ||
* Required to implement arrays of arrays, and to test ArrayBuilder. | ||
* | ||
* @param[in] apWriter Pointer to the TLVWriter that is encoding the message. | ||
* | ||
* @return CHIP_ERROR codes returned by chip::TLV objects. | ||
*/ | ||
CHIP_ERROR Init(TLV::TLVWriter * const apWriter); | ||
}; | ||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* Copyright (c) 2018 Google LLC. | ||
* Copyright (c) 2016-2017 Nest Labs, Inc. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
|
||
#include "ArrayParser.h" | ||
|
||
namespace chip { | ||
namespace app { | ||
CHIP_ERROR ArrayParser::Init(const TLV::TLVReader & aReader) | ||
{ | ||
mReader.Init(aReader); | ||
VerifyOrReturnError(TLV::kTLVType_Array == mReader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); | ||
ReturnLogErrorOnFailure(mReader.EnterContainer(mOuterContainerType)); | ||
return CHIP_NO_ERROR; | ||
} | ||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* Copyright (c) 2016-2017 Nest Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Parser.h" | ||
|
||
namespace chip { | ||
namespace app { | ||
class ArrayParser : public Parser | ||
{ | ||
public: | ||
/** | ||
* @brief Initialize the parser object with TLVReader | ||
* | ||
* @param [in] aReader A pointer to a TLVReader, which should be on the element of the array element | ||
* | ||
* @return #CHIP_NO_ERROR on success | ||
*/ | ||
CHIP_ERROR Init(const TLV::TLVReader & aReader); | ||
}; | ||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.