Skip to content

Commit

Permalink
[upb] fix elisp_rules build broken by upstream b997cb6d
Browse files Browse the repository at this point in the history
This is protocolbuffers/protobuf@b997cb6d titled "upb:
add a non-void typedef for upb_Message" by @ericsalo.
  • Loading branch information
Ron Gut committed Dec 22, 2023
1 parent c4a6abc commit c09eeb0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions elisp/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ cc_binary(
"@com_google_absl//absl/base:config",
"@com_google_absl//absl/base:core_headers",
"@upb",
"@upb//:base",
"@upb//:collections",
"@upb//:descriptor_upb_proto",
"@upb//:json",
Expand Down
32 changes: 20 additions & 12 deletions elisp/proto/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
#include "google/protobuf/duration.upbdefs.h"
#include "google/protobuf/timestamp.upb.h"
#include "google/protobuf/timestamp.upbdefs.h"
#include "upb/base/upcast.h"
#include "upb/collections.h"
#include "upb/decode.h"
#include "upb/def.h"
Expand Down Expand Up @@ -3528,8 +3529,10 @@ static emacs_value Timestamp(emacs_env* env,
kTimestampP, args[0]);
if (msg.type == NULL) return NULL;
struct timespec time;
time.tv_sec = google_protobuf_Timestamp_seconds(msg.value);
time.tv_nsec = google_protobuf_Timestamp_nanos(msg.value);
time.tv_sec = google_protobuf_Timestamp_seconds(
(google_protobuf_Timestamp*)msg.value);
time.tv_nsec = google_protobuf_Timestamp_nanos(
(google_protobuf_Timestamp*)msg.value);
return MakeTime(ctx, time);
}

Expand All @@ -3542,8 +3545,10 @@ static emacs_value Duration(emacs_env* env,
kDurationP, args[0]);
if (msg.type == NULL) return NULL;
struct timespec time;
time.tv_sec = google_protobuf_Duration_seconds(msg.value);
time.tv_nsec = google_protobuf_Duration_nanos(msg.value);
time.tv_sec = google_protobuf_Duration_seconds(
(google_protobuf_Duration*)msg.value);
time.tv_nsec = google_protobuf_Duration_nanos(
(google_protobuf_Duration*)msg.value);
return MakeTime(ctx, time);
}

Expand All @@ -3556,7 +3561,7 @@ static emacs_value SetTimestamp(emacs_env* env,
ctx, kUpb_WellKnown_Timestamp, kTimestampP, args[0]);
if (msg.type == NULL) return NULL;
emacs_value time = args[1];
SetTimestampProto(ctx, msg.value, time);
SetTimestampProto(ctx, (google_protobuf_Timestamp*)msg.value, time);
return time;
}

Expand All @@ -3569,7 +3574,7 @@ static emacs_value SetDuration(emacs_env* env,
ctx, kUpb_WellKnown_Duration, kDurationP, args[0]);
if (msg.type == NULL) return NULL;
emacs_value time = args[1];
SetDurationProto(ctx, msg.value, time);
SetDurationProto(ctx, (google_protobuf_Duration*)msg.value, time);
return time;
}

Expand All @@ -3589,7 +3594,7 @@ static emacs_value MakeTimestamp(emacs_env* env,
}
if (!SetTimestampProto(ctx, msg, args[0])) return NULL;
return MakeMessageStruct(ctx, arena, GlobalSymbol(ctx, kTimestampNew), def,
msg, true);
UPB_UPCAST(msg), true);
}

static emacs_value MakeDuration(emacs_env* env,
Expand All @@ -3608,7 +3613,7 @@ static emacs_value MakeDuration(emacs_env* env,
}
if (!SetDurationProto(ctx, msg, args[0])) return NULL;
return MakeMessageStruct(ctx, arena, GlobalSymbol(ctx, kDurationNew), def,
msg, true);
UPB_UPCAST(msg), true);
}

static emacs_value PackAny(emacs_env* env,
Expand All @@ -3635,7 +3640,7 @@ static emacs_value PackAny(emacs_env* env,
if (type_url.data == NULL || serialized.data == NULL) return NULL;
google_protobuf_Any_set_type_url(any, View(type_url));
google_protobuf_Any_set_value(any, View(serialized));
return MakeMutableMessage(ctx, arena, any_def, any);
return MakeMutableMessage(ctx, arena, any_def, UPB_UPCAST(any));
}

static emacs_value UnpackAny(emacs_env* env,
Expand All @@ -3647,8 +3652,10 @@ static emacs_value UnpackAny(emacs_env* env,
struct MessageArg any =
ExtractWellKnownMessage(ctx, kUpb_WellKnown_Any, kAnyP, arg);
if (any.type == NULL) return NULL;
upb_StringView type_url = google_protobuf_Any_type_url(any.value);
upb_StringView serialized = google_protobuf_Any_value(any.value);
upb_StringView type_url = google_protobuf_Any_type_url(
(google_protobuf_Any *)any.value);
upb_StringView serialized = google_protobuf_Any_value(
(google_protobuf_Any *)any.value);
if (type_url.data == NULL || serialized.data == NULL) {
UninitializedAny(ctx, arg);
return NULL;
Expand All @@ -3670,7 +3677,8 @@ static emacs_value AnyTypeName(emacs_env* env,
struct MessageArg any =
ExtractWellKnownMessage(ctx, kUpb_WellKnown_Any, kAnyP, arg);
if (any.type == NULL) return NULL;
upb_StringView type_url = google_protobuf_Any_type_url(any.value);
upb_StringView type_url = google_protobuf_Any_type_url(
(google_protobuf_Any *)any.value);
if (type_url.data == NULL) {
UninitializedAny(ctx, arg);
return NULL;
Expand Down

0 comments on commit c09eeb0

Please sign in to comment.