-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb0c543
commit 4e93585
Showing
14 changed files
with
182 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,12 @@ | |
|
||
__author__ = '[email protected] (Petar Petrov)' | ||
|
||
from google.protobuf.internal import api_implementation | ||
|
||
if api_implementation.Type() == 'cpp': | ||
# pylint: disable=g-import-not-at-top | ||
from google.protobuf.pyext import _message | ||
|
||
|
||
class GeneratedServiceType(type): | ||
|
||
|
@@ -76,9 +82,15 @@ def __init__(cls, name, bases, dictionary): | |
# when a service class is subclassed. | ||
if GeneratedServiceType._DESCRIPTOR_KEY not in dictionary: | ||
return | ||
|
||
descriptor = dictionary[GeneratedServiceType._DESCRIPTOR_KEY] | ||
if isinstance(descriptor, str): | ||
descriptor = _message.default_pool.FindServiceByName(descriptor) | ||
dictionary[GeneratedServiceType._DESCRIPTOR_KEY] = descriptor | ||
|
||
service_builder = _ServiceBuilder(descriptor) | ||
service_builder.BuildService(cls) | ||
cls.DESCRIPTOR = descriptor | ||
|
||
|
||
class GeneratedServiceStubType(GeneratedServiceType): | ||
|
@@ -101,12 +113,16 @@ def __init__(cls, name, bases, dictionary): | |
dictionary[_DESCRIPTOR_KEY] must contain a ServiceDescriptor object | ||
describing this protocol service type. | ||
""" | ||
descriptor = dictionary.get(cls._DESCRIPTOR_KEY) | ||
if isinstance(descriptor, str): | ||
descriptor = _message.default_pool.FindServiceByName(descriptor) | ||
dictionary[GeneratedServiceStubType._DESCRIPTOR_KEY] = descriptor | ||
super(GeneratedServiceStubType, cls).__init__(name, bases, dictionary) | ||
# Don't do anything if this class doesn't have a descriptor. This happens | ||
# when a service stub is subclassed. | ||
if GeneratedServiceStubType._DESCRIPTOR_KEY not in dictionary: | ||
return | ||
descriptor = dictionary[GeneratedServiceStubType._DESCRIPTOR_KEY] | ||
|
||
service_stub_builder = _ServiceStubBuilder(descriptor) | ||
service_stub_builder.BuildServiceStub(cls) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.