Skip to content

Commit

Permalink
DO NOT SUBMIT: temporary logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswuollett committed Oct 27, 2023
1 parent be36e91 commit 81fff73
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 7 deletions.
3 changes: 3 additions & 0 deletions protobuf-codegen/src/gen/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ impl<'a> EnumGen<'a> {
path: &'a [i32],
info: Option<&'a SourceCodeInfo>,
) -> EnumGen<'a> {
let enum_proto = enum_with_scope.en.proto();
eprintln!("EnumGen::parse enum.name: {}", enum_proto.name());

let customize = customize.child(
&customize_from_rustproto_for_enum(enum_with_scope.en.proto().options.get_or_default()),
&enum_with_scope.en,
Expand Down
2 changes: 2 additions & 0 deletions protobuf-codegen/src/gen/field/elem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ impl<'a> FieldElemMessage<'a> {
}

fn rust_type(&self, reference: &FileAndMod) -> RustType {
eprintln!("FieldElemMessage::rust_type message.mod_name: {}", self.message.mod_name().to_string());
eprintln!("FieldElemMessage::rust_type message.name: {}", self.message.message.name());
RustType::Message(self.rust_name_relative(reference))
}
}
Expand Down
8 changes: 8 additions & 0 deletions protobuf-codegen/src/gen/field/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ impl<'a> FieldGen<'a> {
path: Vec<i32>,
info: Option<&'a SourceCodeInfo>,
) -> anyhow::Result<FieldGen<'a>> {
let message_proto = field.message.message.proto();
eprintln!("FieldGen::parse message.name: {}", message_proto.name());
eprintln!("FieldGen::parse field.name: {}", field.field.proto().name());
eprintln!("FieldGen::parse field.type.protobuf_name: {}", field.field.proto().type_().protobuf_name());
eprintln!("FieldGen::parse field.type_name: {}", field.field.proto().type_name());

