Commit cd980d1c authored by Feng Xiao's avatar Feng Xiao

Prepare nano proto code to be merged into protobuf repository.

parent 6dc39245
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.google</groupId>
<artifactId>google</artifactId>
<version>1</version>
</parent>
<groupId>com.google.protobuf.nano</groupId>
<artifactId>protobuf-javanano</artifactId>
<version>2.6.2-pre</version>
<packaging>bundle</packaging>
<name>Protocol Buffer JavaNano API</name>
<description>
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format.
</description>
<inceptionYear>2008</inceptionYear>
<url>https://developers.google.com/protocol-buffers/</url>
<licenses>
<license>
<name>New BSD license</name>
<url>http://www.opensource.org/licenses/bsd-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/google/protobuf</url>
<connection>
scm:git:https://github.com/google/protobuf.git
</connection>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-test-sources</id>
<phase>generate-test-sources</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-test-sources" />
<exec executable="../src/protoc">
<arg value="--javanano_out=generate_equals=true:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_import_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_single_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=store_unknown_fields=true,generate_equals=true:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=store_unknown_fields=true:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=java_nano_generate_has=true,generate_equals=true:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_has_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=optional_field_style=accessors,generate_equals=true:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=enum_style=java:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=
optional_field_style=accessors,
java_outer_classname=google/protobuf/nano/unittest_enum_validity_nano.proto|EnumValidityAccessors
:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto" />
</exec>
<exec executable="../src/protoc">
<arg value="--javanano_out=optional_field_style=reftypes,generate_equals=true:target/generated-test-sources" />
<arg value="--proto_path=src/test/java/com" />
<arg value="src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto" />
</exec>
</tasks>
<testSourceRoot>target/generated-test-sources</testSourceRoot>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
<Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
<Export-Package>com.google.protobuf;version=2.6.2-pre</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.protobuf;
package com.google.protobuf.nano;
import com.google.protobuf.nano.CodedInputByteBufferNano;
import com.google.protobuf.nano.EnumClassNanoMultiple;
......@@ -3123,11 +3123,12 @@ public class NanoTest extends TestCase {
message.value = false;
byte[] bytes = MessageNano.toByteArray(message);
int extraFieldSize = CodedOutputStream.computeStringSize(1001, "This is an unknown field");
int extraFieldSize = CodedOutputByteBufferNano.computeStringSize(
1001, "This is an unknown field");
byte[] newBytes = new byte[bytes.length + extraFieldSize];
System.arraycopy(bytes, 0, newBytes, 0, bytes.length);
CodedOutputStream.newInstance(newBytes, bytes.length, extraFieldSize).writeString(1001,
"This is an unknown field");
CodedOutputByteBufferNano.newInstance(newBytes, bytes.length, extraFieldSize)
.writeString(1001, "This is an unknown field");
// Deserialize with an unknown field.
AnotherMessage deserialized = AnotherMessage.parseFrom(newBytes);
......
......@@ -3,7 +3,7 @@ syntax = "proto2";
option java_multiple_files = true;
option java_package = "com.google.protobuf.nano";
import "google/protobuf/unittest_extension_nano.proto";
import "google/protobuf/nano/unittest_extension_nano.proto";
// Must be compiled separately due to extension number reuse.
// The reuse is deliberate, for testing wire compatibility.
......
......@@ -3,7 +3,7 @@ syntax = "proto2";
option java_multiple_files = true;
option java_package = "com.google.protobuf.nano";
import "google/protobuf/unittest_extension_nano.proto";
import "google/protobuf/nano/unittest_extension_nano.proto";
// Must be compiled separately due to extension number reuse.
// The reuse is deliberate, for testing wire compatibility.
......
......@@ -3,7 +3,7 @@ syntax = "proto2";
option java_multiple_files = true;
option java_package = "com.google.protobuf.nano";
import "google/protobuf/unittest_extension_nano.proto";
import "google/protobuf/nano/unittest_extension_nano.proto";
// Must be compiled separately due to extension number reuse.
// The reuse is deliberate, for testing wire compatibility.
......
......@@ -34,9 +34,8 @@
package protobuf_unittest_import;
// java_package and java_outer_classname are specified on the command line.
//option java_package = "com.google.protobuf.nano.testimport";
//option java_outer_classname = "UnittestImportNano";
option java_package = "com.google.protobuf.nano.testimport";
option java_outer_classname = "UnittestImportNano";
message ImportMessageNano {
optional int32 d = 1;
......
......@@ -32,7 +32,7 @@
package protobuf_unittest_import;
import "google/protobuf/unittest_import_nano.proto";
import "google/protobuf/nano/unittest_import_nano.proto";
option java_package = "com.google.protobuf.nano";
option java_multiple_files = true;
......
......@@ -32,7 +32,7 @@
package protobuf_unittest;
import "google/protobuf/unittest_import_nano.proto";
import "google/protobuf/nano/unittest_import_nano.proto";
option java_package = "com.google.protobuf.nano";
option java_outer_classname = "NanoOuterClass";
......
......@@ -32,7 +32,7 @@
package protobuf_unittest;
import "google/protobuf/unittest_nano.proto";
import "google/protobuf/nano/unittest_nano.proto";
option java_package = "com.google.protobuf.nano";
option java_multiple_files = true;
......
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__
#include <string>
#include <vector>
......@@ -84,4 +84,4 @@ class EnumGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__
#include <map>
#include <string>
......@@ -122,4 +122,4 @@ class RepeatedEnumFieldGenerator : public FieldGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H_
#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H_
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/javanano/javanano_params.h>
......@@ -71,4 +71,4 @@ class ExtensionGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H_
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__
#include <string>
#include <google/protobuf/stubs/common.h>
......@@ -116,4 +116,4 @@ class FieldGeneratorMap {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__
......@@ -215,7 +215,7 @@ template<typename GeneratorClass, typename DescriptorClass>
static void GenerateSibling(const string& package_dir,
const string& java_package,
const DescriptorClass* descriptor,
OutputDirectory* output_directory,
GeneratorContext* output_directory,
vector<string>* file_list,
const Params& params) {
string filename = package_dir + descriptor->name() + ".java";
......@@ -238,7 +238,7 @@ static void GenerateSibling(const string& package_dir,
}
void FileGenerator::GenerateSiblings(const string& package_dir,
OutputDirectory* output_directory,
GeneratorContext* output_directory,
vector<string>* file_list) {
if (params_.java_multiple_files(file_->name())) {
for (int i = 0; i < file_->message_type_count(); i++) {
......
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__
#include <string>
#include <vector>
......@@ -47,7 +47,7 @@ namespace protobuf {
class Printer; // printer.h
}
namespace compiler {
class OutputDirectory; // code_generator.h
class GeneratorContext; // code_generator.h
}
}
......@@ -71,7 +71,7 @@ class FileGenerator {
// files other than the outer file (i.e. one for each message, enum, and
// service type).
void GenerateSiblings(const string& package_dir,
OutputDirectory* output_directory,
GeneratorContext* output_directory,
vector<string>* file_list);
const string& java_package() { return java_package_; }
......@@ -91,4 +91,4 @@ class FileGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__
......@@ -87,7 +87,7 @@ JavaNanoGenerator::~JavaNanoGenerator() {}
bool JavaNanoGenerator::Generate(const FileDescriptor* file,
const string& parameter,
OutputDirectory* output_directory,
GeneratorContext* output_directory,
string* error) const {
vector<pair<string, string> > options;
......
......@@ -34,8 +34,8 @@
//
// Generates Java nano code for a given .proto file.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NANO_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_NANO_GENERATOR_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__
#include <string>
#include <google/protobuf/compiler/code_generator.h>
......@@ -57,7 +57,7 @@ class LIBPROTOC_EXPORT JavaNanoGenerator : public CodeGenerator {
// implements CodeGenerator ----------------------------------------
bool Generate(const FileDescriptor* file,
const string& parameter,
OutputDirectory* output_directory,
GeneratorContext* output_directory,
string* error) const;
private:
......@@ -69,4 +69,4 @@ class LIBPROTOC_EXPORT JavaNanoGenerator : public CodeGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NANO_GENERATOR_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__
#include <string>
#include <google/protobuf/compiler/javanano/javanano_params.h>
......@@ -186,4 +186,4 @@ void SetBitOperationVariables(const string name,
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__
#include <string>
#include <google/protobuf/compiler/javanano/javanano_helpers.h>
......@@ -92,4 +92,4 @@ class MessageGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__
......@@ -32,8 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__
#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__
#include <map>
#include <string>
......@@ -93,4 +93,4 @@ class RepeatedMessageFieldGenerator : public FieldGenerator {
} // namespace protobuf
} // namespace google
#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__
#endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment