Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
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
flatbuffers
Commits
cb6cc3df
Commit
cb6cc3df
authored
Jun 14, 2016
by
lakedaemon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
php:removed parser from method signatures
parent
66f2aac2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
37 deletions
+25
-37
idl_gen_php.cpp
src/idl_gen_php.cpp
+25
-37
No files found.
src/idl_gen_php.cpp
View file @
cb6cc3df
...
@@ -55,7 +55,7 @@ namespace php {
...
@@ -55,7 +55,7 @@ namespace php {
it
!=
parser_
.
structs_
.
vec
.
end
();
++
it
)
{
it
!=
parser_
.
structs_
.
vec
.
end
();
++
it
)
{
auto
&
struct_def
=
**
it
;
auto
&
struct_def
=
**
it
;
std
::
string
declcode
;
std
::
string
declcode
;
GenStruct
(
parser_
,
struct_def
,
&
declcode
);
GenStruct
(
struct_def
,
&
declcode
);
if
(
!
SaveType
(
struct_def
,
declcode
,
true
))
return
false
;
if
(
!
SaveType
(
struct_def
,
declcode
,
true
))
return
false
;
}
}
return
true
;
return
true
;
...
@@ -96,8 +96,7 @@ namespace php {
...
@@ -96,8 +96,7 @@ namespace php {
// Ensure that a type is prefixed with its namespace whenever it is used
// Ensure that a type is prefixed with its namespace whenever it is used
// outside of its namespace.
// outside of its namespace.
static
std
::
string
WrapInNameSpace
(
const
Namespace
*
ns
,
std
::
string
WrapInNameSpace
(
const
Namespace
*
ns
,
const
std
::
string
&
name
)
{
const
std
::
string
&
name
)
{
std
::
string
qualified_name
=
"
\\
"
;
std
::
string
qualified_name
=
"
\\
"
;
for
(
auto
it
=
ns
->
components
.
begin
();
for
(
auto
it
=
ns
->
components
.
begin
();
it
!=
ns
->
components
.
end
();
++
it
)
{
it
!=
ns
->
components
.
end
();
++
it
)
{
...
@@ -106,7 +105,7 @@ namespace php {
...
@@ -106,7 +105,7 @@ namespace php {
return
qualified_name
+
name
;
return
qualified_name
+
name
;
}
}
st
atic
st
d
::
string
WrapInNameSpace
(
const
Definition
&
def
)
{
std
::
string
WrapInNameSpace
(
const
Definition
&
def
)
{
return
WrapInNameSpace
(
def
.
defined_namespace
,
def
.
name
);
return
WrapInNameSpace
(
def
.
defined_namespace
,
def
.
name
);
}
}
...
@@ -246,8 +245,7 @@ namespace php {
...
@@ -246,8 +245,7 @@ namespace php {
}
}
// Get the value of a table's scalar.
// Get the value of a table's scalar.
static
void
GetScalarFieldOfTable
(
const
FieldDef
&
field
,
void
GetScalarFieldOfTable
(
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
std
::
string
getter
=
GenGetter
(
field
.
value
.
type
);
std
::
string
getter
=
GenGetter
(
field
.
value
.
type
);
...
@@ -270,8 +268,7 @@ namespace php {
...
@@ -270,8 +268,7 @@ namespace php {
// Get a struct by initializing an existing struct.
// Get a struct by initializing an existing struct.
// Specific to Struct.
// Specific to Struct.
static
void
GetStructFieldOfStruct
(
const
FieldDef
&
field
,
void
GetStructFieldOfStruct
(
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
code
+=
Indent
+
"/**
\n
"
;
code
+=
Indent
+
"/**
\n
"
;
...
@@ -290,8 +287,7 @@ namespace php {
...
@@ -290,8 +287,7 @@ namespace php {
// Get a struct by initializing an existing struct.
// Get a struct by initializing an existing struct.
// Specific to Table.
// Specific to Table.
static
void
GetStructFieldOfTable
(
const
FieldDef
&
field
,
void
GetStructFieldOfTable
(
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
code
+=
Indent
+
"public function get"
;
code
+=
Indent
+
"public function get"
;
...
@@ -317,8 +313,7 @@ namespace php {
...
@@ -317,8 +313,7 @@ namespace php {
}
}
// Get the value of a string.
// Get the value of a string.
static
void
GetStringField
(
const
FieldDef
&
field
,
void
GetStringField
(
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
code
+=
Indent
+
"public function get"
;
code
+=
Indent
+
"public function get"
;
code
+=
MakeCamel
(
field
.
name
);
code
+=
MakeCamel
(
field
.
name
);
...
@@ -335,8 +330,7 @@ namespace php {
...
@@ -335,8 +330,7 @@ namespace php {
}
}
// Get the value of a union from an object.
// Get the value of a union from an object.
static
void
GetUnionField
(
const
FieldDef
&
field
,
void
GetUnionField
(
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
code
+=
Indent
+
"/**
\n
"
;
code
+=
Indent
+
"/**
\n
"
;
...
@@ -355,9 +349,8 @@ namespace php {
...
@@ -355,9 +349,8 @@ namespace php {
}
}
// Get the value of a vector's struct member.
// Get the value of a vector's struct member.
static
void
GetMemberOfVectorOfStruct
(
const
StructDef
&
struct_def
,
void
GetMemberOfVectorOfStruct
(
const
StructDef
&
struct_def
,
const
FieldDef
&
field
,
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
auto
vectortype
=
field
.
value
.
type
.
VectorType
();
auto
vectortype
=
field
.
value
.
type
.
VectorType
();
...
@@ -419,7 +412,7 @@ namespace php {
...
@@ -419,7 +412,7 @@ namespace php {
// Get the value of a vector's non-struct member. Uses a named return
// Get the value of a vector's non-struct member. Uses a named return
// argument to conveniently set the zero value for the result.
// argument to conveniently set the zero value for the result.
static
void
GetMemberOfVectorOfNonStruct
(
const
FieldDef
&
field
,
void
GetMemberOfVectorOfNonStruct
(
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
auto
vectortype
=
field
.
value
.
type
.
VectorType
();
auto
vectortype
=
field
.
value
.
type
.
VectorType
();
...
@@ -660,9 +653,7 @@ namespace php {
...
@@ -660,9 +653,7 @@ namespace php {
}
}
// Get the offset of the end of a table.
// Get the offset of the end of a table.
static
void
GetEndOffsetOnTable
(
const
Parser
&
parser
,
void
GetEndOffsetOnTable
(
const
StructDef
&
struct_def
,
std
::
string
*
code_ptr
)
{
const
StructDef
&
struct_def
,
std
::
string
*
code_ptr
)
{
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
...
@@ -689,7 +680,7 @@ namespace php {
...
@@ -689,7 +680,7 @@ namespace php {
code
+=
Indent
+
Indent
+
"return $o;
\n
"
;
code
+=
Indent
+
Indent
+
"return $o;
\n
"
;
code
+=
Indent
+
"}
\n
"
;
code
+=
Indent
+
"}
\n
"
;
if
(
parser
.
root_struct_def_
==
&
struct_def
)
{
if
(
parser
_
.
root_struct_def_
==
&
struct_def
)
{
code
+=
"
\n
"
;
code
+=
"
\n
"
;
code
+=
Indent
+
"public static function finish"
;
code
+=
Indent
+
"public static function finish"
;
code
+=
struct_def
.
name
;
code
+=
struct_def
.
name
;
...
@@ -697,16 +688,15 @@ namespace php {
...
@@ -697,16 +688,15 @@ namespace php {
code
+=
Indent
+
"{
\n
"
;
code
+=
Indent
+
"{
\n
"
;
code
+=
Indent
+
Indent
+
"$builder->finish($offset"
;
code
+=
Indent
+
Indent
+
"$builder->finish($offset"
;
if
(
parser
.
file_identifier_
.
length
())
if
(
parser
_
.
file_identifier_
.
length
())
code
+=
",
\"
"
+
parser
.
file_identifier_
+
"
\"
"
;
code
+=
",
\"
"
+
parser
_
.
file_identifier_
+
"
\"
"
;
code
+=
");
\n
"
;
code
+=
");
\n
"
;
code
+=
Indent
+
"}
\n
"
;
code
+=
Indent
+
"}
\n
"
;
}
}
}
}
// Generate a struct field, conditioned on its child type(s).
// Generate a struct field, conditioned on its child type(s).
static
void
GenStructAccessor
(
const
StructDef
&
struct_def
,
void
GenStructAccessor
(
const
StructDef
&
struct_def
,
const
FieldDef
&
field
,
const
FieldDef
&
field
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
GenComment
(
field
.
doc_comment
,
code_ptr
,
nullptr
);
GenComment
(
field
.
doc_comment
,
code_ptr
,
nullptr
);
...
@@ -753,9 +743,7 @@ namespace php {
...
@@ -753,9 +743,7 @@ namespace php {
}
}
// Generate table constructors, conditioned on its members' types.
// Generate table constructors, conditioned on its members' types.
static
void
GenTableBuilders
(
const
Parser
&
parser
,
void
GenTableBuilders
(
const
StructDef
&
struct_def
,
std
::
string
*
code_ptr
)
{
const
StructDef
&
struct_def
,
std
::
string
*
code_ptr
)
{
GetStartOfTable
(
struct_def
,
code_ptr
);
GetStartOfTable
(
struct_def
,
code_ptr
);
for
(
auto
it
=
struct_def
.
fields
.
vec
.
begin
();
for
(
auto
it
=
struct_def
.
fields
.
vec
.
begin
();
...
@@ -782,11 +770,11 @@ namespace php {
...
@@ -782,11 +770,11 @@ namespace php {
}
}
}
}
GetEndOffsetOnTable
(
parser
,
struct_def
,
code_ptr
);
GetEndOffsetOnTable
(
struct_def
,
code_ptr
);
}
}
// Generate struct or table methods.
// Generate struct or table methods.
static
void
GenStruct
(
const
Parser
&
parser
,
const
StructDef
&
struct_def
,
void
GenStruct
(
const
StructDef
&
struct_def
,
std
::
string
*
code_ptr
)
{
std
::
string
*
code_ptr
)
{
if
(
struct_def
.
generated
)
return
;
if
(
struct_def
.
generated
)
return
;
...
@@ -801,13 +789,13 @@ namespace php {
...
@@ -801,13 +789,13 @@ namespace php {
std
::
string
&
code
=
*
code_ptr
;
std
::
string
&
code
=
*
code_ptr
;
if
(
!
struct_def
.
fixed
)
{
if
(
!
struct_def
.
fixed
)
{
if
(
parser
.
file_identifier_
.
length
())
{
if
(
parser
_
.
file_identifier_
.
length
())
{
// Return the identifier
// Return the identifier
code
+=
Indent
+
"public static function "
+
struct_def
.
name
;
code
+=
Indent
+
"public static function "
+
struct_def
.
name
;
code
+=
"Identifier()
\n
"
;
code
+=
"Identifier()
\n
"
;
code
+=
Indent
+
"{
\n
"
;
code
+=
Indent
+
"{
\n
"
;
code
+=
Indent
+
Indent
+
"return
\"
"
;
code
+=
Indent
+
Indent
+
"return
\"
"
;
code
+=
parser
.
file_identifier_
+
"
\"
;
\n
"
;
code
+=
parser
_
.
file_identifier_
+
"
\"
;
\n
"
;
code
+=
Indent
+
"}
\n\n
"
;
code
+=
Indent
+
"}
\n\n
"
;
// Check if a buffer has the identifier.
// Check if a buffer has the identifier.
...
@@ -820,12 +808,12 @@ namespace php {
...
@@ -820,12 +808,12 @@ namespace php {
code
+=
Indent
+
"}
\n\n
"
;
code
+=
Indent
+
"}
\n\n
"
;
}
}
if
(
parser
.
file_extension_
.
length
())
{
if
(
parser
_
.
file_extension_
.
length
())
{
// Return the extension
// Return the extension
code
+=
Indent
+
"public static function "
+
struct_def
.
name
;
code
+=
Indent
+
"public static function "
+
struct_def
.
name
;
code
+=
"Extension()
\n
"
;
code
+=
"Extension()
\n
"
;
code
+=
Indent
+
"{
\n
"
;
code
+=
Indent
+
"{
\n
"
;
code
+=
Indent
+
Indent
+
"return
\"
"
+
parser
.
file_extension_
;
code
+=
Indent
+
Indent
+
"return
\"
"
+
parser
_
.
file_extension_
;
code
+=
"
\"
;
\n
"
;
code
+=
"
\"
;
\n
"
;
code
+=
Indent
+
"}
\n\n
"
;
code
+=
Indent
+
"}
\n\n
"
;
}
}
...
@@ -848,7 +836,7 @@ namespace php {
...
@@ -848,7 +836,7 @@ namespace php {
GenStructBuilder
(
struct_def
,
code_ptr
);
GenStructBuilder
(
struct_def
,
code_ptr
);
}
else
{
}
else
{
// Create a set of functions that allow table construction.
// Create a set of functions that allow table construction.
GenTableBuilders
(
parser
,
struct_def
,
code_ptr
);
GenTableBuilders
(
struct_def
,
code_ptr
);
}
}
EndClass
(
code_ptr
);
EndClass
(
code_ptr
);
}
}
...
@@ -916,7 +904,7 @@ namespace php {
...
@@ -916,7 +904,7 @@ namespace php {
return
ctypename
[
type
.
base_type
];
return
ctypename
[
type
.
base_type
];
}
}
st
atic
st
d
::
string
GenDefaultValue
(
const
Value
&
value
)
{
std
::
string
GenDefaultValue
(
const
Value
&
value
)
{
if
(
value
.
type
.
enum_def
)
{
if
(
value
.
type
.
enum_def
)
{
if
(
auto
val
=
value
.
type
.
enum_def
->
ReverseLookup
(
if
(
auto
val
=
value
.
type
.
enum_def
->
ReverseLookup
(
atoi
(
value
.
constant
.
c_str
()),
false
))
{
atoi
(
value
.
constant
.
c_str
()),
false
))
{
...
...
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