let customize = parent_customize
.child(
&customize_from_rustproto_for_field(field.field.proto().options.get_or_default()),
Expand Down Expand Up @@ -336,6 +342,8 @@ impl<'a> FieldGen<'a> {

// for field `foo`, return type of `fn foo(..)`
fn getter_return_type(&self) -> RustType {
eprintln!("FieldGen::getter_return_type");

let reference = self
.proto_field
.message
Expand Down
2 changes: 2 additions & 0 deletions protobuf-codegen/src/gen/oneof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ impl<'a> OneofGen<'a> {
oneof: OneofWithContext<'a>,
parent_customize: &CustomizeElemCtx<'a>,
) -> OneofGen<'a> {
let message_proto = message.message.message.proto();
eprintln!("OneofGen::parse message.name: {}", message_proto.name());
let customize = parent_customize.child(&Customize::default(), &oneof.oneof);
let lite_runtime = customize.for_elem.lite_runtime.unwrap_or_else(|| {
oneof
Expand Down
7 changes: 6 additions & 1 deletion protobuf-codegen/src/gen/paths.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use protobuf::descriptor::FileDescriptorProto;

use crate::gen::inside::protobuf_crate_path;
use crate::gen::rust::ident::RustIdent;
use crate::gen::rust::path::RustPath;
Expand Down Expand Up @@ -74,16 +76,19 @@ pub(crate) fn proto_path_to_fn_file_descriptor(
s => {
if let Some(mod_path) = &customize.gen_mod_rs_hierarchy_out_dir_mod_name {
let mut rust_path = RustPath::from("crate");
eprintln!("Forming path wth rust_path: {}", rust_path);
for mod_part in mod_path.split("::") {
rust_path = rust_path.append_ident(RustIdent::from(mod_part));
eprintln!("Forming path wth rust_path: {}", rust_path);
}
for component in proto_path.split("/").filter(|p| !p.ends_with(".proto")) {
rust_path = rust_path.append_ident(RustIdent::from(component));
eprintln!("Forming path wth rust_path: {}", rust_path);
}
rust_path.append_ident("file_descriptor".into())
} else {
RustPath::super_path()
.append_ident(proto_path_to_rust_mod(s))
.append_ident(proto_path_to_rust_mod(s))
.append_ident("file_descriptor".into())
}
}
Expand Down
62 changes: 56 additions & 6 deletions protobuf-codegen/src/gen/rust_types_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ impl RustType {
RustType::Option(ref param) => {
format!("::std::option::Option<{}>", param.to_code(customize))
}
RustType::MessageField(ref param) => format!(
"{}::MessageField<{}>",
protobuf_crate_path(customize),
param.to_code(customize)
),
RustType::MessageField(ref param) => {
let crate_path = protobuf_crate_path(customize);
eprintln!("Writing MessageField");
format!("{}::MessageField<{}>", crate_path, param.to_code(customize))
}
RustType::Uniq(ref param) => format!("::std::boxed::Box<{}>", param.to_code(customize)),
RustType::Ref(ref param) => format!("&{}", param.to_code(customize)),
RustType::Message(ref name) => format!("{}", name),
RustType::Message(ref name) => {
eprintln!("Writing Message name: {}", name);
eprintln!("Writing Message rust.ident: {}", name.0.ident);
eprintln!("Writing Message rust.path: {}", name.0.path);
format!("{}", name)
}
RustType::Enum(ref name, ..) | RustType::Oneof(ref name) => format!("{}", name),
RustType::EnumOrUnknown(ref name, ..) => format!(
"{}::EnumOrUnknown<{}>",
Expand Down Expand Up @@ -486,6 +491,7 @@ pub(crate) fn message_or_enum_to_rust_relative(
message_or_enum: &dyn WithScope,
current: &FileAndMod,
) -> RustIdentWithPath {
eprintln!("message_or_enum_to_rust_relative");
let same_file = message_or_enum.file_descriptor().name() == current.file;
if same_file {
// field type is a message or enum declared in the same file
Expand Down Expand Up @@ -514,16 +520,60 @@ pub(crate) fn message_or_enum_to_rust_relative(
))
} else if let Some(mod_name) = &current.customize.gen_mod_rs_hierarchy_out_dir_mod_name {
let mut rust_name = format!("crate::{}", mod_name.to_owned());
eprintln!(
"message_or_enum_to_rust_relative MY_WAY mod_name: {}",
rust_name
);
for component in message_or_enum
.name_absolute()
.trim_start_matches(':')
.split('.')
.filter(|s| !s.is_empty())
{
eprintln!(
"message_or_enum_to_rust_relative MY_WAY component: {}",
component
);
rust_name.push_str(&format!("::{}", component.replace('-', "_")));
}
eprintln!(
"message_or_enum_to_rust_relative MY_WAY rust_name: {}",
rust_name
);
RustIdentWithPath::from(rust_name)
} else {
eprintln!(
"message_or_enum_to_rust_relative current.file: {}",
current.file
);
eprintln!(
"message_or_enum_to_rust_relative current.relative_mod: {}",
current.relative_mod
);
eprintln!(
"message_or_enum_to_rust_relative message_or_enum.name_absolute: {}",
message_or_enum.name_absolute()
);
eprintln!(
"message_or_enum_to_rust_relative message_or_enum.name_to_package: {}",
message_or_enum.name_to_package()
);
eprintln!(
"message_or_enum_to_rust_relative message_or_enum.protobuf_name_to_package: {}",
message_or_enum.protobuf_name_to_package()
);
eprintln!(
"message_or_enum_to_rust_relative message_or_enum.rust_name: {}",
message_or_enum.rust_name()
);
eprintln!(
"message_or_enum_to_rust_relative message_or_enum.rust_name_to_file: {}",
message_or_enum.rust_name_to_file()
);
eprintln!(
"message_or_enum_to_rust_relative message_or_enum.rust_name_with_file: {}",
message_or_enum.rust_name_with_file()
);
current
.relative_mod
.to_reverse()
Expand Down
5 changes: 5 additions & 0 deletions protobuf-codegen/src/gen/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ impl<'a> Scope<'a> {
}

pub fn file_and_mod(&self, customize: Customize) -> FileAndMod {
let d = self.file_scope.file_descriptor.proto();
eprintln!("Scope::file_and_mod package: package: {}", d.package());
eprintln!("Scope::file_and_mod package: name: {}", d.name());
eprintln!("Scope::file_and_mod package: rust_path_to_file: {}", self.rust_path_to_file());
eprintln!("Scope::file_and_mod package: path_str: {}", self.path_str());
FileAndMod {
file: self.file_scope.file_descriptor.proto().name().to_owned(),
relative_mod: self.rust_path_to_file(),
Expand Down

0 comments on commit 81fff73

Please sign in to comment.