Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
d419ca10
Commit
d419ca10
authored
Apr 22, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated upb and simplified ruby code a bit with new upb method.
parent
40574479
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
26 deletions
+19
-26
encode_decode.c
ruby/ext/google/protobuf_c/encode_decode.c
+1
-6
message.c
ruby/ext/google/protobuf_c/message.c
+18
-20
upb.c
ruby/ext/google/protobuf_c/upb.c
+0
-0
upb.h
ruby/ext/google/protobuf_c/upb.h
+0
-0
No files found.
ruby/ext/google/protobuf_c/encode_decode.c
View file @
d419ca10
...
...
@@ -656,7 +656,6 @@ static const upb_json_parsermethod *msgdef_jsonparsermethod(Descriptor* desc) {
#define STACK_ENV_STACKBYTES 4096
typedef
struct
{
upb_env
env
;
upb_seededalloc
alloc
;
const
char
*
ruby_error_template
;
char
allocbuf
[
STACK_ENV_STACKBYTES
];
}
stackenv
;
...
...
@@ -681,16 +680,12 @@ static bool env_error_func(void* ud, const upb_status* status) {
static
void
stackenv_init
(
stackenv
*
se
,
const
char
*
errmsg
)
{
se
->
ruby_error_template
=
errmsg
;
upb_env_init
(
&
se
->
env
);
upb_seededalloc_init
(
&
se
->
alloc
,
&
se
->
allocbuf
,
STACK_ENV_STACKBYTES
);
upb_env_setallocfunc
(
&
se
->
env
,
upb_seededalloc_getallocfunc
(
&
se
->
alloc
),
&
se
->
alloc
);
upb_env_init2
(
&
se
->
env
,
se
->
allocbuf
,
sizeof
(
se
->
allocbuf
),
NULL
);
upb_env_seterrorfunc
(
&
se
->
env
,
env_error_func
,
se
);
}
static
void
stackenv_uninit
(
stackenv
*
se
)
{
upb_env_uninit
(
&
se
->
env
);
upb_seededalloc_uninit
(
&
se
->
alloc
);
}
/*
...
...
ruby/ext/google/protobuf_c/message.c
View file @
d419ca10
...
...
@@ -151,32 +151,30 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) {
name_len
--
;
}
// Check for a oneof name first.
o
=
upb_msgdef_ntoo
(
self
->
descriptor
->
msgdef
,
name
,
name_len
);
// See if this name corresponds to either a oneof or field in this message.
if
(
!
upb_msgdef_lookupname
(
self
->
descriptor
->
msgdef
,
name
,
name_len
,
&
f
,
&
o
))
{
return
rb_call_super
(
argc
,
argv
);
}
if
(
o
!=
NULL
)
{
// This is a oneof -- return which field inside the oneof is set.
if
(
setter
)
{
rb_raise
(
rb_eRuntimeError
,
"Oneof accessors are read-only."
);
}
return
which_oneof_field
(
self
,
o
);
}
// Otherwise, check for a field with that name.
f
=
upb_msgdef_ntof
(
self
->
descriptor
->
msgdef
,
name
,
name_len
);
if
(
f
==
NULL
)
{
return
rb_call_super
(
argc
,
argv
);
}
if
(
setter
)
{
if
(
argc
<
2
)
{
rb_raise
(
rb_eArgError
,
"No value provided to setter."
);
}
layout_set
(
self
->
descriptor
->
layout
,
Message_data
(
self
),
f
,
argv
[
1
]);
return
Qnil
;
}
else
{
return
layout_get
(
self
->
descriptor
->
layout
,
Message_data
(
self
),
f
);
// This is a field -- get or set the field's value.
assert
(
f
);
if
(
setter
)
{
if
(
argc
<
2
)
{
rb_raise
(
rb_eArgError
,
"No value provided to setter."
);
}
layout_set
(
self
->
descriptor
->
layout
,
Message_data
(
self
),
f
,
argv
[
1
]);
return
Qnil
;
}
else
{
return
layout_get
(
self
->
descriptor
->
layout
,
Message_data
(
self
),
f
);
}
}
}
...
...
ruby/ext/google/protobuf_c/upb.c
View file @
d419ca10
This diff is collapsed.
Click to expand it.
ruby/ext/google/protobuf_c/upb.h
View file @
d419ca10
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment