Hide spvBinaryHeaderSet with its only client.
authorDavid Neto <dneto@google.com>
Tue, 27 Oct 2015 19:51:34 +0000 (15:51 -0400)
committerDavid Neto <dneto@google.com>
Mon, 2 Nov 2015 18:52:09 +0000 (13:52 -0500)
Also rename it to SetHeader since it's not part of the "binary"
API.

source/binary.cpp
source/binary.h
source/text.cpp

index de29106..4213bea 100644 (file)
@@ -113,19 +113,6 @@ spv_result_t spvBinaryHeaderGet(const spv_binary binary,
   return SPV_SUCCESS;
 }
 
-spv_result_t spvBinaryHeaderSet(spv_binary_t *binary, const uint32_t bound) {
-  if (!binary) return SPV_ERROR_INVALID_BINARY;
-  if (!binary->code || !binary->wordCount) return SPV_ERROR_INVALID_BINARY;
-
-  binary->code[SPV_INDEX_MAGIC_NUMBER] = SPV_MAGIC_NUMBER;
-  binary->code[SPV_INDEX_VERSION_NUMBER] = SPV_VERSION_NUMBER;
-  binary->code[SPV_INDEX_GENERATOR_NUMBER] = SPV_GENERATOR_KHRONOS;
-  binary->code[SPV_INDEX_BOUND] = bound;
-  binary->code[SPV_INDEX_SCHEMA] = 0;  // NOTE: Reserved
-
-  return SPV_SUCCESS;
-}
-
 // TODO(dneto): This API is not powerful enough in the case that the
 // number and type of operands are not known until partway through parsing
 // the operation.  This happens when enum operands might have different number
index b78a163..ad542cf 100644 (file)
@@ -76,14 +76,6 @@ spv_result_t spvBinaryHeaderGet(const spv_binary binary,
                                 const spv_endianness_t endian,
                                 spv_header_t *pHeader);
 
-/// @brief Populate a binary stream with this generators header
-///
-/// @param[in,out] binary the binary stream
-/// @param[in] bound the upper ID bound
-///
-/// @return result code
-spv_result_t spvBinaryHeaderSet(spv_binary binary, const uint32_t bound);
-
 /// @brief Determine the type of the desired operand
 ///
 /// @param[in] word the operand value
index 8853ed2..8d60a50 100644 (file)
@@ -612,6 +612,25 @@ spv_result_t spvTextEncodeOpcode(const libspirv::AssemblyGrammar& grammar,
 
 namespace {
 
+/// @brief Populate a binary stream with this generator's header.
+///
+/// @param[in,out] binary the binary stream
+/// @param[in] bound the upper ID bound
+///
+/// @return result code
+spv_result_t SetHeader(spv_binary_t* binary, const uint32_t bound) {
+  if (!binary) return SPV_ERROR_INVALID_BINARY;
+  if (!binary->code || !binary->wordCount) return SPV_ERROR_INVALID_BINARY;
+
+  binary->code[SPV_INDEX_MAGIC_NUMBER] = SPV_MAGIC_NUMBER;
+  binary->code[SPV_INDEX_VERSION_NUMBER] = SPV_VERSION_NUMBER;
+  binary->code[SPV_INDEX_GENERATOR_NUMBER] = SPV_GENERATOR_KHRONOS;
+  binary->code[SPV_INDEX_BOUND] = bound;
+  binary->code[SPV_INDEX_SCHEMA] = 0;  // NOTE: Reserved
+
+  return SPV_SUCCESS;
+}
+
 // Translates a given assembly language module into binary form.
 // If a diagnostic is generated, it is not yet marked as being
 // for a text-based input.
@@ -673,8 +692,7 @@ spv_result_t spvTextToBinaryInternal(const libspirv::AssemblyGrammar& grammar,
   binary->code = data;
   binary->wordCount = totalSize;
 
-  spv_result_t error = spvBinaryHeaderSet(binary, context.getBound());
-  if (error) {
+  if (auto error = SetHeader(binary, context.getBound())) {
     spvBinaryDestroy(binary);
     return error;
   }