gorealis v2 refactor (#5)

* Changing default timeout for start maintenance.

* Upgrading dependencies to gorealis v2 and thrift  0.12.0

* Refactored to update to gorealis v2.
This commit is contained in:
Renan DelValle 2018-12-27 11:31:51 -08:00 committed by GitHub
parent ad4dd9606e
commit 6ab5c9334d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1335 changed files with 137431 additions and 61530 deletions

View file

@ -1,3 +1,7 @@
0.0.7
* Initial migration to gorealis v2
0.0.6
* Added auto-completion to the deb file.

15
Gopkg.lock generated
View file

@ -2,13 +2,12 @@
[[projects]]
branch = "0.10.0-http-client-fix"
digest = "1:2b8c4f3c06ddb304a24ba8a625aa9f583c5576743356fa41e48c63e1563021d2"
branch = "0.12.0"
digest = "1:89696c38cec777120b8b1bb5e2d363d655cf2e1e7d8c851919aaa0fd576d9b86"
name = "git.apache.org/thrift.git"
packages = ["lib/go/thrift"]
pruneopts = ""
revision = "cb1afec972a85791e9b24a04b60fc9dbbfc3cda3"
source = "github.com/rdelval/thrift"
revision = "384647d290e2e4a55a14b1b7ef1b7e66293a2c33"
[[projects]]
digest = "1:eb53021a8aa3f599d29c7102e65026242bdedce998a54837dc67f14b6a97c5fd"
@ -70,8 +69,7 @@
version = "v1.1.2"
[[projects]]
branch = "drainSLA"
digest = "1:154e4eb61c4f730b3b5962fc254e7aff9ddb9bab50efd6ab098fcfcad0e1920f"
digest = "1:0a57933aaf17a56940a600fbbe6ede0e0fcc92531d7b85a29f2a6352c12573ca"
name = "github.com/paypal/gorealis"
packages = [
".",
@ -79,8 +77,8 @@
"response",
]
pruneopts = ""
revision = "f27dc4a6abf5a2ad8675d7a4ba0059309631e473"
source = "github.com/rdelval/gorealis"
revision = "b776bd301d9018b86253711e789eb2376ce60d1c"
version = "v2.0.0"
[[projects]]
digest = "1:894aef961c056b6d85d12bac890bf60c44e99b46292888bfa66caf529f804457"
@ -210,6 +208,7 @@
"git.apache.org/thrift.git/lib/go/thrift",
"github.com/paypal/gorealis",
"github.com/paypal/gorealis/gen-go/apache/aurora",
"github.com/pkg/errors",
"github.com/sirupsen/logrus",
"github.com/spf13/cobra",
"github.com/spf13/pflag",

View file

@ -2,8 +2,7 @@ required = ["git.apache.org/thrift.git/lib/go/thrift"]
[[constraint]]
name = "github.com/paypal/gorealis"
branch = "drainSLA"
source = "github.com/rdelval/gorealis"
version = ">=2.0.0"
[[constraint]]
name = "github.com/spf13/cobra"
@ -14,6 +13,5 @@ required = ["git.apache.org/thrift.git/lib/go/thrift"]
revision = "62edee319679b6ceaec16de03b966102d2dea709"
[[constraint]]
name = "git.apache.org/thrift.git"
branch = "0.10.0-http-client-fix"
source = "github.com/rdelval/thrift"
name = "git.apache.org/thrift.git"
branch = "0.12.0"

View file

@ -119,7 +119,7 @@ func fetchTasks(cmd *cobra.Command, args []string) {
func fetchStatus(cmd *cobra.Command, args []string) {
log.Infof("Fetching maintenance status for %v \n", args)
_, result, err := client.MaintenanceStatus(args...)
result, err := client.MaintenanceStatus(args...)
if err != nil {
log.Fatalf("error: %+v\n", err)
}
@ -127,7 +127,7 @@ func fetchStatus(cmd *cobra.Command, args []string) {
if toJson {
fmt.Println(toJSON(result.Statuses))
} else {
for k := range result.Statuses {
for _, k := range result.GetStatuses() {
fmt.Printf("Result: %s:%s\n", k.Host, k.Mode)
}
}
@ -162,7 +162,7 @@ func fetchJobs(cmd *cobra.Command, args []string) {
*role = ""
}
_, result, err := client.GetJobs(*role)
result, err := client.GetJobs(*role)
if err != nil {
log.Fatalf("error: %+v\n", err)
@ -171,7 +171,7 @@ func fetchJobs(cmd *cobra.Command, args []string) {
if toJson {
var configSlice []*aurora.JobConfiguration
for config := range result.GetConfigs() {
for _, config := range result.GetConfigs() {
configSlice = append(configSlice, config)
}

View file

@ -1,8 +1,6 @@
package cmd
import (
"fmt"
"github.com/paypal/gorealis"
"github.com/spf13/cobra"
@ -53,20 +51,14 @@ func killJob(cmd *cobra.Command, args []string) {
Environment(*env).
Role(*role).
Name(*name)
resp, err := client.KillJob(job.JobKey())
err := client.KillJob(job.JobKey())
if err != nil {
log.Fatalln(err)
}
if ok, err := monitor.Instances(job.JobKey(), 0, 5, 50); !ok || err != nil {
if ok, err := client.InstancesMonitor(job.JobKey(), 0, 5, 50); !ok || err != nil {
log.Fatalln("Unable to kill all instances of job")
}
if toJson {
fmt.Println(toJSON(resp.GetResult_()))
} else {
fmt.Println(resp.GetResult_())
}
}
func killEntireCluster(cmd *cobra.Command, args []string) {

View file

@ -15,8 +15,7 @@ var username, password, zkAddr, schedAddr string
var env, role, name = new(string), new(string), new(string)
var ram, disk int64
var cpu float64
var client realis.Realis
var monitor *realis.Monitor
var client *realis.Client
var skipCertVerification bool
var caCertsPath string
var clientKey, clientCert string
@ -28,7 +27,7 @@ var percent float64
var count int64
var filename string
const australisVer = "v0.0.6"
const australisVer = "v0.0.7"
var monitorInterval, monitorTimeout time.Duration
@ -119,7 +118,7 @@ func connect(cmd *cobra.Command, args []string) {
realisOptions := []realis.ClientOption{realis.BasicAuth(username, password),
realis.ThriftJSON(),
realis.TimeoutMS(20000),
realis.Timeout(20 * time.Second),
realis.BackOff(realis.Backoff{
Steps: 2,
Duration: 10 * time.Second,
@ -141,16 +140,15 @@ func connect(cmd *cobra.Command, args []string) {
// Client certificate configuration if available
if clientKey != "" || clientCert != "" || caCertsPath != "" {
realisOptions = append(realisOptions,
realis.Certspath(caCertsPath),
realis.CertsPath(caCertsPath),
realis.ClientCerts(clientKey, clientCert),
realis.InsecureSkipVerify(skipCertVerification))
}
// Connect to Aurora Scheduler and create a client object
client, err = realis.NewRealisClient(realisOptions...)
client, err = realis.NewClient(realisOptions...)
if err != nil {
log.Fatal(err)
}
monitor = &realis.Monitor{Client: client}
}

View file

@ -72,15 +72,9 @@ func setQuota(cmd *cobra.Command, args []string) {
log.Println("Setting Quota resources for role.")
log.Println(args)
resp, err := client.SetQuota(*role, &cpu, &ram, &disk)
err := client.SetQuota(*role, &cpu, &ram, &disk)
if err != nil {
log.Fatal(err)
}
if toJson{
fmt.Println(toJSON(resp.GetResult_()))
} else {
fmt.Println(resp.GetResult_())
}
}

View file

@ -43,7 +43,7 @@ func init() {
// SLA Maintenance specific flags
startMaintenanceCmd.Flags().DurationVar(&monitorInterval,"interval", time.Second * 5, "Interval at which to poll scheduler.")
startMaintenanceCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 1, "Time after which the monitor will stop polling and throw an error.")
startMaintenanceCmd.Flags().DurationVar(&monitorTimeout,"timeout", time.Minute * 10, "Time after which the monitor will stop polling and throw an error.")
}
var startCmd = &cobra.Command{
@ -102,7 +102,7 @@ expects a space separated list of hosts to place into maintenance mode.`,
func drain(cmd *cobra.Command, args []string) {
log.Infoln("Setting hosts to DRAINING")
log.Infoln(args)
_, result, err := client.DrainHosts(args...)
result, err := client.DrainHosts(args...)
if err != nil {
log.Fatalf("error: %+v\n", err)
}
@ -110,16 +110,16 @@ func drain(cmd *cobra.Command, args []string) {
log.Debugln(result)
// Monitor change to DRAINING and DRAINED mode
hostResult, err := monitor.HostMaintenance(
hostResult, err := client.HostMaintenanceMonitor(
args,
[]aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED},
int(monitorInterval.Seconds()),
int(monitorTimeout.Seconds()))
monitorInterval,
monitorTimeout)
maintenanceMonitorPrint(hostResult, []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED})
if err != nil {
log.Fatalln("error: %+v", err)
log.Fatalln(err)
}
}
@ -133,11 +133,11 @@ func slaDrain(policy *aurora.SlaPolicy, hosts ...string) {
log.Debugln(result)
// Monitor change to DRAINING and DRAINED mode
hostResult, err := monitor.HostMaintenance(
hostResult, err := client.HostMaintenanceMonitor(
hosts,
[]aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED},
int(monitorInterval.Seconds()),
int(monitorTimeout.Seconds()))
monitorInterval,
monitorTimeout)
maintenanceMonitorPrint(hostResult, []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED})
@ -167,7 +167,7 @@ func SLAPercentageDrain(cmd *cobra.Command, args []string) {
func maintenance(cmd *cobra.Command, args []string) {
log.Infoln("Setting hosts to Maintenance mode")
log.Infoln(args)
_, result, err := client.StartMaintenance(args...)
result, err := client.StartMaintenance(args...)
if err != nil {
log.Fatalf("error: %+v\n", err)
}
@ -175,11 +175,11 @@ func maintenance(cmd *cobra.Command, args []string) {
log.Debugln(result)
// Monitor change to DRAINING and DRAINED mode
hostResult, err := monitor.HostMaintenance(
hostResult, err := client.HostMaintenanceMonitor(
args,
[]aurora.MaintenanceMode{aurora.MaintenanceMode_SCHEDULED},
int(monitorInterval.Seconds()),
int(monitorTimeout.Seconds()))
monitorInterval,
monitorTimeout)
maintenanceMonitorPrint(hostResult, []aurora.MaintenanceMode{aurora.MaintenanceMode_SCHEDULED})

View file

@ -1,7 +1,6 @@
package cmd
import (
"fmt"
"github.com/paypal/gorealis/gen-go/apache/aurora"
"github.com/spf13/cobra"
"time"
@ -48,7 +47,7 @@ var stopUpdateCmd = &cobra.Command{
func endMaintenance(cmd *cobra.Command, args []string) {
log.Println("Setting hosts to NONE maintenance status.")
log.Println(args)
_, result, err := client.EndMaintenance(args...)
result, err := client.EndMaintenance(args...)
if err != nil {
log.Fatalf("error: %+v\n", err)
}
@ -56,12 +55,11 @@ func endMaintenance(cmd *cobra.Command, args []string) {
log.Debugln(result)
// Monitor change to NONE mode
hostResult, err := monitor.HostMaintenance(
hostResult, err := client.HostMaintenanceMonitor(
args,
[]aurora.MaintenanceMode{aurora.MaintenanceMode_NONE},
int(monitorInterval.Seconds()),
int(monitorTimeout.Seconds()))
monitorInterval,
monitorTimeout)
maintenanceMonitorPrint(hostResult,[]aurora.MaintenanceMode{aurora.MaintenanceMode_NONE})
@ -78,7 +76,7 @@ func stopUpdate(cmd *cobra.Command, args []string) {
log.Infof("Stopping (aborting) update [%s/%s/%s] %s\n", *env, *role, *name, args[0])
resp, err := client.AbortJobUpdate(aurora.JobUpdateKey{
err := client.AbortJobUpdate(aurora.JobUpdateKey{
Job: &aurora.JobKey{Environment: *env, Role: *role, Name: *name},
ID: args[0],
},
@ -87,10 +85,4 @@ func stopUpdate(cmd *cobra.Command, args []string) {
if err != nil {
log.Fatalln(err)
}
if toJson{
fmt.Println(toJSON(resp.GetResult_()))
} else {
fmt.Println(resp.GetResult_())
}
}

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
australis (0.0.7) unstable; urgency=medium
* Upgraded australis to gorealis v2.
-- Renan DelValle <renanidelvalle@gmail.com> Wed, 26 Dec 2018 15:10:00 -0700
australis (0.0.6) unstable; urgency=medium
* Added auto-completion to the deb file.

9
vendor/git.apache.org/thrift.git/.eslintignore generated vendored Normal file
View file

@ -0,0 +1,9 @@
# TODO: Use eslint on js lib and generated code
# Ignore lib/js for now, which uses jshint currently
lib/js/*
# Ignore all generated code for now
**/gen-*
# Don't lint nested node_modules
**/node_modules

24
vendor/git.apache.org/thrift.git/.eslintrc.json generated vendored Normal file
View file

@ -0,0 +1,24 @@
{
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 2017
},
"rules": {
"no-console": "off",
"no-var": "error",
"prefer-const": "error",
"no-constant-condition": [
"error",
{
"checkLoops": false
}
]
}
}

59
vendor/git.apache.org/thrift.git/.github/stale.yml generated vendored Normal file
View file

@ -0,0 +1,59 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 60
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 7
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- Do Not Merge
- blocked
- pinned
- security
- "[Status] Maybe Later"
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Label to use when marking as stale
staleLabel: wontfix
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed in 7 days if no further activity occurs.
Thank you for your contributions.
# Comment to post when removing the stale label.
unmarkComment: >
This issue is no longer stale.
Thank you for your contributions.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
This issue has been automatically closed due to inactivity.
Thank you for your contributions.
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
# Limit to only `issues` or `pulls`
# only: issues
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.
# issues:
# exemptLabels:
# - confirmed

View file

@ -21,28 +21,41 @@
*.swp
*.hi
*~
tags
.*project
.classpath
.dub
.settings
.checkstyle
junit*.properties
.idea
*.iml
*.ipr
*.iws
gen-*
Makefile
Makefile.in
aclocal.m4
acinclude.m4
apache-thrift-test-library
autom4te.cache
cmake-*
dub.selections.json
libapache-thrift.a
node_modules
compile
test-driver
erl_crash.dump
project.lock.json
.sonar
.DS_Store
.svn
.vagrant
.vscode
.vs
/contrib/.vagrant/
/aclocal/libtool.m4
/aclocal/lt*.m4
/autoscan.log
@ -77,6 +90,7 @@ erl_crash.dump
/configure
/configure.lineno
/configure.scan
/contrib/.vagrant/
/contrib/fb303/config.cache
/contrib/fb303/config.log
/contrib/fb303/config.status
@ -91,6 +105,13 @@ erl_crash.dump
/contrib/fb303/py/fb303/ttypes.py
/depcomp
/install-sh
/lib/cl/backport-update.zip
/lib/cl/lib
/lib/cl/run-tests
/lib/cl/quicklisp.lisp
/lib/cl/externals/
/lib/cl/run-tests
/lib/cl/quicklisp/
/lib/cpp/Debug/
/lib/cpp/Debug-mt/
/lib/cpp/Release/
@ -101,6 +122,7 @@ erl_crash.dump
/lib/cpp/src/thrift/stamp-h2
/lib/cpp/test/Benchmark
/lib/cpp/test/AllProtocolsTest
/lib/cpp/test/AnnotationTest
/lib/cpp/test/DebugProtoTest
/lib/cpp/test/DenseProtoTest
/lib/cpp/test/EnumTest
@ -108,12 +130,14 @@ erl_crash.dump
/lib/cpp/test/OptionalRequiredTest
/lib/cpp/test/SecurityTest
/lib/cpp/test/SpecializationTest
/lib/cpp/test/ReflectionTest
/lib/cpp/test/RecursiveTest
/lib/cpp/test/ReflectionTest
/lib/cpp/test/RenderedDoubleConstantsTest
/lib/cpp/test/TFDTransportTest
/lib/cpp/test/TFileTransportTest
/lib/cpp/test/TInterruptTest
/lib/cpp/test/TNonblockingServerTest
/lib/cpp/test/TNonblockingSSLServerTest
/lib/cpp/test/TPipedTransportTest
/lib/cpp/test/TServerIntegrationTest
/lib/cpp/test/TSocketInterruptTest
@ -149,6 +173,7 @@ erl_crash.dump
/lib/c_glib/test/testframedtransport
/lib/c_glib/test/testmemorybuffer
/lib/c_glib/test/testoptionalrequired
/lib/c_glib/test/testtransportsslsocket
/lib/c_glib/test/testsimpleserver
/lib/c_glib/test/teststruct
/lib/c_glib/test/testthrifttest
@ -175,46 +200,35 @@ erl_crash.dump
/lib/dart/**/packages
/lib/dart/**/.pub/
/lib/dart/**/pubspec.lock
/lib/delphi/src/*.dcu
/lib/delphi/test/*.identcache
/lib/delphi/test/*.local
/lib/delphi/test/*.dcu
/lib/delphi/test/*.2007
/lib/delphi/test/*.dproj
/lib/delphi/test/*.dproj
/lib/delphi/test/codegen/*.bat
/lib/delphi/test/skip/*.local
/lib/delphi/test/skip/*.identcache
/lib/delphi/test/skip/*.identcache
/lib/delphi/test/skip/*.dproj
/lib/delphi/test/skip/*.dproj
/lib/delphi/test/skip/*.2007
/lib/delphi/test/serializer/*.identcache
/lib/delphi/test/serializer/*.dproj
/lib/delphi/test/serializer/*.local
/lib/delphi/test/serializer/*.2007
/lib/delphi/test/serializer/*.dcu
/lib/delphi/test/multiplexed/*.dproj
/lib/delphi/test/multiplexed/*.2007
/lib/delphi/test/multiplexed/*.local
/lib/delphi/test/multiplexed/*.identcache
/lib/delphi/test/multiplexed/*.dcu
/lib/delphi/test/typeregistry/*.2007
/lib/delphi/test/typeregistry/*.dproj
/lib/delphi/test/typeregistry/*.identcache
/lib/delphi/test/typeregistry/*.local
/lib/delphi/test/typeregistry/*.dcu
/lib/erl/.generated
/lib/delphi/test/skip/*.request
/lib/delphi/test/skip/*.response
/lib/delphi/**/*.identcache
/lib/delphi/**/*.local
/lib/delphi/**/*.dcu
/lib/delphi/**/*.2007
/lib/delphi/**/*.dproj
/lib/delphi/**/codegen/*.bat
/lib/erl/.eunit
/lib/erl/ebin
/lib/erl/.generated
/lib/erl/.rebar/
/lib/erl/deps/
/lib/erl/ebin
/lib/erl/src/thrift.app.src
/lib/erl/test/*.hrl
/lib/erl/test/*.beam
/lib/erl/test/*.hrl
/lib/erl/test/Thrift_omit_without.thrift
/lib/haxe/test/bin
/lib/haxe/test/data.tmp
/lib/hs/dist
/lib/java/.gradle
/lib/java/android/.gradle
/lib/java/build
/lib/java/target
/lib/js/dist
/lib/js/doc
/lib/js/test/build
/lib/netcore/**/bin
/lib/netcore/**/obj
/lib/nodejs/coverage
/lib/nodejs/node_modules/
/lib/perl/MANIFEST
@ -238,6 +252,7 @@ erl_crash.dump
/lib/php/src/ext/thrift_protocol/build/
/lib/php/src/ext/thrift_protocol/config.*
/lib/php/src/ext/thrift_protocol/configure
/lib/php/src/ext/thrift_protocol/configure.ac
/lib/php/src/ext/thrift_protocol/configure.in
/lib/php/src/ext/thrift_protocol/install-sh
/lib/php/src/ext/thrift_protocol/libtool
@ -254,21 +269,41 @@ erl_crash.dump
/lib/php/test/packages/
/lib/py/dist/
/lib/erl/logs/
/lib/go/pkg
/lib/go/src
/lib/go/test/gopath/
/lib/go/test/ThriftTest.thrift
/lib/rs/target/
/lib/rs/Cargo.lock
/lib/rs/test/Cargo.lock
/lib/rs/test/target/
/lib/rs/test/bin/
/lib/rs/test/src/base_one.rs
/lib/rs/test/src/base_two.rs
/lib/rs/test/src/midlayer.rs
/lib/rs/test/src/recursive.rs
/lib/rs/test/src/ultimate.rs
/lib/rs/*.iml
/lib/rs/**/*.iml
/libtool
/ltmain.sh
/missing
/node_modules/
/vendor/
/composer.lock
/stamp-h1
/test/features/results.json
/test/results.json
/test/c_glib/test_client
/test/c_glib/test_server
/test/cl/TestServer
/test/cl/TestClient
/test/cpp/StressTest
/test/cpp/StressTestNonBlocking
/test/cpp/TestClient
/test/cpp/TestServer
/test/csharp/obj
/test/csharp/bin
/test/dart/**/.packages
/test/dart/**/packages
/test/dart/**/.pub/
@ -276,20 +311,45 @@ erl_crash.dump
/test/log/
/test/test.log
/test/erl/.generated
/test/erl/.rebar
/test/erl/ebin
/test/go/bin/
/test/go/ThriftTest.thrift
/test/go/gopath
/test/go/pkg/
/test/go/src/code.google.com/
/test/go/src/common/mock_handler.go
/test/go/src/github.com/golang/
/test/go/src/golang.org/
/test/go/src/gen/
/test/go/src/thrift
/test/haxe/bin
/test/hs/TestClient
/test/hs/TestServer
/test/php/php_ext_dir/
/test/py.twisted/_trial_temp/
/test/rb/Gemfile.lock
/test/netcore/**/bin
/test/netcore/**/obj
/test/netcore/Thrift
/test/php/php_ext_dir/
/test/rs/Cargo.lock
/test/rs/src/thrift_test.rs
/test/rs/bin/
/test/rs/target/
/test/rs/*.iml
/test/rs/**/*.iml
/lib/cl/backport-update.zip
/lib/cl/lib
/tutorial/cl/quicklisp.lisp
/tutorial/cl/externals/
/tutorial/cl/quicklisp/
/tutorial/cl/TutorialClient
/tutorial/cl/TutorialServer
/tutorial/cl/backport-update.zip
/tutorial/cl/lib/
/tutorial/cl/shared-implementation.fasl
/tutorial/cl/tutorial-implementation.fasl
/tutorial/cpp/TutorialClient
/tutorial/cpp/TutorialServer
/tutorial/c_glib/tutorial_client
@ -305,22 +365,31 @@ erl_crash.dump
/tutorial/dart/**/packages
/tutorial/dart/**/.pub/
/tutorial/dart/**/pubspec.lock
/tutorial/delphi/*.dsk
/tutorial/delphi/*.local
/tutorial/delphi/*.tvsconfig
/tutorial/delphi/DelphiClient/dcu
/tutorial/delphi/DelphiServer/dcu
/tutorial/delphi/DelphiClient/*.local
/tutorial/delphi/DelphiClient/*.identcache
/tutorial/delphi/DelphiServer/*.identcache
/tutorial/delphi/DelphiServer/*.local
/tutorial/delphi/**/*.dsk
/tutorial/delphi/**/*.local
/tutorial/delphi/**/*.tvsconfig
/tutorial/delphi/**/dcu
/tutorial/delphi/**/*.local
/tutorial/delphi/**/*.identcache
/tutorial/go/gopath
/tutorial/go/go-tutorial
/tutorial/go/calculator-remote
/tutorial/go/src/shared
/tutorial/go/src/tutorial
/tutorial/go/src/git.apache.org
/tutorial/go/src/golang.org
/tutorial/haxe/bin
/tutorial/hs/dist/
/tutorial/java/build/
/tutorial/js/build/
/tutorial/netcore/**/bin
/tutorial/netcore/**/obj
/tutorial/netcore/Thrift
/tutorial/rs/*.iml
/tutorial/rs/src/shared.rs
/tutorial/rs/src/tutorial.rs
/tutorial/rs/bin
/tutorial/rs/target
/tutorial/rs/Cargo.lock
/ylwrap

64
vendor/git.apache.org/thrift.git/.rustfmt.toml generated vendored Normal file
View file

@ -0,0 +1,64 @@
max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = "Auto"
use_small_heuristics = "Default"
indent_style = "Block"
wrap_comments = false
format_doc_comments = false
comment_width = 80
normalize_comments = false
normalize_doc_attributes = false
license_template_path = ""
format_strings = false
format_macro_matchers = false
format_macro_bodies = true
empty_item_single_line = true
struct_lit_single_line = true
fn_single_line = false
where_single_line = false
imports_indent = "Block"
imports_layout = "Mixed"
merge_imports = false
reorder_imports = true
reorder_modules = true
reorder_impl_items = false
type_punctuation_density = "Wide"
space_before_colon = false
space_after_colon = true
spaces_around_ranges = false
binop_separator = "Front"
remove_nested_parens = true
combine_control_expr = true
overflow_delimited_expr = false
struct_field_align_threshold = 0
enum_discrim_align_threshold = 0
match_arm_blocks = true
force_multiline_blocks = false
fn_args_density = "Tall"
brace_style = "SameLineWhere"
control_brace_style = "AlwaysSameLine"
trailing_semicolon = true
trailing_comma = "Vertical"
match_block_trailing_comma = false
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
edition = "2015"
merge_derives = true
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true
condense_wildcard_suffixes = false
color = "Auto"
required_version = "1.0.0"
unstable_features = false
disable_all_formatting = false
skip_children = false
hide_parse_errors = false
error_on_line_overflow = false
error_on_unformatted = false
report_todo = "Never"
report_fixme = "Never"
ignore = []
emit_mode = "Files"
make_backup = false

View file

@ -19,181 +19,163 @@
# build Apache Thrift on Travis CI - https://travis-ci.org/
#
# Docker Integration
# see: build/docker/README.md
#
sudo: required
dist: trusty
language: cpp
services:
- docker
install:
- (travis_wait ./build/docker/check_unmodified.sh $DISTRO && touch .unmodified) || true
- if [ ! -f .unmodified ]; then travis_retry travis_wait docker build -q -t thrift-build:$DISTRO build/docker/$DISTRO; fi
- if [[ `uname` == "Linux" ]]; then build/docker/refresh.sh; fi
script:
- docker run --net=host -e BUILD_LIBS="$BUILD_LIBS" $BUILD_ENV -v $(pwd):/thrift/src -it thrift-build:$DISTRO build/docker/scripts/$SCRIPT $BUILD_ARG
stages:
- docker # docker images
- thrift # thrift build jobs
env:
global:
- TEST_NAME=""
- SCRIPT="cmake.sh"
- BUILD_ARG=""
- BUILD_ENV="-e CC=clang -e CXX=clang++"
- DISTRO=ubuntu
- BUILD_ENV="-e CC=gcc -e CXX=g++ -e THRIFT_CROSSTEST_CONCURRENCY=4"
- DISTRO=ubuntu-bionic
- BUILD_LIBS="CPP C_GLIB HASKELL JAVA PYTHON TESTING TUTORIALS" # only meaningful for CMake builds
- TRAVIS_BUILD_STAGE=test
# DOCKER_REPO (this works for all builds as a source for docker images - you can override for fork builds in your Travis settings)
- DOCKER_REPO="thrift/thrift-build"
# DOCKER_USER (provide in your Travis settings if you want to build and update docker images once, instead of on every job)
# DOCKER_PASS (same)
matrix:
- TEST_NAME="Cross Language Tests (Binary and Header Protocols)"
SCRIPT="cross-test.sh"
BUILD_ARG="-'(binary|header)'"
BUILD_ENV="-e CC=clang -e CXX=clang++ -e THRIFT_CROSSTEST_CONCURRENCY=4"
- TEST_NAME="Cross Language Tests (Debian) (Binary and Header Protocols)"
SCRIPT="cross-test.sh"
BUILD_ARG="-'(binary|header)'"
BUILD_ENV="-e CC=clang -e CXX=clang++ -e THRIFT_CROSSTEST_CONCURRENCY=4"
DISTRO=debian
- TEST_NAME="Cross Language Tests (Compact and JSON Protocols)"
SCRIPT="cross-test.sh"
BUILD_ARG="-'(compact|json)'"
BUILD_ENV="-e CC=clang -e CXX=clang++ -e THRIFT_CROSSTEST_CONCURRENCY=4"
- TEST_NAME="Cross Language Tests (Debian) (Compact and JSON Protocols)"
SCRIPT="cross-test.sh"
BUILD_ARG="-'(compact|json)'"
BUILD_ENV="-e CC=clang -e CXX=clang++ -e THRIFT_CROSSTEST_CONCURRENCY=4"
DISTRO=debian
# TODO: Remove them once migrated to CMake
# Autotools builds
- TEST_NAME="C C++ C# D Erlang Haxe Go (automake)"
SCRIPT="autotools.sh"
BUILD_ARG="--without-dart --without-haskell --without-java --without-lua --without-nodejs --without-perl --without-php --without-php_extension --without-python --without-ruby"
- TEST_NAME="C C++ - GCC (automake)"
SCRIPT="autotools.sh"
BUILD_ARG="--without-csharp --without-java --without-erlang --without-nodejs --without-lua --without-python --without-perl --without-php --without-php_extension --without-dart --without-ruby --without-haskell --without-go --without-haxe --without-d"
BUILD_ENV="-e CC=gcc -e CXX=g++"
- TEST_NAME="Java Lua PHP Ruby Dart (automake)"
SCRIPT="autotools.sh"
BUILD_ARG="--without-cpp --without-haskell --without-c_glib --without-csharp --without-d --without-erlang --without-go --without-haxe --without-nodejs --without-python --without-perl"
# These are flaky (due to cabal and npm network/server failures) and also have lengthy output
- TEST_NAME="Haskell Node.js Python Perl (automake)"
SCRIPT="autotools.sh"
BUILD_ARG="--without-cpp --without-c_glib --without-csharp --without-d --without-dart --without-erlang --without-go --without-haxe --without-java --without-lua --without-php --without-php_extension --without-ruby"
# CMake build
- TEST_NAME="All"
- TEST_NAME="All (Debian)"
DISTRO=debian
- TEST_NAME="C C++ - GCC"
BUILD_LIBS="CPP C_GLIB TESTING TUTORIALS"
BUILD_ARG="-DWITH_PYTHON=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
BUILD_ENV="-e CC=gcc -e CXX=g++"
- TEST_NAME="C++ (Boost Thread)"
BUILD_LIBS="CPP TESTING TUTORIALS"
BUILD_ARG="-DWITH_BOOSTTHREADS=ON -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
- TEST_NAME="C++ (Boost Thread - GCC)"
BUILD_LIBS="CPP TESTING TUTORIALS"
BUILD_ARG="-DWITH_BOOSTTHREADS=ON -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
BUILD_ENV="-e CC=gcc -e CXX=g++"
- TEST_NAME="C++ (Std Thread)"
BUILD_LIBS="CPP TESTING TUTORIALS"
BUILD_ARG="-DWITH_STDTHREADS=ON -DCMAKE_CXX_FLAGS='-std=c++11' -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
- TEST_NAME="C++ (Std Thread - GCC)"
BUILD_LIBS="CPP TESTING TUTORIALS"
BUILD_ARG="-DWITH_STDTHREADS=ON -DCMAKE_CXX_FLAGS='-std=c++11' -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
BUILD_ENV="-e CC=gcc -e CXX=g++"
- TEST_NAME="Compiler (mingw)"
BUILD_LIBS=""
BUILD_ARG="-DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF"
BUILD_ENV=""
- TEST_NAME="All - GCC (CentOS)"
BUILD_ENV="-e CC=gcc -e CXX=g++"
DISTRO=centos
- TEST_NAME="C C++ - Clang (CentOS)"
BUILD_LIBS="CPP C_GLIB TESTING TUTORIALS"
BUILD_ARG="-DWITH_PYTHON=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
DISTRO=centos
- TEST_NAME="Python 2.6 (CentOS 6)"
BUILD_LIBS="PYTHON TESTING TUTORIALS"
BUILD_ARG="-DWITH_PYTHON=ON -DWITH_CPP=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
BUILD_ENV="-e CC=gcc -e CXX=g++"
DISTRO=centos6
# Distribution
- TEST_NAME="make dist"
SCRIPT="make-dist.sh"
BUILD_ENV="-e CC=gcc -e CXX=g++"
- TEST_NAME="Debian Packages"
SCRIPT="dpkg.sh"
BUILD_ENV="-e CC=gcc -e CXX=g++"
- TEST_NAME="make dist (Debian)"
SCRIPT="make-dist.sh"
BUILD_ENV="-e CC=gcc -e CXX=g++"
DISTRO=debian
- TEST_NAME="Debian Packages (Debian)"
SCRIPT="dpkg.sh"
BUILD_ENV="-e CC=gcc -e CXX=g++"
DISTRO=debian
matrix:
jobs:
include:
# ========================= stage: docker =========================
- stage: docker
script: true
env:
- JOB="Docker Build ubuntu-xenial 16.04 LTS"
- DISTRO=ubuntu-xenial
- TRAVIS_BUILD_STAGE=docker
- script: true
env:
- JOB="Docker Build ubuntu-bionic 18.04 LTS"
- DISTRO=ubuntu-bionic
- TRAVIS_BUILD_STAGE=docker
# ========================= stage: thrift =======================
# ------------------------- phase: cross ------------------------
# apache/thrift official PR builds can exceed 50 minutes per job so combine all cross tests
- stage: thrift
script: build/docker/run.sh
if: repo = apache/thrift
env:
- JOB="Cross Language Tests"
- SCRIPT="cross-test.sh"
# fork based PR builds cannot exceed 50 minutes per job
- stage: thrift
script: build/docker/run.sh
if: repo != apache/thrift
env:
- JOB="Cross Language Tests (Binary Protocol)"
- SCRIPT="cross-test.sh"
- BUILD_ARG="-'(binary)'"
- stage: thrift
script: build/docker/run.sh
if: repo != apache/thrift
env:
- JOB="Cross Language Tests (Header, JSON Protocols)"
- SCRIPT="cross-test.sh"
- BUILD_ARG="-'(header|json)'"
- stage: thrift
script: build/docker/run.sh
if: repo != apache/thrift
env:
- JOB="Cross Language Tests (Compact and Multiplexed Protocols)"
- SCRIPT="cross-test.sh"
- BUILD_ARG="-'(compact|multiplexed)'"
# ------------------------- phase: sca --------------------------
# QA jobs for code analytics and metrics
#
# C/C++ static code analysis with cppcheck
# add --error-exitcode=1 to --enable=all as soon as everything is fixed
#
# Python code style check with flake8
#
# search for TODO etc within source tree
# some statistics about the code base
# some info about the build machine
- env: TEST_NAME="cppcheck, flake8, TODO FIXME HACK, LoC and system info"
install:
- travis_retry sudo apt-get update
- travis_retry sudo apt-get install -ym cppcheck sloccount python-flake8
script:
# Compiler cppcheck (All)
- cppcheck --force --quiet --inline-suppr --enable=all -j2 compiler/cpp/src
# C++ cppcheck (All)
- cppcheck --force --quiet --inline-suppr --enable=all -j2 lib/cpp/src lib/cpp/test test/cpp tutorial/cpp
# C Glib cppcheck (All)
- cppcheck --force --quiet --inline-suppr --enable=all -j2 lib/c_glib/src lib/c_glib/test test/c_glib/src tutorial/c_glib
# Silent error checks
- cppcheck --force --quiet --inline-suppr --error-exitcode=1 -j2 compiler/cpp/src
- cppcheck --force --quiet --inline-suppr --error-exitcode=1 -j2 lib/cpp/src lib/cpp/test test/cpp tutorial/cpp
- cppcheck --force --quiet --inline-suppr --error-exitcode=1 -j2 lib/c_glib/src lib/c_glib/test test/c_glib/src tutorial/c_glib
# Python code style
- flake8 --ignore=E501 lib/py
- flake8 tutorial/py
- flake8 --ignore=E501 test/py
- flake8 test/py.twisted
- flake8 test/py.tornado
- flake8 --ignore=E501 test/test.py
- flake8 --ignore=E501 test/crossrunner
- flake8 test/features
# TODO etc
- grep -r TODO *
- grep -r FIXME *
- grep -r HACK *
# LoC
- sloccount .
# System Info
- dpkg -l
- uname -a
- stage: thrift
script: build/docker/run.sh
env:
- JOB="Static Code Analysis"
- SCRIPT="sca.sh"
# C and C++ undefined behavior.
# A binary crashes if undefined behavior occurs and produces a stack trace.
# python is disabled, see: THRIFT-4360
- script: build/docker/run.sh
env:
- JOB="UBSan"
- SCRIPT="ubsan.sh"
- BUILD_ARG="--without-python --without-py3"
# ------------------------- phase: autotools --------------------
# TODO: Remove them once migrated to CMake
- script: build/docker/run.sh
env:
- JOB="Autotools (Ubuntu Bionic)"
- SCRIPT="autotools.sh"
- script: build/docker/run.sh
env:
- JOB="Autotools (Ubuntu Xenial)"
- DISTRO=ubuntu-xenial
- SCRIPT="autotools.sh"
# ------------------------- phase: cmake ------------------------
- script: build/docker/run.sh
env:
- JOB="CMake"
# C++ specific options: compiler plug-in, threading model
- script: build/docker/run.sh
env:
- JOB="C++98 (Boost Thread)"
- SCRIPT="cmake.sh"
- BUILD_LIBS="CPP TESTING TUTORIALS"
- BUILD_ARG="-DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF --DWITH_BOOSTTHREADS=ON -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
- BUILD_ENV="-e CC=clang -e CXX=clang++"
- script: build/docker/run.sh
env:
- JOB="C++ (Std Thread) and Plugin"
- SCRIPT="cmake.sh"
- BUILD_LIBS="CPP TESTING TUTORIALS"
- BUILD_ARG="-DWITH_PLUGIN=ON -DWITH_STDTHREADS=ON -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
- BUILD_ENV="-e CC=clang -e CXX=clang++"
# ------------------------- phase: dist -------------------------
- script: build/docker/run.sh
env:
- JOB="make dist"
- SCRIPT="make-dist.sh"
- script: build/docker/run.sh
env:
- JOB="Debian Packages"
- SCRIPT="dpkg.sh"
# ------------------------- phase: coverity ---------------------
# We build the coverity scan build once monthly using a travis cron job
- if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (master)) AND (type IN (cron))
script: build/docker/run.sh
env:
- JOB="Coverity Scan"
- SCRIPT="covscan.sh"
### ------------------------- phase: osx --------------------------
# disabled due to the time delays it imposes on build jobs
# - os: osx
# osx_image: xcode9
# script: build/docker/scripts/autotools.sh

View file

@ -1,5 +1,552 @@
Apache Thrift Changelog
================================================================================
Thrift 0.12.0
--------------------------------------------------------------------------------
## New Languages
* Common LISP (cl)
* Swift
* Typescript (nodets)
## Deprecated Languages
* Cocoa
## Breaking Changes (since 0.11.0)
* [THRIFT-4529] - Rust enum variants are now camel-cased instead of uppercased to conform to Rust naming conventions
* [THRIFT-4448] - Support for golang 1.6 and earlier has been dropped.
* [THRIFT-4474] - PHP now uses the PSR-4 loader by default instead of class maps.
* [THRIFT-4532] - method signatures changed in the compiler's t_oop_generator.
* [THRIFT-4648] - The C (GLib) compiler's handling of namespaces has been improved.
## Known Issues (Blocker or Critical)
* [THRIFT-4037] - build: use a single build system for thrift
* [THRIFT-4119] - build: bootstrap.sh is missing from source tarball
* [THRIFT-3289] - csharp: socket exhaustion in csharp implementation
* [THRIFT-3029] - cocoa: Getters for fields defined with uppercase names do not work
* [THRIFT-3325] - cocoa: Extended services aren't subclasses in generated Cocoa
* [THRIFT-4116] - cocoa: Thrift de-capitalizes the name of IsSet property in Cocoa
* [THRIFT-3877] - cpp: the http implementation is not standard; interop with other languages is spotty at best
* [THRIFT-4180] - cpp: Impossible to build Thrift C++ library for Android (NDK)
* [THRIFT-4384] - cpp: Using multiple async services simultaneously is not thread-safe
* [THRIFT-3108] - haskell: Defaulted struct parameters on a service generates invalid Haskell
* [THRIFT-3990] - nodejs: Exception swallowed by deserialization function
* [THRIFT-4214] - nodejs: map<i64,value> key treated as hex value in JavaScript
* [THRIFT-4602] - nodejs: ERROR in ./node_modules/thrift/lib/nodejs/lib/thrift/connection.js Module not found: Error: Can't resolve 'child_process'
* [THRIFT-4639] - nodejs: Sequence numbering for multiplexed protocol broken
* [THRIFT-1310] - php: sequence and reconnection management issues
* [THRIFT-1538] - php: Error during deserialization int64 on 32-bit architecture
* [THRIFT-1580] - php: thrift type i64 java to php serialize/deserealize not working
* [THRIFT-1950] - php: PHP gets stuck in infinite loop
* [THRIFT-2954] - python: sending int or float in a double field breaks the connection
* [THRIFT-4080] - python: unix sockets can get stuck forever
* [THRIFT-4281] - python: generated code is out of order and causes load issues
* [THRIFT-4677] - py3: UnicodeDecideError in Python3
## Build Process
* [THRIFT-4308] - D language docker images need demios for libevent and openssl fixed to re-enable make cross on dlang
* [THRIFT-4579] - Use Ubuntu Bionic (18.04 LTS) for CI builds instead of Artful (17.10)
* [THRIFT-4508] - Define CI operating system coverage rules for the project and (hopefully) simplify CI a little more
* [THRIFT-4397] - ubuntu install instructions broken on 16.04
* [THRIFT-4545] - Appveyor builds are failing due to a haskell / cabal update in chocolatey
* [THRIFT-4452] - optimize Dockerfile (only onetime apt-get update)
* [THRIFT-4440] - rm `build/docker/ubuntu-trusty/Dockerfile.orig`
* [THRIFT-4352] - Ubuntu Artful doesn't appear to be compatible with Thrift and Haxe 3.4.2
* [THRIFT-4666] - DLang Client Pool Test fails sporadically
* [THRIFT-4676] - CL tutorial build fails sporadically
* [THRIFT-4456] - Make haxelib download quiet so it doesn't blow up the build log
* [THRIFT-4605] - bootstrap.sh fails if automake=1.16.1
## c_glib
* [THRIFT-4648] - The C (GLib) compiler's handling of namespaces has been improved.
* [THRIFT-4622] - glibC compilation issue
* [THRIFT-4671] - c glib is unable to handle client close unexpectedly
## cl (new language support in 0.12.0)
* [THRIFT-82] - Common Lisp support
## csharp
* [THRIFT-4558] - reserved Csharp keywords are not escaped in some cases
* [THRIFT-4637] - C# async mode generates incorrect code with inherited services
* [THRIFT-4672] - IAsyncResult style methods not being supported by certain transports leads to issues in mixed ISync/IAsync use cases
* [THRIFT-4539] - Allow TBufferedTransport to be used as base class
* [THRIFT-4535] - XML docs; code cleanup (tabs->spaces; String->string)
* [THRIFT-4492] - protected ExceptionType type member of TApplicationException cannot be accessed
* [THRIFT-4446] - JSONProtocol Base64 Encoding Trims Padding
* [THRIFT-4455] - Missing dispose calls in ThreadedServer & ThreadpoolServer
* [THRIFT-4609] - keep InnerException wherever appropriate
* [THRIFT-4673] - IAsyncResult not supported by layered transports (buffered/framed)
## cpp
* [THRIFT-4476] - Typecasting problem on list items
* [THRIFT-4465] - TNonblockingServer throwing THRIFT LOGGER: TConnection::workSocket(): THRIFT_EAGAIN (unavailable resources)
* [THRIFT-4680] - TBufferTransports.h does not compile under Visual Studio 2017
* [THRIFT-4618] - TNonblockingServer crash because of limitation of select()
* [THRIFT-4620] - TZlibTransport.cpp doesn't ensure that there is enough space for the zlib flush marker in the buffer.
* [THRIFT-4571] - ZeroMQ contrib library needs a refresh
* [THRIFT-4559] - TSSLServerSocket incorrectly prints errors
* [THRIFT-4578] - Move `TAsyncProtocolProcessor` into main thrift library
* [THRIFT-4418] - evhttp_connection_new is deprecated; use evhttp_connection_base_new
## compiler
* [THRIFT-4644] - Compiler cannot be compiled on macOS(maybe also on other platforms with clang)
* [THRIFT-4531] - Thrift generates wrong Python code for immutable structures with optional members
* [THRIFT-4513] - thrift generated code is not stable for constants
* [THRIFT-4532] - Avoid updating Thrift compiler generated code if the output has not changed
* [THRIFT-4400] - Visual Studio Compiler project should link runtime statically in release builds
* [THRIFT-4399] - plugin.thrift t_const_value is not used as a union in C++ code -- fix this
* [THRIFT-4496] - Dealing with language keywords in Thrift (e.g. service method names)
* [THRIFT-4393] - repeated runs of compiler produce different binary output at plugin interface
## dlang
* [THRIFT-4478] - Thrift will not build with dlang 2.078 or later
* [THRIFT-4503] - dlang servers logError on normal client disconnection
* [THRIFT-4308] - D language docker images need demios for libevent and openssl fixed to re-enable make cross on dlang
## dart
* [THRIFT-4646] - Effective Dart and Exceptions
* [THRIFT-4439] - Shouldn't download dart.deb directly.
## delphi
* [THRIFT-4562] - Calling wrong exception CTOR leads to "call failed: unknown result" instead of the real exception being thrown
* [THRIFT-4554] - uncompileable code with member names that are also types under specific conditions
* [THRIFT-4422] - Add Async implementation via IFuture
* [THRIFT-4485] - Possible invalid ptr AV with overlapped read/write on pipes
* [THRIFT-4549] - Thrift exceptions should derive from TException
* [THRIFT-4540] - buffered transport broken when trying to re-open a formerly closed transport
* [THRIFT-4473] - Move Thrift.Console.pas out of the Library
* [THRIFT-4490] - Allow a default service as fallback for multiplex processors connected by old clients
* [THRIFT-4454] - Large writes/reads may cause range check errors in debug mode
* [THRIFT-4461] - Compiler directive should match Delphi XE4
* [THRIFT-4462] - First line in Console duplicated
* [THRIFT-4642] - FPU ctrl word settings may cause an unexpected "denormalized" error
## erlang
* [THRIFT-4497] - Erlang records should use map() for map type
* [THRIFT-4495] - Erlang records should allow 'undefined' for non-required fields
* [THRIFT-4580] - Fix erlang tutorial unpack on Windows
* [THRIFT-4582] - Ubuntu Xenial erlang 18.3 "make check" fails
## golang
* [THRIFT-4448] - Support for golang 1.6 and earlier has been dropped.
* [THRIFT-4253] - Go generator assigns strings to field in const instead of pointers.
* [THRIFT-4573] - Unions Field Count Does Not Consider Binary
* [THRIFT-4447] - Golang: Panic on p.c.Call when using deprecated initializers
* [THRIFT-4650] - Required field incorrectly marked as set when fieldType does not match
* [THRIFT-4486] - Golang: -remote.go client cleanup
* [THRIFT-4537] - TSimpleServer can exit Accept loop with lock still acquired
* [THRIFT-4516] - Add support for go 1.10
* [THRIFT-4421] - golang tests rely on gomock, which has change behaviour, causing tests to fail
* [THRIFT-4626] - Communication crash when using binary/compact protocol and zlib transport
* [THRIFT-4659] - golang race detected when closing listener socket
## haskell
* [THRIFT-4634] - Haskell builds with older cabal cannot reconcile complex version requirements
## java
* [THRIFT-4259] - Thrift does not compile due to Ant Maven task errors
* [THRIFT-1418] - Compiling Thrift from source: Class org.apache.tools.ant.taskdefs.ConditionTask doesn't support the nested "typefound" element
* [THRIFT-4530] - proposal: add nullability annotations to generated Java code
* [THRIFT-4614] - Generate missing @Nullable annotations for Java iterator getters
* [THRIFT-4555] - Getter of binary field in Java creates unnecessary copy
* [THRIFT-3983] - libthrift is deployed on central with pom packaging instead of jar
* [THRIFT-4294] - Java Configure Fails for Ant >= 1.10
* [THRIFT-4178] - Java libraries missing from package when using cmake
* [THRIFT-4120] - pom files are not generated or provided in the build
* [THRIFT-1507] - Maven can't download resource from central when behind a proxy and won't use local repository
* [THRIFT-4556] - Optional rethrow of unhandled exceptions in java processor
* [THRIFT-4337] - Able to set keyStore and trustStore as InputStream in the TSSLTransportFactory.TSSLTransportParameters
* [THRIFT-4566] - Pass message of unhandled exception to optional rethrow.
* [THRIFT-4506] - Remove assertion in Java SASL code that would be ignored in release builds
* [THRIFT-4470] - Include popular IDE file templates to gitignore
* [THRIFT-4429] - Make TThreadPoolServer.executorService_ available in inherited classes and refactor methods to be able customization
* [THRIFT-3769] - Fix logic of THRIFT-2268
* [THRIFT-4494] - Increase Java Socket Buffer Size
* [THRIFT-4499] - Remove Magic Number In TFIleTransport
## js
* [THRIFT-4406] - JavaScript: Use modern Promise implementations
* [THRIFT-4625] - let / const variable decorators for es6 compiler
* [THRIFT-4653] - ES6 Classes
* [THRIFT-4592] - JS: readI32 performance on large arrays is very poor in Chrome
* [THRIFT-4509] - js and nodejs libraries need to be refreshed with current libraries
* [THRIFT-4403] - thrift.js: Incorrect usage of 'this' in TWebSocketTransport.__onOpen
* [THRIFT-4436] - Deserialization of nested list discards content
* [THRIFT-4437] - JS WebSocket client callbacks invoked twice on parallel requests
* [THRIFT-4679] - Duplicate declaration of InputBufferUnderrunError in lib/nodejs/lib/thrift/json_protocol.js
* [THRIFT-4551] - Add prettier for consistent JS code formatting
## lua
* [THRIFT-4591] - lua client uses two write() calls per framed message send
* [THRIFT-3863] - Can't "make install" Lua Library
## netcore
* [THRIFT-4524] - .NET Core Server doesn't close properly when cancelled
* [THRIFT-4434] - Update .NET Core components, add tests for .Net Core library and .Net Core compiler, fix bugs and build process
* [THRIFT-4446] - JSONProtocol Base64 Encoding Trims Padding
## node.js
* [THRIFT-4225] - Error handling malformed arguments leaks memory, corrupts transport buffers causing next RPC to fail
* [THRIFT-3950] - Memory leak while calling oneway method
* [THRIFT-3143] - add typescript directory support
* [THRIFT-4564] - TBufferedTransport can leave corrupt data in the buffer
* [THRIFT-4647] - Node.js Fileserver webroot path
* [THRIFT-4489] - Unix domain socket support for NodeJS client
* [THRIFT-4443] - node.js json_protocol throws error in skip function
* [THRIFT-4604] - NodeJS: Expose Int64 from browser.js for consumption by browser
* [THRIFT-4480] - NodeJS warning on binary_protocol writeMessageEnd when seqid = 0
## perl
* [THRIFT-4382] - Replace the use of Perl Indirect Object Syntax calls to new()
* [THRIFT-4471] - Thrift CPAN release is missing Makefile.PL and the clients are unable to build the module
* [THRIFT-4416] - Perl CPAN Packaging Improvements
## php
* [THRIFT-4474] - PHP generator use PSR-4 default
* [THRIFT-4463] - PHP generated code match PSR-2
* [THRIFT-4373] - Extending Thrift class results in "Attempt serialize from non-Thrift object"
* [THRIFT-4354] - TSocket block on read
* [THRIFT-4423] - migrate php library to psr-4
* [THRIFT-4656] - infinite loop in latest PHP library
* [THRIFT-4477] - TBufferedTransport must have underlying transport
* [THRIFT-4475] - lib/php/test should be checked for PSR-2
* [THRIFT-4498] - add phpcs back
* [THRIFT-4460] - php library use PSR-2
* [THRIFT-4641] - TCurlClient doesn't check for HTTP status code
* [THRIFT-4645] - TCurlClient: show actual error message when throwing TTransportException
* [THRIFT-4674] - Add stream context support into PHP/THttpClient
* [THRIFT-4459] - reduce php library directory depth
## python
* [THRIFT-4670] - Twisted, slots, and void method fails with "object has no attribute 'success'"
* [THRIFT-4464] - Potentially server-crashing typo in Python TNonblockingServer
* [THRIFT-4548] - Supporting TBinaryProtocolAccelerated protocol when using TMultiplexedProcessor in Python
* [THRIFT-4577] - Outdated cipher string in python unit test
* [THRIFT-4505] - python build on Vagrant Windows boxes fails
* [THRIFT-4621] - THeader for Python
* [THRIFT-4668] - make socket backlog configurable for python
* [THRIFT-4561] - Python: cleanup socket timeout settings
## ruby
* [THRIFT-4289] - Thrift RSpec test suite fails with Ruby 2.4.x due to Fixnum deprecation
* [THRIFT-4342] - Support ruby rspec 3
* [THRIFT-4525] - Add ssl socket option to ruby cross tests
* [THRIFT-4450] - Add seek support to TCompactInputProtocol in Rust
* [THRIFT-4631] - Codegen Creates Invalid Ruby for Recursive Structs
* [THRIFT-4472] - Fix the genspec for ruby so it does not complain about an invalid license
## rust
* [THRIFT-4662] - Rust const string calls function at compile time
* [THRIFT-4661] - Rust enum name wrong case in generated structs
* [THRIFT-4617] - Avoid generating conflicting struct names in Rust code
* [THRIFT-4529] - Rust generation should include #![allow(non_snake_case)] or force conform to Rust style guidelines
* [THRIFT-4390] - Rust binary protocol and buffered transport cannot handle writes above 4096 bytes
* [THRIFT-4419] - Rust framed transport cannot handle writes above 4096 bytes
* [THRIFT-4658] - Rust's TBinaryInputProtocol fails when strict is false
* [THRIFT-4187] - Dart -> Rust Framed cross tests fail
* [THRIFT-4664] - Rust cannot create ReadHalf/WriteHalf to implement custom tranports
## swift (new language support in 0.12.0)
* [THRIFT-3773] - Swift Library
## test suite
* [THRIFT-4515] - Gracefully shutdown cross-test servers to fully test teardown
* [THRIFT-4085] - Add .NET Core to the make cross standard test suite
* [THRIFT-4358] - Add unix domain sockets in ruby to cross test - code exists
## typescript (new language support in 0.12.0)
* [THRIFT-3143] - add typescript directory support
================================================================================
Thrift 0.11.0
--------------------------------------------------------------------------------
## Sub-task
* [THRIFT-2733] - Erlang coding standards
* [THRIFT-2740] - Perl coding standards
* [THRIFT-3610] - Streamline exception handling in Python server handler
* [THRIFT-3686] - Java processor should report internal error on uncaught exception
* [THRIFT-4049] - Skip() should throw TProtocolException.INVALID_DATA on unknown data types
* [THRIFT-4053] - Skip() should throw TProtocolException.INVALID_DATA on unknown data types
* [THRIFT-4136] - Align is_binary() method with is_string() to simplify those checks
* [THRIFT-4137] - Fix remaining undefined behavior invalid vptr casts in Thrift Compiler
* [THRIFT-4138] - Fix remaining undefined behavior invalid vptr casts in C++ library
* [THRIFT-4296] - Fix Ubuntu Xenial build environment for the python language
* [THRIFT-4298] - Fix Ubuntu Xenial build environment for the go 1.6 language
* [THRIFT-4299] - Fix Ubuntu Xenial build environment for the D language
* [THRIFT-4300] - Fix make cross in Ubuntu Xenial docker environment, once all language support issues are fixed
* [THRIFT-4302] - Fix Ubuntu Xenial make cross testing for lua and php7
* [THRIFT-4398] - Update EXTRA_DIST for "make dist"
## Bug
* [THRIFT-381] - Fail fast if configure detects C++ problems
* [THRIFT-1677] - MinGW support broken
* [THRIFT-1805] - Thrift should not swallow ALL exceptions
* [THRIFT-2026] - Fix TCompactProtocol 64 bit builds
* [THRIFT-2642] - Recursive structs don't work in python
* [THRIFT-2889] - stable release 0.9.2, erlang tutorial broken
* [THRIFT-2913] - Ruby Server Thrift::ThreadPoolServer should serve inside a thread
* [THRIFT-2998] - Node.js: Missing header from http request
* [THRIFT-3000] - .NET implementation has trouble with mixed IP modes
* [THRIFT-3281] - Travis CI build passed but the log says BUILD FAILED
* [THRIFT-3358] - Makefile:1362: *** missing separator. Stop.
* [THRIFT-3600] - Make TTwisted server send exception on unexpected handler error
* [THRIFT-3602] - Make Tornado server send exception on unexpected handler error
* [THRIFT-3657] - D TFileWriterTransport close should use non-priority send
* [THRIFT-3700] - Go Map has wrong default value when optional
* [THRIFT-3703] - Unions Field Count Does Not Consider Map/Set/List Fields
* [THRIFT-3730] - server log error twice
* [THRIFT-3778] - go client can not pass method parameter to server of other language if no field_id is given
* [THRIFT-3784] - thrift-maven-plugin generates invalid include directories for IDL in dependency JARs
* [THRIFT-3801] - Node Thrift client throws exception with multiplexer and responses that are bigger than a single buffer
* [THRIFT-3821] - TMemoryBuffer buffer may overflow when resizing
* [THRIFT-3832] - Thrift version 0.9.3 example on Windows, Visual Studio, linking errors during compiling
* [THRIFT-3847] - thrift/config.h includes a #define for VERSION which will likely conflict with existing user environment or code
* [THRIFT-3873] - Fix various build warnings when using Visual Studio
* [THRIFT-3891] - TNonblockingServer configured with more than one IO threads does not always return from serve() upon stop()
* [THRIFT-3892] - Thrift uses TLS SNI extension provided by OpenSSL library. Older version of OpenSSL(< 0.9.8f) may create problem because they do not support 'SSL_set_tlsext_host_name()'.
* [THRIFT-3895] - Build fails using Java 1.8 with Ant < 1.9
* [THRIFT-3896] - map<string,string> data with number string key cannot access that deserialized by php extension
* [THRIFT-3938] - Python TNonblockingServer does not work with SSL
* [THRIFT-3944] - TSSLSocket has dead code in checkHandshake
* [THRIFT-3946] - Java 1.5 compatibility broken for binary fields (java5 option)
* [THRIFT-3960] - Inherited services in Lua generator are not named correctly
* [THRIFT-3962] - Ant build.xml broken on Windows for Java library
* [THRIFT-3963] - Thrift.cabal filename does not match module name
* [THRIFT-3967] - gobject/gparam.h:166:33: warning: enumerator value for G_PARAM_DEPRECATED is not an integer constant expression
* [THRIFT-3968] - Deserializing empty string/binary fields
* [THRIFT-3974] - Using clang-3.8 and ThreadSanitizer on the concurrency_test claims bad PThread behavior
* [THRIFT-3984] - PHP7 extension causes segfault
* [THRIFT-4008] - broken ci due to upstream dependency versioning break
* [THRIFT-4009] - Use @implementer instead of implements in TTwisted.py
* [THRIFT-4010] - Q.fcall messing up with *this* pointer inside called function
* [THRIFT-4011] - Sets of Thrift structs generate Go code that can't be serialized to JSON
* [THRIFT-4012] - Python Twisted implementation uses implements, not compatible with Py3
* [THRIFT-4014] - align C# meta data in AssemblyInfo.cs
* [THRIFT-4015] - Fix wrongly spelled "Thirft"s
* [THRIFT-4016] - testInsanity() impl does not conform to test spec in ThriftTest.thrift
* [THRIFT-4023] - Skip unexpected field types on read/write
* [THRIFT-4024] - Skip() should throw on unknown data types
* [THRIFT-4026] - TSSLSocket doesn't work with Python < 2.7.9
* [THRIFT-4029] - Accelerated protocols do not build from thrift-py 0.10.0 on PyPI
* [THRIFT-4031] - Go plugin generates invalid code for lists of typedef'ed built-in types
* [THRIFT-4033] - Default build WITH_PLUGIN=ON for all builds results in packaging errors
* [THRIFT-4034] - CMake doesn't work to build compiler on MacOS
* [THRIFT-4036] - Add .NET Core environment/build support to the docker image
* [THRIFT-4038] - socket check: checking an unsigned number against >= 0 never fails
* [THRIFT-4042] - ExtractionError when using accelerated thrift in a multiprocess test
* [THRIFT-4043] - thrift perl debian package is placing files in the wrong place
* [THRIFT-4044] - Build job 17 failing on every pull request; hspec core (haskell) 2.4 issue
* [THRIFT-4046] - MinGW with gcc 6.2 does not compile on Windows
* [THRIFT-4060] - Thrift printTo ostream overload mechanism breaks down when types are nested
* [THRIFT-4062] - Remove debug print from TServiceClient
* [THRIFT-4065] - Document Perl ForkingServer signal restriction imposed by THRIFT-3848 and remove unnecessary code
* [THRIFT-4068] - A code comment in Java ServerSocket is wrong around accept()
* [THRIFT-4073] - enum files are still being generated with unused imports
* [THRIFT-4076] - Appveyor builds failing because ant 1.9.8 was removed from apache servers
* [THRIFT-4077] - AI_ADDRCONFIG redefined after recent change to PlatformSocket header
* [THRIFT-4079] - Generated perl code that returns structures from included thrift files is missing a necessary use clause
* [THRIFT-4087] - Spurious exception destroying TThreadedServer because of incorrect join() call
* [THRIFT-4102] - TBufferedTransport performance issue since 0.10.0
* [THRIFT-4106] - concurrency_test fails randomly
* [THRIFT-4108] - c_glib thrift ssl has multiple bugs and deprecated functions
* [THRIFT-4109] - Configure Script uses string comparison for versions
* [THRIFT-4129] - C++ TNonblockingServer fd leak when failing to dispatch new connections
* [THRIFT-4131] - Javascript with WebSocket handles oneway methods wrong
* [THRIFT-4134] - Fix remaining undefined behavior invalid vptr casts
* [THRIFT-4140] - Use of non-thread-safe function gmtime()
* [THRIFT-4141] - Installation of haxe in docker files refers to a redirect link and fails
* [THRIFT-4147] - Rust: protocol should accept transports with non-static lifetime
* [THRIFT-4148] - [maven-thrift-plugin] compile error while import a thrift in dependency jar file.
* [THRIFT-4149] - System.out pollutes log files
* [THRIFT-4154] - PHP close() of a TSocket needs to close any type of socket
* [THRIFT-4158] - minor issue in README-MSYS2.md
* [THRIFT-4159] - Building tests fails on MSYS2 (MinGW64) due to a (small?) linker error
* [THRIFT-4160] - TNonblocking server fix use of closed/freed connections
* [THRIFT-4161] - TNonBlocking server using uninitialized event in error paths
* [THRIFT-4162] - TNonBlocking handling of TSockets in error state is incorrect after fd is closed
* [THRIFT-4164] - Core in TSSLSocket cleanupOpenSSL when destroying a mutex used by openssl
* [THRIFT-4165] - C++ build has many warnings under c++03 due to recent changes, cmake needs better platform-independent language level control
* [THRIFT-4166] - Recent fix to remove boost::lexical_cast usage broke VS2010
* [THRIFT-4167] - Missing compile flag
* [THRIFT-4170] - Support lua 5.1 or earlier properly for object length determination
* [THRIFT-4172] - node.js tutorial client does not import assert, connection issues are not handled properly
* [THRIFT-4177] - Java compiler produces deep copy constructor that could make shallow copy instead
* [THRIFT-4184] - Building on Appveyor: invalid escape sequence \L
* [THRIFT-4185] - fb303 counter encoding fix
* [THRIFT-4189] - Framed/buffered transport Dispose() does not dispose the nested transport
* [THRIFT-4193] - Lower the default maxReadBufferBytes for non-blocking servers
* [THRIFT-4195] - Compilation to GO produces broken code
* [THRIFT-4196] - Cannot generate recursive Rust types
* [THRIFT-4204] - typo in compact spec
* [THRIFT-4206] - Strings in container fields are not decoded properly with py:dynamic and py:utf8strings
* [THRIFT-4208] - C# NamedPipesServer not really working in some scenarios
* [THRIFT-4211] - Fix GError glib management under Thrift
* [THRIFT-4212] - c_glib flush tries to close SSL even if socket is invalid
* [THRIFT-4213] - Travis build fails at curl -sSL https://www.npmjs.com/install.sh | sh
* [THRIFT-4215] - Golang TTransportFactory Pattern Squelches Errors
* [THRIFT-4216] - Golang Http Clients Do Not Respect User Options
* [THRIFT-4218] - Set TCP_NODELAY for PHP client socket
* [THRIFT-4219] - Golang HTTP clients created with Nil buffer
* [THRIFT-4231] - TJSONProtocol throws unexpected non-Thrift-exception on null strings
* [THRIFT-4232] - ./configure does bad ant version check
* [THRIFT-4234] - Travis build fails cross language tests with "Unsupported security protocol type"
* [THRIFT-4237] - Go TServerSocket Race Conditions
* [THRIFT-4240] - Go TSimpleServer does not close properly
* [THRIFT-4243] - Go TSimpleServer race on wait in Stop() method
* [THRIFT-4245] - Golang TFramedTransport's writeBuffer increases if writes to transport failed
* [THRIFT-4246] - Sequence number mismatch on multiplexed clients
* [THRIFT-4247] - Compile fails with openssl 1.1
* [THRIFT-4248] - Compile fails - strncpy, memcmp, memset not declared in src/thrift/transport/TSSLSocket.cpp
* [THRIFT-4251] - Java Epoll Selector Bug
* [THRIFT-4257] - Typescript async callbacks do not provide the correct types
* [THRIFT-4258] - Boost/std thread wrapping faultiness
* [THRIFT-4260] - Go context generation issue. Context is parameter in Interface not in implementation
* [THRIFT-4261] - Go context generation issue: breaking change in generated code regarding thrift.TProcessorFunction interface
* [THRIFT-4262] - Invalid binding to InterlockedCompareExchange64() with 64-bit targets
* [THRIFT-4263] - Fix use after free bug for thrown exceptions
* [THRIFT-4266] - Erlang library throws during skipping fields of composite type (maps, lists, structs, sets)
* [THRIFT-4268] - Erlang library emits debugging output in transport layer
* [THRIFT-4273] - erlang:now/0: Deprecated BIF.
* [THRIFT-4274] - Python feature tests for SSL/TLS failing
* [THRIFT-4279] - Wrong path in include directive in generated Thrift sources
* [THRIFT-4283] - TNamedPipeServer race condition in interrupt
* [THRIFT-4284] - File contains a NBSP: lib/nodejs/lib/thrift/web_server.js
* [THRIFT-4290] - C# nullable option generates invalid code for non-required enum field with default value
* [THRIFT-4292] - TimerManager::remove() is not implemented
* [THRIFT-4307] - Make ssl-open timeout effective in golang client
* [THRIFT-4312] - Erlang client cannot connect to Python server: exception error: econnrefused
* [THRIFT-4313] - Program code of the Erlang tutorial files contain syntax errors
* [THRIFT-4316] - TByteBuffer.java will read too much data if a previous read returns fewer bytes than requested
* [THRIFT-4319] - command line switch for "evhttp" incorrectly resolved to anon pipes
* [THRIFT-4323] - range check errors or NPE in edge cases
* [THRIFT-4324] - field names can conflict with local vars in generated code
* [THRIFT-4328] - Travis CI builds are timing out (job 1) and haxe builds are failing since 9/11
* [THRIFT-4329] - c_glib Doesn't have a multiplexed processor
* [THRIFT-4331] - C++: TSSLSockets bug in handling huge messages, bug in handling polling
* [THRIFT-4332] - Binary protocol has memory leaks
* [THRIFT-4334] - Perl indentation incorrect when defaulting field attribute to a struct
* [THRIFT-4339] - Thrift Framed Transport in Erlang crashes server when client disconnects
* [THRIFT-4340] - Erlang fix a crash on client close
* [THRIFT-4355] - Javascript indentation incorrect when defaulting field attribute to a struct
* [THRIFT-4356] - thrift_protocol call Transport cause Segmentation fault
* [THRIFT-4359] - Haxe compiler looks like it is producing incorrect code for map or set key that is binary type
* [THRIFT-4362] - Missing size-check can lead to huge memory allocation
* [THRIFT-4364] - Website contributing guide erroneously recommends submitting patches in JIRA
* [THRIFT-4365] - Perl generated code uses indirect object syntax, which occasionally causes compilation errors.
* [THRIFT-4367] - python TProcessor.process is missing "self"
* [THRIFT-4370] - Ubuntu Artful cppcheck and flake8 are more stringent and causing SCA build job failures
* [THRIFT-4372] - Pipe write operations across a network are limited to 65,535 bytes per write.
* [THRIFT-4374] - cannot load thrift_protocol due to undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
* [THRIFT-4376] - Coverity high impact issue resolution
* [THRIFT-4377] - haxe. socket handles leak in TSimpleServer
* [THRIFT-4381] - Wrong isset bitfield value after transmission
* [THRIFT-4385] - Go remote client -u flag is broken
* [THRIFT-4392] - compiler/..../plugin.thrift structs mis-ordered blows up ocaml generator
* [THRIFT-4395] - Unable to build in the ubuntu-xenial docker image: clap 2.28 requires Rust 1.20
* [THRIFT-4396] - inconsistent (or plain wrong) version numbers in master/trunk
## Documentation
* [THRIFT-4157] - outdated readme about Haxe installation on Linux
## Improvement
* [THRIFT-105] - make a thrift_spec for a structures with negative tags
* [THRIFT-281] - Cocoa library code needs comments, badly
* [THRIFT-775] - performance improvements for Perl
* [THRIFT-2221] - Generate c++ code with std::shared_ptr instead of boost::shared_ptr.
* [THRIFT-2364] - OCaml: Use Oasis exclusively for build process
* [THRIFT-2504] - TMultiplexedProcessor should allow registering default processor called if no service name is present
* [THRIFT-3207] - Enable build with OpenSSL 1.1.0 series
* [THRIFT-3272] - Perl SSL Authentication Support
* [THRIFT-3357] - Generate EnumSet/EnumMap where elements/keys are enums
* [THRIFT-3369] - Implement SSL/TLS support on C with c_glib
* [THRIFT-3467] - Go Maps for Thrift Sets Should Have Values of Type struct{}
* [THRIFT-3580] - THeader for Haskell
* [THRIFT-3627] - Missing basic code style consistency of JavaScript.
* [THRIFT-3706] - There's no support for Multiplexed protocol on c_glib library
* [THRIFT-3766] - Add getUnderlyingTransport() to TZlibTransport
* [THRIFT-3776] - Go code from multiple thrift files with the same namespace
* [THRIFT-3823] - Escape documentation while generating non escaped documetation
* [THRIFT-3854] - allow users to clear read buffers
* [THRIFT-3859] - Unix Domain Socket Support in Objective-C
* [THRIFT-3921] - C++ code should print enums as strings
* [THRIFT-3926] - There should be an error emitted when http status code is not 200
* [THRIFT-4007] - Micro-optimization of TTransport.py
* [THRIFT-4040] - Add real cause of TNonblockingServerSocket error to exception
* [THRIFT-4064] - Update node library dependencies
* [THRIFT-4069] - All perl packages should have proper namespace, version syntax, and use proper thrift exceptions
* [THRIFT-4071] - Consolidate the Travis CI jobs where possible to put less stress on the Apache Foundation's allocation of CI build slaves
* [THRIFT-4072] - Add the possibility to send custom headers in TCurlClient
* [THRIFT-4075] - Better MinGW support for headers-only boost (without thread library)
* [THRIFT-4081] - Provide a MinGW 64-bit Appveyor CI build for better pull request validation
* [THRIFT-4084] - Improve SSL security in thrift by adding a make cross client that checks to make sure SSLv3 protocol cannot be negotiated
* [THRIFT-4095] - Add multiplexed protocol to Travis CI for make cross
* [THRIFT-4099] - Auto-derive Hash for generated Rust structs
* [THRIFT-4110] - The debian build files do not produce a "-dbg" package for debug symbols of libthrift0
* [THRIFT-4114] - Space after '///' in doc comments
* [THRIFT-4126] - Validate objects in php extension
* [THRIFT-4130] - Ensure Apache Http connection is released back to pool after use
* [THRIFT-4151] - Thrift Mutex Contention Profiling (pthreads) should be disabled by default
* [THRIFT-4176] - Implement a threaded and threadpool server type for Rust
* [THRIFT-4183] - Named pipe client blocks forever on Open() when there is no server at the other end
* [THRIFT-4190] - improve C# TThreadPoolServer defaults
* [THRIFT-4197] - Implement transparent gzip compression for HTTP transport
* [THRIFT-4198] - Ruby should log Thrift internal errors to global logger
* [THRIFT-4203] - thrift server stop gracefully
* [THRIFT-4205] - c_glib is not linking against glib + gobject
* [THRIFT-4209] - warning CS0414 in T[TLS]ServerSocket.cs
* [THRIFT-4210] - include Thrift.45.csproj into CI runs
* [THRIFT-4217] - HttpClient should support gzip and deflate
* [THRIFT-4222] - Support Unix Domain Sockets in Golang TServerSocket
* [THRIFT-4233] - Make THsHaServer.invoker available (get method only) in inherited classes
* [THRIFT-4236] - Support context in go generated code.
* [THRIFT-4238] - JSON generator: make annotation-aware
* [THRIFT-4269] - Don't append '.' to Erlang namespace if it ends in '_'.
* [THRIFT-4270] - Generate Erlang mapping functions for const maps and lists
* [THRIFT-4275] - Add support for zope.interface only, apart from twisted support.
* [THRIFT-4285] - Pull generated send/recv into library to allow behaviour to be customised
* [THRIFT-4287] - Add c++ compiler "no_skeleton" flag option
* [THRIFT-4288] - Implement logging levels properly for node.js
* [THRIFT-4295] - Refresh the Docker image file suite for Ubuntu, Debian, and CentOS
* [THRIFT-4305] - Emit ddoc for generated items
* [THRIFT-4306] - Thrift imports not replicated to D service output
* [THRIFT-4315] - Add default message for TApplicationException
* [THRIFT-4318] - Delphi performance improvements
* [THRIFT-4325] - Simplify automake cross compilation by relying on one global THRIFT compiler path
* [THRIFT-4327] - Improve TimerManager API to allow removing specific task
* [THRIFT-4330] - Allow unused crates in Rust files
* [THRIFT-4333] - Erlang tutorial examples are using a different port (9999)
* [THRIFT-4343] - Change CI builds to use node.js 8.x LTS once available
* [THRIFT-4345] - Create a docker build environment that uses the minimum supported language levels
* [THRIFT-4346] - Allow Zlib transport factory to wrap other transports
* [THRIFT-4348] - Perl HTTP Client custom HTTP headers
* [THRIFT-4350] - Update netcore build for dotnet 2.0 sdk and make cross validation
* [THRIFT-4351] - Use Travis CI Build Stages to optimize the CI build
* [THRIFT-4353] - cannot read via thrift_protocol at server side
* [THRIFT-4378] - add set stopTimeoutUnit method to TThreadPoolServer
## New Feature
* [THRIFT-750] - C++ Compiler Virtual Function Option
* [THRIFT-2945] - Implement support for Rust language
* [THRIFT-3857] - thrift js:node complier support an object as parameter not an instance of struct
* [THRIFT-3933] - Port official C# .NET library for Thrift to C# .NET Core libary
* [THRIFT-4039] - Update of Apache Thrift .Net Core lib
* [THRIFT-4113] - Provide a buffer transport for reading/writing in memory byte stream
## Question
* [THRIFT-2956] - autoconf - possibly undefined macro - AC_PROG_BISON
* [THRIFT-4223] - Add support to the isServing() method for the C++ library
## Task
* [THRIFT-3622] - Fix deprecated uses of std::auto_ptr
* [THRIFT-4028] - Please remove System.out.format from the source code
* [THRIFT-4186] - Build and test rust client in Travis
## Test
* [THRIFT-4264] - PHP - Support both shared & static linking of sockets library
## Wish
* [THRIFT-4344] - Define and maintain the minimum language level for all languages in one place
Thrift 0.10.0
--------------------------------------------------------------------------------
## Bug

View file

@ -17,7 +17,14 @@
# under the License.
#
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.1)
# CMake 3.1 supports C++ standards selection with CMAKE_CXX_STANDARD
# If you need CMake 3.1+ for Ubuntu 14.04, try
# https://launchpad.net/~george-edison55/+archive/ubuntu/cmake-3.x
# If you need CMake 3.1+ for debian "jessie", get it from jessie-backports
# Otherwise
# http://cmake.org
project("Apache Thrift")

View file

@ -1,49 +1,116 @@
## How to contribute
1. Help to review and verify existing patches
1. Make sure your issue is not all ready in the [Jira issue tracker](http://issues.apache.org/jira/browse/THRIFT)
1. If not, create a ticket describing the change you're proposing in the [Jira issue tracker](http://issues.apache.org/jira/browse/THRIFT)
1. Contribute your patch using one of the two methods below
# How to Contribute #
### Contributing via a patch
1. Check out the latest version of the source code
* git clone https://git-wip-us.apache.org/repos/asf/thrift.git thrift
1. Modify the source to include the improvement/bugfix
* Remember to provide *tests* for all submited changes
* When bugfixing: add test that will isolate bug *before* applying change that fixes it
* Verify that you follow [Thrift Coding Standards](/docs/coding_standards) (you can run 'make style', which ensures proper format for some languages)
1. Create a patch from project root directory (e.g. you@dev:~/thrift $ ):
* git diff > ../thrift-XXX-my-new-feature.patch
1. Attach the newly generated patch to the issue
1. Wait for other contributors or committers to review your new addition
1. Wait for a committer to commit your patch
### Contributing via GitHub pull requests
1. Create a fork for http://github.com/apache/thrift
1. Create a branch for your changes(best practice is issue as branch name, e.g. THRIFT-9999)
1. Modify the source to include the improvement/bugfix
* Remember to provide *tests* for all submited changes
* When bugfixing: add test that will isolate bug *before* applying change that fixes it
* Verify that you follow [Thrift Coding Standards](/docs/coding_standards) (you can run 'make style', which ensures proper format for some languages)
* Verify that your change works on other platforms by adding a GitHub service hook to [Travis CI](http://docs.travis-ci.com/user/getting-started/#Step-one%3A-Sign-in) and [AppVeyor](http://www.appveyor.com/docs)
1. Commit and push changes to your branch (please use issue name and description as commit title, e.g. THRIFT-9999 make it perfect)
1. Issue a pull request with the jira ticket number you are working on in it's name
1. Wait for other contributors or committers to review your new addition
1. Wait for a committer to commit your patch
### More info
Plenty of information on why and how to contribute is available on the Apache Software Foundation (ASF) web site. In particular, we recommend the following:
Thank you for your interest in contributing to the Apache Thrift project! Information on why and how to contribute is available on the Apache Software Foundation (ASF) web site. In particular, we recommend the following to become acquainted with Apache Contributions:
* [Contributors Tech Guide](http://www.apache.org/dev/contributors)
* [Get involved!](http://www.apache.org/foundation/getinvolved.html)
* [Legal aspects on Submission of Contributions (Patches)](http://www.apache.org/licenses/LICENSE-2.0.html#contributions)
## GitHub pull requests ##
This is the preferred method of submitting changes. When you submit a pull request through github,
it activates the continuous integration (CI) build systems at Appveyor and Travis to build your changesxi
on a variety of Linux and Windows configurations and run all the test suites. Follow these requirements
for a successful pull request:
1. All code changes require an [Apache Jira THRIFT Issue](http://issues.apache.org/jira/browse/THRIFT) ticket.
1. All pull requests should contain a single commit per issue, or we will ask you to squash it.
1. The pull request title must begin with the Jira THRIFT ticket identifier, for example:
THRIFT-9999: an example pull request title
1. Commit messages must follow this pattern for code changes (deviations will not be merged):
THRIFT-9999: [summary of fix, one line if possible]
Client: [language(s) affected, comma separated, use lib/ directory names please]
Instructions:
1. Create a fork in your GitHub account of http://github.com/apache/thrift
1. Clone the fork to your development system.
1. Create a branch for your changes (best practice is issue as branch name, e.g. THRIFT-9999).
1. Modify the source to include the improvement/bugfix, and:
* Remember to provide *tests* for all submitted changes!
* Use test-driven development (TDD): add a test that will isolate the bug *before* applying the change that fixes it.
* Verify that you follow [Thrift Coding Standards](/docs/coding_standards) (you can run 'make style', which ensures proper format for some languages).
* [*optional*] Verify that your change works on other platforms by adding a GitHub service hook to [Travis CI](http://docs.travis-ci.com/user/getting-started/#Step-one%3A-Sign-in) and [AppVeyor](http://www.appveyor.com/docs). You can use this technique to run the Thrift CI jobs in your account to check your changes before they are made public. Every GitHub pull request into Thrift will run the full CI build and test suite on your changes.
1. Squash your changes to a single commit. This maintains clean change history.
1. Commit and push changes to your branch (please use issue name and description as commit title, e.g. "THRIFT-9999: make it perfect"), with the affected languages on the next line of the description.
1. Use GitHub to create a pull request going from your branch to apache:master. Ensure that the Jira ticket number is at the beginning of the title of your pull request, same as the commit title.
1. Wait for other contributors or committers to review your new addition, and for a CI build to complete.
1. Wait for a committer to commit your patch. You can nudge the committers if necessary by sending a message to the [Apache Thrift mailing list](https://thrift.apache.org/mailing).
## If you want to build the project locally ##
For Windows systems, see our detailed instructions on the [CMake README](/build/cmake/README.md).
For Windows Native C++ builds, see our detailed instructions on the [WinCPP README](/build/wincpp/README.md).
For unix systems, see our detailed instructions on the [Docker README](/build/docker/README.md).
## If you want to review open issues... ##
1. Review the [GitHub Pull Request Backlog](https://github.com/apache/thrift/pulls). Code reviews are open to all.
2. Review the [Jira issue tracker](http://issues.apache.org/jira/browse/THRIFT). You can search for tickets relating to languages you are interested in or currently using with thrift, for example a Jira search (Issues -> Search For Issues) query of ``project = THRIFT AND component in ("Erlang - Library") and status not in (resolved, closed)`` will locate all the open Erlang Library issues.
## If you discovered a defect... ##
1. Check to see if the issue is already in the [Jira issue tracker](http://issues.apache.org/jira/browse/THRIFT).
1. If not, create a ticket describing the change you're proposing in the Jira issue tracker.
1. Contribute your code changes using the GitHub pull request method:
## Contributing via Patch ##
Some changes do not require a build, for example in documentation. For changes that are not code or build related, you can submit a patch on Jira for review. To create a patch from changes in your local directory:
git diff > ../THRIFT-NNNN.patch
then wait for contributors or committers to review your changes, and then for a committer to apply your patch.
## GitHub recipes for Pull Requests ##
Sometimes commmitters may ask you to take actions in your pull requests. Here are some recipes that will help you accomplish those requests. These examples assume you are working on Jira issue THRIFT-9999. You should also be familiar with the [upstream](https://help.github.com/articles/syncing-a-fork/) repository concept.
### Squash your changes ###
If you have not submitted a pull request yet, or if you have not yet rebased your existing pull request, you can squash all your commits down to a single commit. This makes life easier for the committers. If your pull request on GitHub has more than one commit, you should do this.
1. Use the command ``git log`` to identify how many commits you made since you began.
2. Use the command ``git rebase -i HEAD~N`` where N is the number of commits.
3. Leave "pull" in the first line.
4. Change all other lines from "pull" to "fixup".
5. All your changes are now in a single commit.
If you already have a pull request outstanding, you will need to do a "force push" to overwrite it since you changed your commit history:
git push -u origin THRIFT-9999 --force
A more detailed walkthrough of a squash can be found at [Git Ready](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html).
### Rebase your pull request ###
If your pull request has a conflict with master, it needs to be rebased:
git checkout THRIFT-9999
git rebase upstream master
(resolve any conflicts, make sure it builds)
git push -u origin THRIFT-9999 --force
### Fix a bad merge ###
If your pull request contains commits that are not yours, then you should use the following technique to fix the bad merge in your branch:
git checkout master
git pull upstream master
git checkout -b THRIFT-9999-take-2
git cherry-pick ...
(pick only your commits from your original pull request in ascending chronological order)
squash your changes to a single commit if there is more than one (see above)
git push -u origin THRIFT-9999-take-2:THRIFT-9999
This procedure will apply only your commits in order to the current master, then you will squash them to a single commit, and then you force push your local THRIFT-9999-take-2 into remote THRIFT-9999 which represents your pull request, replacing all the commits with the new one.

View file

@ -1,61 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Goal: provide a thrift-compiler Docker image
#
# Usage:
# docker run -v "${PWD}:/data" thrift/thrift-compiler -gen cpp -o /data/ /data/test/ThriftTest.thrift
#
# further details on docker for thrift is here build/docker/
#
# TODO: push to apache/thrift-compiler instead of thrift/thrift-compiler
FROM debian:jessie
MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
ADD . /thrift
RUN buildDeps=" \
flex \
bison \
g++ \
make \
cmake \
curl \
"; \
apt-get update && apt-get install -y --no-install-recommends $buildDeps \
&& mkdir /tmp/cmake-build && cd /tmp/cmake-build \
&& cmake \
-DBUILD_COMPILER=ON \
-DBUILD_LIBRARIES=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
/thrift \
&& cmake --build . --config Release \
&& make install \
&& curl -k -sSL "https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz" -o /tmp/go.tar.gz \
&& tar xzf /tmp/go.tar.gz -C /tmp \
&& cp /tmp/go/bin/gofmt /usr/bin/gofmt \
&& apt-get purge -y --auto-remove $buildDeps \
&& apt-get clean \
&& rm -rf /tmp/* \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["thrift"]

355
vendor/git.apache.org/thrift.git/LANGUAGES.md generated vendored Normal file
View file

@ -0,0 +1,355 @@
# Apache Thrift Language Support #
Last Modified: 2018-12-17
Guidance For: 0.12.0 or later
Thrift supports many programming languages and has an impressive test suite that exercises most of the languages, protocols, and transports that represents a matrix of thousands of possible combinations. Each language typically has a minimum required version as well as support libraries - some mandatory and some optional. All of this information is provided below to help you assess whether you can use Apache Thrift with your project. Obviously this is a complex matrix to maintain and may not be correct in all cases - if you spot an error please inform the developers using the mailing list.
Apache Thrift has a choice of two build systems. The `autoconf` build system is the most complete build and is used to build all supported languages. The `cmake` build system has been designated by the project to replace `autoconf` however this transition will take quite some time to complete.
The Language/Library Levels indicate the minimum and maximum versions that are used in the [continuous integration environments](build/docker/README.md) (Appveyor, Travis) for Apache Thrift. Other language levels may be supported for each language, however tested less thoroughly; check the README file inside each lib directory for additional details. Note that while a language may contain support for protocols, transports, and servers, the extent to which each is tested as part of the overall build process varies. The definitive integration test for the project is called the "cross" test which executes a test matrix with clients and servers communicating across languages.
<table style="font-size: 60%; padding: 1px;">
<thead>
<tr>
<th rowspan=2>Language</th>
<th rowspan=2 align=center>Since</th>
<th colspan=2 align=center>Build Systems</th>
<th colspan=2 align=center>Lang/Lib Levels (Tested)</th>
<th colspan=6 align=center>Low-Level Transports</th>
<th colspan=3 align=center>Transport Wrappers</th>
<th colspan=4 align=center>Protocols</th>
<th colspan=5 align=center>Servers</th>
<th rowspan=2>Open Issues</th>
</tr>
<tr>
<!-- Build Systems ---------><th>autoconf</th><th>cmake</th>
<!-- Lang/Lib Levels -------><th>Min</th><th>Max</th>
<!-- Low-Level Transports --><th><a href="https://en.wikipedia.org/wiki/Unix_domain_socket">Domain</a></th><th>&nbsp;File&nbsp;</th><th>Memory</th><th>&nbsp;Pipe&nbsp;</th><th>Socket</th><th>&nbsp;TLS&nbsp;</th>
<!-- Transport Wrappers ----><th>Framed</th><th>&nbsp;http&nbsp;</th><th>&nbsp;zlib&nbsp;</th>
<!-- Protocols -------------><th><a href="doc/specs/thrift-binary-protocol.md">Binary</a></th><th><a href="doc/specs/thrift-compact-protocol.md">Compact</a></th><th>&nbsp;JSON&nbsp;</th><th>Multiplex</th>
<!-- Servers ---------------><th>Forking</th><th>Nonblocking</th><th>Simple</th><th>Threaded</th><th>ThreadPool</th>
</tr>
</thead>
<tbody>
<tr align=center>
<td align=left><a href="lib/as3/README.md">ActionScript</a></td>
<!-- Since -----------------><td>0.3.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>ActionScript 3</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12313722">ActionScript</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/c_glib/README.md">C (glib)</a></td>
<!-- Since -----------------><td>0.6.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Language Levels -------><td>2.48.2</td><td>2.54.0</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12313854">C (glib)</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/cpp/README.md">C++</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Language Levels -------><td colspan=2>C++98</td>
<!-- Low-Level Transports --><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312313">C++</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/csharp/README.md">C#</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>.NET&nbsp;3.5 / mono&nbsp;3.2.8.0</td><td>.NET&nbsp;4.6.1 / mono&nbsp;4.6.2.7</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312362">C# (.NET)</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/cocoa/README.md">Cocoa</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>unknown</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312398">Cocoa</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/cl/README.md">Common Lisp</a></td>
<!-- Since -----------------><td>0.12.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>SBCL 1.4.5</td><td>SBCL 1.4.9</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT-82">Common Lisp</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/d/README.md">Dlang</a></td>
<!-- Since -----------------><td>0.9.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>2.075.1</td><td>2.081.0</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12317904">D</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/dart/README.md">Dart</a></td>
<!-- Since -----------------><td>0.10.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>1.22.1</td><td>1.24.3</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12328006">Dart</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/delphi/README.md">Delphi</a></td>
<!-- Since -----------------><td>0.8.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>2010</td><td>unknown</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12316601">Delphi</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/netcore/README.md">.NET Core</a></td>
<!-- Since -----------------><td>0.11.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>2.1.4</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12331176">.NET Core</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/erl/README.md">Erlang</a></td>
<!-- Since -----------------><td>0.3.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>18.3</td><td>20.0.4</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312390">Erlang</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/go/README.md">Go</a></td>
<!-- Since -----------------><td>0.7.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>1.7.6</td><td>1.10.3</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12314307">Go</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/hs/README.md">Haskell</a></td>
<!-- Since -----------------><td>0.5.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Language Levels -------><td>7.10.3</td><td>8.0.2</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312704">Haskell</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/haxe/README.md">Haxe</a></td>
<!-- Since -----------------><td>0.9.3</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>3.2.1</td><td>3.4.4</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12324347">Haxe</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/java/README.md">Java (SE)</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Language Levels -------><td colspan=2>1.8.0_151</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312314">Java SE</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/javame/README.md">Java (ME)</a></td>
<!-- Since -----------------><td>0.5.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>unknown</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12313759">Java ME</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/js/README.md">Javascript</a></td>
<!-- Since -----------------><td>0.3.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>unknown</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12313418">Javascript</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/lua/README.md">Lua</a></td>
<!-- Since -----------------><td>0.9.2</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>5.1.5</td><td>5.2.4</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12322659">Lua</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/nodejs/README.md">node.js</a></td>
<!-- Since -----------------><td>0.6.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>6.x</td><td>8.11.3</td>
<!-- Low-Level Transports --><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12314320">node.js</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/nodets/README.md">node.ts</a></td>
<!-- Since -----------------><td>0.12.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>3.1.6</td><td></td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/issues/?jql=project%20%3D%20THRIFT%20AND%20resolution%20%3D%20Unresolved%20and%20Component%20in%20(%22TypeScript%20-%20Library%22)%20ORDER%20BY%20priority%20DESC%2C%20updated%20DESC">node.ts</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/ocaml/README.md">OCaml</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>4.04.0</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12313660">OCaml</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/perl/README.md">Perl</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>5.22.1</td><td>5.26.0</td>
<!-- Low-Level Transports --><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312312">Perl</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/php/README.md">PHP</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>7.0.22</td><td>7.1.8</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312431">PHP</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/py/README.md">Python</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Language Levels -------><td>2.7.12, 3.5.2</td><td>2.7.14, 3.6.3</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312315">Python</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/rb/README.md">Ruby</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>2.3.1p112</td><td>2.3.3p222</td>
<!-- Low-Level Transports --><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12312316">Ruby</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/rs/README.md">Rust</a></td>
<!-- Since -----------------><td>0.11.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>1.17.0</td><td>1.21.0</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12331420">Rust</a></td>
</tr>
<tr align=center>
<td align=left><a href="lib/st/README.md">Smalltalk</a></td>
<!-- Since -----------------><td>0.2.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td colspan=2>unknown</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<!-- Servers ---------------><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td>
<td align=left><a href="https://issues.apache.org/jira/browse/THRIFT/component/12313861">Smalltalk</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<th rowspan=2>Language</th>
<th rowspan=2 align=center>Since</th>
<!-- Build Systems ---------><th>autoconf</th><th>cmake</th>
<!-- Lang/Lib Levels -------><th>Min</th><th>Max</th>
<!-- Low-Level Transports --><th><a href="https://en.wikipedia.org/wiki/Unix_domain_socket">Domain</a></th></th><th>&nbsp;File&nbsp;</th><th>Memory</th><th>&nbsp;Pipe&nbsp;</th><th>Socket</th><th>&nbsp;TLS&nbsp;</th>
<!-- Transport Wrappers ----><th>Framed</th><th>&nbsp;http&nbsp;</th><th>&nbsp;zlib&nbsp;</th>
<!-- Protocols -------------><th><a href="doc/specs/thrift-binary-protocol.md">Binary</a></th><th><a href="doc/specs/thrift-compact-protocol.md">Compact</a></th><th>&nbsp;JSON&nbsp;</th><th>Multiplex</th>
<!-- Servers ---------------><th>Forking</th><th>Nonblocking</th><th>Simple</th><th>Threaded</th><th>ThreadPool</th>
<th rowspan=2>Open Issues</th>
</tr>
<tr>
<th colspan=2 align=center>Build Systems</th>
<th colspan=2 align=center>Lang/Lib Levels (Tested)</th>
<th colspan=6 align=center>Low-Level Transports</th>
<th colspan=3 align=center>Transport Wrappers</th>
<th colspan=4 align=center>Protocols</th>
<th colspan=5 align=center>Servers</th>
</tr>
</tfoot>
</table>

View file

@ -43,7 +43,7 @@ dist-hook:
find $(distdir) -type d \( -iname ".svn" -or -iname ".git" \) | xargs rm -rf
print-version:
@echo $(VERSION)
@echo $(PACKAGE_VERSION)
.PHONY: precross cross
precross-%: all
@ -54,7 +54,7 @@ empty :=
space := $(empty) $(empty)
comma := ,
CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_D@ @MAYBE_JAVA@ @MAYBE_CSHARP@ @MAYBE_PYTHON@ @MAYBE_PY3@ @MAYBE_RUBY@ @MAYBE_HASKELL@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ @MAYBE_ERLANG@ @MAYBE_LUA@
CROSS_LANGS = @MAYBE_CPP@ @MAYBE_C_GLIB@ @MAYBE_CL@ @MAYBE_D@ @MAYBE_JAVA@ @MAYBE_CSHARP@ @MAYBE_PYTHON@ @MAYBE_PY3@ @MAYBE_RUBY@ @MAYBE_HASKELL@ @MAYBE_PERL@ @MAYBE_PHP@ @MAYBE_GO@ @MAYBE_NODEJS@ @MAYBE_DART@ @MAYBE_ERLANG@ @MAYBE_LUA@ @MAYBE_RS@ @MAYBE_DOTNETCORE@ @MAYBE_NODETS@
CROSS_LANGS_COMMA_SEPARATED = $(subst $(space),$(comma),$(CROSS_LANGS))
if WITH_PY3
@ -65,14 +65,14 @@ endif
if WITH_PYTHON
crossfeature: precross
$(CROSS_PY) test/test.py --retry-count 3 --features .* --skip-known-failures --server $(CROSS_LANGS_COMMA_SEPARATED)
$(CROSS_PY) test/test.py --retry-count 5 --features .* --skip-known-failures --server $(CROSS_LANGS_COMMA_SEPARATED)
else
# feature test needs python build
crossfeature:
endif
cross-%: precross crossfeature
$(CROSS_PY) test/test.py --retry-count 3 --skip-known-failures --server $(CROSS_LANGS_COMMA_SEPARATED) --client $(CROSS_LANGS_COMMA_SEPARATED) --regex "$*"
$(CROSS_PY) test/test.py --retry-count 5 --skip-known-failures --server $(CROSS_LANGS_COMMA_SEPARATED) --client $(CROSS_LANGS_COMMA_SEPARATED) --regex "$*"
cross: cross-.*
@ -111,9 +111,13 @@ EXTRA_DIST = \
.clang-format \
.editorconfig \
.travis.yml \
.rustfmt.toml \
.dockerignore \
appveyor.yml \
bower.json \
build \
bootstrap.sh \
cleanup.sh \
CMakeLists.txt \
composer.json \
contrib \
@ -123,7 +127,7 @@ EXTRA_DIST = \
doap.rdf \
package.json \
sonar-project.properties \
Dockerfile \
LANGUAGES.md \
LICENSE \
CHANGES \
NOTICE \

View file

@ -1,5 +1,5 @@
Apache Thrift
Copyright 2006-2010 The Apache Software Foundation.
Copyright 2006-2017 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
The Apache Software Foundation (http://www.apache.org/).

View file

@ -1,29 +1,66 @@
Apache Thrift
=============
+[![Build Status](https://travis-ci.org/apache/thrift.svg?branch=master)](https://travis-ci.org/apache/thrift)
- +[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/e2qks7enyp9gw7ma?svg=true)](https://ci.appveyor.com/project/apache/thrift)
Introduction
============
Thrift is a lightweight, language-independent software stack with an
associated code generation mechanism for RPC. Thrift provides clean
abstractions for data transport, data serialization, and application
associated code generation mechanism for point-to-point RPC. Thrift provides
clean abstractions for data transport, data serialization, and application
level processing. The code generation system takes a simple definition
language as its input and generates code across programming languages that
language as input and generates code across programming languages that
uses the abstracted stack to build interoperable RPC clients and servers.
![Apache Thrift Layered Architecture](doc/images/thrift-layers.png)
Thrift makes it easy for programs written in different programming
languages to share data and call remote procedures. With support
for [25 programming languages](LANGUAGES.md), chances are Thrift
supports the languages that you currently use.
Thrift is specifically designed to support non-atomic version changes
across client and server code.
For more details on Thrift's design and implementation, take a gander at
the Thrift whitepaper included in this distribution or at the README.md files
For more details on Thrift's design and implementation, see the Thrift
whitepaper included in this distribution, or at the README.md file
in your particular subdirectory of interest.
Hierarchy
=========
Status
======
| Branch | Travis | Appveyor | Coverity Scan | codecov.io | Website |
| :----- | :----- | :------- | :------------ | :--------- | :------ |
| [`master`](https://github.com/apache/thrift/tree/master) | [![Build Status](https://travis-ci.org/apache/thrift.svg?branch=master)](https://travis-ci.org/apache/thrift) | [![Build status](https://ci.appveyor.com/api/projects/status/github/apache/thrift?branch=master&svg=true)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/thrift/history) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/1345/badge.svg)](https://scan.coverity.com/projects/thrift) | | [![Website](https://img.shields.io/badge/official-website-brightgreen.svg)](https://thrift.apache.org/) |
Releases
========
Thrift does not maintain a specific release calendar at this time.
We strive to release twice yearly. Download the [current release](http://thrift.apache.org/download).
License
=======
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Project Hierarchy
=================
thrift/
@ -42,6 +79,7 @@ thrift/
php/
py/
rb/
...
test/
@ -53,10 +91,16 @@ thrift/
Contains a basic tutorial that will teach you how to develop software
using Thrift.
Development
===========
To build the same way Travis CI builds the project you should use docker.
We have [comprehensive building instructions for docker](build/docker/README.md).
Requirements
============
See http://thrift.apache.org/docs/install for an up-to-date list of build requirements.
See http://thrift.apache.org/docs/install for a list of build requirements (may be stale). Alternatively see the docker build environments for a list of prerequisites.
Resources
=========
@ -145,22 +189,4 @@ To run the cross-language test suite, please run:
This will run a set of tests that use different language clients and
servers.
License
=======
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

16
vendor/git.apache.org/thrift.git/Thrift-swift3.podspec generated vendored Normal file
View file

@ -0,0 +1,16 @@
Pod::Spec.new do |s|
s.name = "Thrift-swift3"
s.version = "0.12.0"
s.summary = "Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC."
s.description = <<-DESC
The Apache Thrift software framework, for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.
DESC
s.homepage = "http://thrift.apache.org"
s.license = { :type => 'Apache License, Version 2.0', :url => 'https://www.apache.org/licenses/LICENSE-2.0' }
s.author = { "Apache Thrift Developers" => "dev@thrift.apache.org" }
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
s.requires_arc = true
s.source = { :git => "https://github.com/apache/thrift.git", :tag => "0.12.0" }
s.source_files = "lib/swift/Sources/*.swift"
end

View file

@ -1,18 +1,18 @@
Pod::Spec.new do |s|
s.name = "Thrift"
s.version = "0.10.0"
s.version = "0.12.0"
s.summary = "Apache Thrift is a lightweight, language-independent software stack with an associated code generation mechanism for RPC."
s.description = <<-DESC
The Apache Thrift software framework, for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.
DESC
s.homepage = "http://thrift.apache.org"
s.license = { :type => 'Apache License, Version 2.0', :url => 'https://raw.github.com/apache/thrift/thrift-0.9.0/LICENSE' }
s.author = { "The Apache Software Foundation" => "apache@apache.org" }
s.license = { :type => 'Apache License, Version 2.0', :url => 'https://www.apache.org/licenses/LICENSE-2.0' }
s.author = { "Apache Thrift Developers" => "dev@thrift.apache.org" }
s.requires_arc = true
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.8'
s.ios.framework = 'CFNetwork'
s.osx.framework = 'CoreServices'
s.source = { :git => "https://github.com/apache/thrift.git", :tag => "thrift-0.10.0" }
s.source = { :git => "https://github.com/apache/thrift.git", :tag => "0.12.0" }
s.source_files = 'lib/cocoa/src/**/*.{h,m,swift}'
end
end

View file

@ -1,5 +1,5 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
# https://www.gnu.org/software/autoconf-archive/ax_boost_base.html
# ===========================================================================
#
# SYNOPSIS
@ -33,7 +33,15 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 23
#serial 45
# example boost program (need to pass version)
m4_define([_AX_BOOST_BASE_PROGRAM],
[AC_LANG_PROGRAM([[
#include <boost/version.hpp>
]],[[
(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))]));
]])])
AC_DEFUN([AX_BOOST_BASE],
[
@ -44,101 +52,121 @@ AC_ARG_WITH([boost],
or disable it (ARG=no)
@<:@ARG=yes@:>@ ])],
[
if test "$withval" = "no"; then
want_boost="no"
elif test "$withval" = "yes"; then
want_boost="yes"
ac_boost_path=""
else
want_boost="yes"
ac_boost_path="$withval"
fi
AS_CASE([$withval],
[no],[want_boost="no";_AX_BOOST_BASE_boost_path=""],
[yes],[want_boost="yes";_AX_BOOST_BASE_boost_path=""],
[want_boost="yes";_AX_BOOST_BASE_boost_path="$withval"])
],
[want_boost="yes"])
AC_ARG_WITH([boost-libdir],
AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
[Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
[
if test -d "$withval"
then
ac_boost_lib_path="$withval"
else
AC_MSG_ERROR(--with-boost-libdir expected directory name)
fi
],
[ac_boost_lib_path=""]
)
[AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
[Force given directory for boost libraries.
Note that this will override library path detection,
so use this parameter only if default library detection fails
and you know exactly where your boost libraries are located.])],
[
AS_IF([test -d "$withval"],
[_AX_BOOST_BASE_boost_lib_path="$withval"],
[AC_MSG_ERROR([--with-boost-libdir expected directory name])])
],
[_AX_BOOST_BASE_boost_lib_path=""])
if test "x$want_boost" = "xyes"; then
boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
if test "x$boost_lib_version_req_sub_minor" = "x" ; then
boost_lib_version_req_sub_minor="0"
fi
WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
BOOST_LDFLAGS=""
BOOST_CPPFLAGS=""
AS_IF([test "x$want_boost" = "xyes"],
[_AX_BOOST_BASE_RUNDETECT([$1],[$2],[$3])])
AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS)
])
# convert a version string in $2 to numeric and affect to polymorphic var $1
AC_DEFUN([_AX_BOOST_BASE_TONUMERICVERSION],[
AS_IF([test "x$2" = "x"],[_AX_BOOST_BASE_TONUMERICVERSION_req="1.20.0"],[_AX_BOOST_BASE_TONUMERICVERSION_req="$2"])
_AX_BOOST_BASE_TONUMERICVERSION_req_shorten=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\.[[0-9]]*\)'`
_AX_BOOST_BASE_TONUMERICVERSION_req_major=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\)'`
AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_major" = "x"],
[AC_MSG_ERROR([You should at least specify libboost major version])])
_AX_BOOST_BASE_TONUMERICVERSION_req_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.\([[0-9]]*\)'`
AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_minor" = "x"],
[_AX_BOOST_BASE_TONUMERICVERSION_req_minor="0"])
_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
AS_IF([test "X$_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor" = "X"],
[_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor="0"])
_AX_BOOST_BASE_TONUMERICVERSION_RET=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req_major \* 100000 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_minor \* 100 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor`
AS_VAR_SET($1,$_AX_BOOST_BASE_TONUMERICVERSION_RET)
])
dnl Run the detection of boost should be run only if $want_boost
AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
_AX_BOOST_BASE_TONUMERICVERSION(WANT_BOOST_VERSION,[$1])
succeeded=no
AC_REQUIRE([AC_CANONICAL_HOST])
dnl On 64-bit systems check for system libraries in both lib64 and lib.
dnl The former is specified by FHS, but e.g. Debian does not adhere to
dnl this (as it rises problems for generic multi-arch support).
dnl The last entry in the list is chosen by default when no libraries
dnl are found, e.g. when only header-only libraries are installed!
libsubdirs="lib"
ax_arch=`uname -m`
case $ax_arch in
x86_64|ppc64|s390x|sparc64|aarch64)
libsubdirs="lib64 lib lib64"
;;
esac
AS_CASE([${host_cpu}],
[x86_64],[libsubdirs="lib64 libx32 lib lib64"],
[ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"],
[libsubdirs="lib"]
)
dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give
dnl them priority over the other paths since, if libs are found there, they
dnl are almost assuredly the ones desired.
AC_REQUIRE([AC_CANONICAL_HOST])
libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs"
case ${host_cpu} in
i?86)
libsubdirs="lib/i386-${host_os} $libsubdirs"
;;
esac
AS_CASE([${host_cpu}],
[i?86],[multiarch_libsubdir="lib/i386-${host_os}"],
[multiarch_libsubdir="lib/${host_cpu}-${host_os}"]
)
dnl first we check the system location for boost libraries
dnl this location ist chosen if boost libraries are installed with the --layout=system option
dnl or if you install boost with RPM
if test "$ac_boost_path" != ""; then
BOOST_CPPFLAGS="-I$ac_boost_path/include"
for ac_boost_path_tmp in $libsubdirs; do
if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
break
fi
done
elif test "$cross_compiling" != yes; then
for ac_boost_path_tmp in $lt_sysroot/usr $lt_sysroot/usr/local $lt_sysroot/opt $lt_sysroot/opt/local ; do
if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
for libsubdir in $libsubdirs ; do
if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"])
AS_IF([test -d "$_AX_BOOST_BASE_boost_path/include" && test -r "$_AX_BOOST_BASE_boost_path/include"],[
AC_MSG_RESULT([yes])
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include"
for _AX_BOOST_BASE_boost_path_tmp in $multiarch_libsubdir $libsubdirs; do
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) lib path in "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"])
AS_IF([test -d "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" && test -r "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" ],[
AC_MSG_RESULT([yes])
BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp";
break;
],
[AC_MSG_RESULT([no])])
done],[
AC_MSG_RESULT([no])])
],[
if test X"$cross_compiling" = Xyes; then
search_libsubdirs=$multiarch_libsubdir
else
search_libsubdirs="$multiarch_libsubdir $libsubdirs"
fi
for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then
for libsubdir in $search_libsubdirs ; do
if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path_tmp/$libsubdir"
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path_tmp/include"
break;
fi
done
fi
])
dnl overwrite ld flags if we have required special directory with
dnl --with-boost-libdir parameter
if test "$ac_boost_lib_path" != ""; then
BOOST_LDFLAGS="-L$ac_boost_lib_path"
fi
AS_IF([test "x$_AX_BOOST_BASE_boost_lib_path" != "x"],
[BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_lib_path"])
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION)])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
@ -149,15 +177,7 @@ if test "x$want_boost" = "xyes"; then
AC_REQUIRE([AC_PROG_CXX])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= $WANT_BOOST_VERSION
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
@ -169,30 +189,50 @@ if test "x$want_boost" = "xyes"; then
dnl if we found no boost with system layout we search for boost libraries
dnl built and installed without the --layout=system option or for a staged(not installed) version
if test "x$succeeded" != "xyes"; then
if test "x$succeeded" != "xyes" ; then
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
BOOST_CPPFLAGS=
if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
BOOST_LDFLAGS=
fi
_version=0
if test "$ac_boost_path" != ""; then
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
if test -n "$_AX_BOOST_BASE_boost_path" ; then
if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path"; then
for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "$V_CHECK" = "1" ; then
if test "x$V_CHECK" = "x1" ; then
_version=$_version_tmp
fi
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include/boost-$VERSION_UNDERSCORE"
done
dnl if nothing found search for layout used in Windows distributions
if test -z "$BOOST_CPPFLAGS"; then
if test -d "$_AX_BOOST_BASE_boost_path/boost" && test -r "$_AX_BOOST_BASE_boost_path/boost"; then
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path"
fi
fi
dnl if we found something and BOOST_LDFLAGS was unset before
dnl (because "$_AX_BOOST_BASE_boost_lib_path" = ""), set it here.
if test -n "$BOOST_CPPFLAGS" && test -z "$BOOST_LDFLAGS"; then
for libsubdir in $libsubdirs ; do
if ls "$_AX_BOOST_BASE_boost_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$libsubdir"
fi
fi
else
if test "$cross_compiling" != yes; then
for ac_boost_path in $lt_sysroot/usr $lt_sysroot/usr/local $lt_sysroot/opt $lt_sysroot/opt/local ; do
if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
if test "x$cross_compiling" != "xyes" ; then
for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do
if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then
for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "$V_CHECK" = "1" ; then
if test "x$V_CHECK" = "x1" ; then
_version=$_version_tmp
best_path=$ac_boost_path
best_path=$_AX_BOOST_BASE_boost_path
fi
done
fi
@ -200,7 +240,7 @@ if test "x$want_boost" = "xyes"; then
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
if test "$ac_boost_lib_path" = ""; then
if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
for libsubdir in $libsubdirs ; do
if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
@ -208,7 +248,7 @@ if test "x$want_boost" = "xyes"; then
fi
fi
if test "x$BOOST_ROOT" != "x"; then
if test -n "$BOOST_ROOT" ; then
for libsubdir in $libsubdirs ; do
if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
@ -217,7 +257,7 @@ if test "x$want_boost" = "xyes"; then
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
V_CHECK=`expr $stage_version_shorten \>\= $_version`
if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
if test "x$V_CHECK" = "x1" && test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
BOOST_CPPFLAGS="-I$BOOST_ROOT"
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
@ -232,15 +272,7 @@ if test "x$want_boost" = "xyes"; then
export LDFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <boost/version.hpp>
]], [[
#if BOOST_VERSION >= $WANT_BOOST_VERSION
// Everything is okay
#else
# error Boost version is too old
#endif
]])],[
AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
@ -249,17 +281,15 @@ if test "x$want_boost" = "xyes"; then
AC_LANG_POP([C++])
fi
if test "$succeeded" != "yes" ; then
if test "$_version" = "0" ; then
AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
if test "x$succeeded" != "xyes" ; then
if test "x$_version" = "x0" ; then
AC_MSG_NOTICE([[We could not detect the boost libraries (version $1 or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
else
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
fi
# execute ACTION-IF-NOT-FOUND (if present):
ifelse([$3], , :, [$3])
else
AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS)
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
# execute ACTION-IF-FOUND (if present):
ifelse([$2], , :, [$2])
@ -267,6 +297,5 @@ if test "x$want_boost" = "xyes"; then
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])

View file

@ -1,5 +1,5 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
# https://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
# ===========================================================================
#
# SYNOPSIS
@ -32,7 +32,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 8
#serial 10
AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
AC_DEFUN([AX_CHECK_OPENSSL], [
@ -51,7 +51,7 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
], [
# if pkg-config is installed and openssl has installed a .pc file,
# then use that information and don't search ssldirs
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
if test x"$PKG_CONFIG" != x""; then
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
if test $? = 0; then

View file

@ -1,5 +1,5 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html
# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
# ===========================================================================
#
# SYNOPSIS
@ -79,7 +79,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 11
#serial 12
dnl #########################################################################
AC_DEFUN([AX_COMPARE_VERSION], [

View file

@ -0,0 +1,948 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
# or '14' (for the C++14 standard).
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
# required and that the macro should error out if no mode with that
# support is found. If specified 'optional', then configuration proceeds
# regardless, after defining HAVE_CXX${VERSION} if and only if a
# supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 10
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
[$2], [noext], [],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
AC_LANG_PUSH([C++])dnl
ac_success=no
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
switch="-std=gnu++${alternative}"
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
fi])
m4_if([$2], [ext], [], [dnl
if test x$ac_success = xno; then
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
if test x$ac_success = xyes; then
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
fi
if test x$ac_success = xno; then
HAVE_CXX$1=0
AC_MSG_NOTICE([No compiler with C++$1 support was found])
else
HAVE_CXX$1=1
AC_DEFINE(HAVE_CXX$1,1,
[define if the compiler supports basic C++$1 syntax])
fi
AC_SUBST(HAVE_CXX$1)
])
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual void f() {}
};
struct Derived : public Base
{
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_separators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])
dnl Tests for new features in C++17
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201703L
#error "This is not a C++17 compiler"
#else
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
namespace test_constexpr_lambdas
{
constexpr int foo = [](){return 42;}();
}
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
namespace test_template_argument_deduction_for_class_templates
{
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
namespace test_structured_bindings
{
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
namespace test_exception_spec_type_system
{
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus < 201703L
]])

View file

@ -1,26 +1,23 @@
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# The first argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The second argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline C++11 support is required and that the macro
# should error out if no mode with that support is found. If specified
# 'optional', then configuration proceeds regardless, after defining
# HAVE_CXX11 if and only if a supporting mode is found.
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++11. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
@ -28,138 +25,15 @@
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 10
#serial 18
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
struct Base {
virtual void f() {}
};
struct Child : public Base {
virtual void f() override {}
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
auto l = [](){};
// Prevent Clang error: unused variable 'l' [-Werror,-Wunused-variable]
struct use_l { use_l() { l(); } };
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this
namespace test_template_alias_sfinae {
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() {
func<foo>(0);
}
}
]])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
ax_cv_cxx_compile_cxx11,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx11=yes],
[ax_cv_cxx_compile_cxx11=no])])
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
ac_success=yes
fi
m4_if([$1], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++11 -std=gnu++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=c++11 -std=c++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx11_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
fi
else
if test x$ac_success = xno; then
HAVE_CXX11=0
AC_MSG_NOTICE([No compiler with C++11 support was found])
else
HAVE_CXX11=1
AC_DEFINE(HAVE_CXX11,1,
[define if the compiler supports basic C++11 syntax])
fi
AC_SUBST(HAVE_CXX11)
fi
])
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])

View file

@ -118,7 +118,7 @@ AC_DEFUN([AX_CHECK_JAVA_CLASS],
AC_DEFUN([AX_CHECK_ANT_VERSION],
[
AC_MSG_CHECKING(for ant version > $2)
ANT_VALID=`expr $($1 -version 2>/dev/null | sed -n 's/.*version \(@<:@0-9\.@:>@*\).*/\1/p') \>= $2`
ANT_VALID=`expr "x$(printf "$2\n$($1 -version 2>/dev/null | sed -n 's/.*version \(@<:@0-9\.@:>@*\).*/\1/p')" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -g | sed -n 1p)" = "x$2"`
if test "x$ANT_VALID" = "x1" ; then
AC_MSG_RESULT(yes)
else

View file

@ -1,5 +1,5 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_lua.html
# https://www.gnu.org/software/autoconf-archive/ax_lua.html
# ===========================================================================
#
# SYNOPSIS
@ -166,7 +166,7 @@
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
@ -181,7 +181,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 39
#serial 40
dnl =========================================================================
dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION],

View file

@ -0,0 +1,61 @@
# ===============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_prog_dotnetcore_version.html
# ===============================================================================
#
# SYNOPSIS
#
# AX_PROG_DOTNETCORE_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])
#
# DESCRIPTION
#
# Makes sure that .NET Core supports the version indicated. If true the
# shell commands in ACTION-IF-TRUE are executed. If not the shell commands
# in ACTION-IF-FALSE are run. The $dotnetcore_version variable will be
# filled with the detected version.
#
# This macro uses the $DOTNETCORE variable to perform the check. If
# $DOTNETCORE is not set prior to calling this macro, the macro will fail.
#
# Example:
#
# AC_PATH_PROG([DOTNETCORE],[dotnet])
# AC_PROG_DOTNETCORE_VERSION([1.0.2],[ ... ],[ ... ])
#
# Searches for .NET Core, then checks if at least version 1.0.2 is
# present.
#
# LICENSE
#
# Copyright (c) 2016 Jens Geyer <jensg@apache.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 2
AC_DEFUN([AX_PROG_DOTNETCORE_VERSION],[
AC_REQUIRE([AC_PROG_SED])
AS_IF([test -n "$DOTNETCORE"],[
ax_dotnetcore_version="$1"
AC_MSG_CHECKING([for .NET Core version])
dotnetcore_version=`$DOTNETCORE --version 2>&1 | $SED -e 's/\(@<:@0-9@:>@*\.@<:@0-9@:>@*\.@<:@0-9@:>@*\)\(.*\)/\1/'`
AC_MSG_RESULT($dotnetcore_version)
AC_SUBST([DOTNETCORE_VERSION],[$dotnetcore_version])
AX_COMPARE_VERSION([$ax_dotnetcore_version],[le],[$dotnetcore_version],[
:
$2
],[
:
$3
])
],[
AC_MSG_WARN([could not find .NET Core])
$3
])
])

View file

@ -1,5 +1,5 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_prog_haxe_version.html
# https://www.gnu.org/software/autoconf-archive/ax_prog_haxe_version.html
# ===========================================================================
#
# SYNOPSIS
@ -32,7 +32,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 1
#serial 2
AC_DEFUN([AX_PROG_HAXE_VERSION],[
AC_REQUIRE([AC_PROG_SED])

View file

@ -1,5 +1,5 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html
# https://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html
# ===========================================================================
#
# SYNOPSIS
@ -32,7 +32,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 7
#serial 8
AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES])
AC_DEFUN([AX_PROG_PERL_MODULES],[dnl

View file

@ -1,3 +1,4 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@ -18,76 +19,92 @@
# build Apache Thrift on AppVeyor - https://ci.appveyor.com
shallow_clone: true
clone_depth: 10
version: '0.12.0.{build}'
shallow_clone: true
version: '{build}'
os:
# - Windows Server 2012 R2
- Visual Studio 2015
- Visual Studio 2017
matrix:
allow_failures:
- PROFILE: CYGWIN
fast_finish: true
environment:
BOOST_ROOT: C:\Libraries\boost_1_59_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0
# Unfurtunately, this version needs manual update because old versions are quickly deleted.
ANT_VERSION: 1.9.7
matrix:
- PROFILE: MSVC2017
PLATFORM: x64
CONFIGURATION: Release
BOOST_VERSION: 1.65.1
LIBEVENT_VERSION: 2.1.8
PYTHON_VERSION: 3.6
QT_VERSION: 5.10
ZLIB_VERSION: 1.2.11
DISABLED_TESTS: StressTestNonBlocking
- PROFILE: MSVC2013
PLATFORM: x86
CONFIGURATION: Release
BOOST_VERSION: 1.58.0
LIBEVENT_VERSION: 2.0.22
PYTHON_VERSION: 3.5
QT_VERSION: 5.8
ZLIB_VERSION: 1.2.8
DISABLED_TESTS: StressTestNonBlocking
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- PROFILE: MINGW
PLATFORM: x64
CONFIGURATION: RelWithDebInfo
DISABLED_TESTS: StressTestNonBlocking
- PROFILE: CYGWIN
PLATFORM: x86
CONFIGURATION: RelWithDebInfo
DISABLED_TESTS: (ZlibTest|OpenSSLManualInitTest|TNonblockingServerTest|StressTestNonBlocking)
# - PROFILE: CYGWIN
# PLATFORM: x64
# CONFIGURATION: RelWithDebInfo
# DISABLED_TESTS: (ZlibTest|OpenSSLManualInitTest|TNonblockingServerTest|StressTestNonBlocking)
install:
- '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64'
- cd \
# Zlib
- appveyor DownloadFile https://github.com/madler/zlib/archive/v1.2.8.tar.gz
- 7z x v1.2.8.tar.gz -so | 7z x -si -ttar > nul
- cd zlib-1.2.8
- cmake -G "Visual Studio 14 2015 Win64" .
- cmake --build . --config release
- cd ..
# OpenSSL
- C:\Python35-x64\python %APPVEYOR_BUILD_FOLDER%\build\appveyor\download_openssl.py
- ps: Start-Process "Win64OpenSSL.exe" -ArgumentList "/silent /verysilent /sp- /suppressmsgboxes" -Wait
# Libevent
- appveyor DownloadFile https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
- 7z x libevent-2.0.22-stable.tar.gz -so | 7z x -si -ttar > nul
- cd libevent-2.0.22-stable
- nmake -f Makefile.nmake
- mkdir lib
- move *.lib lib\
- move WIN32-Code\event2\* include\event2\
- move *.h include\
- cd ..
- appveyor-retry cinst -y winflexbison
- appveyor DownloadFile http://www.us.apache.org/dist/ant/binaries/apache-ant-%ANT_VERSION%-bin.zip
- 7z x apache-ant-%ANT_VERSION%-bin.zip > nul
- cd %APPVEYOR_BUILD_FOLDER%
# TODO: Enable Haskell build
# - cinst HaskellPlatform -version 2014.2.0.0
- cd %APPVEYOR_BUILD_FOLDER%
- call build\appveyor\%PROFILE:~0,4%-appveyor-install.bat
- refreshenv
build_script:
- set PATH=C:\ProgramData\chocolatey\bin;C:\apache-ant-%ANT_VERSION%\bin;%PATH%
- set JAVA_HOME=C:\Program Files\Java\jdk1.7.0
- set PATH=%JAVA_HOME%\bin;%PATH%
# - set PATH=%PATH%;C:\Program Files (x86)\Haskell Platform\2014.2.0.0\bin
# - set PATH=%PATH%;C:\Program Files (x86)\Haskell Platform\2014.2.0.0\lib\extralibs\bin
- set PATH=C:\Python27-x64\scripts;C:\Python27-x64;%PATH%
- pip install ipaddress backports.ssl_match_hostname tornado twisted
- mkdir cmake-build
- cd cmake-build
- cmake -G "Visual Studio 14 2015 Win64" -DWITH_SHARED_LIB=OFF -DLIBEVENT_ROOT=C:\libevent-2.0.22-stable -DZLIB_INCLUDE_DIR=C:\zlib-1.2.8 -DZLIB_LIBRARY=C:\zlib-1.2.8\release\zlibstatic.lib -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" ..
- findstr /b /e BUILD_COMPILER:BOOL=ON CMakeCache.txt
- findstr /b /e BUILD_CPP:BOOL=ON CMakeCache.txt
- findstr /b /e BUILD_JAVA:BOOL=ON CMakeCache.txt
- findstr /b /e BUILD_PYTHON:BOOL=ON CMakeCache.txt
# - findstr /b /e BUILD_C_GLIB:BOOL=ON CMakeCache.txt
# - findstr /b /e BUILD_HASKELL:BOOL=ON CMakeCache.txt
- findstr /b /e BUILD_TESTING:BOOL=ON CMakeCache.txt
# - cmake --build .
- cmake --build . --config Release
# TODO: Fix cpack
# - cpack
# TODO: Run more tests
# CTest fails to invoke ant seemingly due to "ant.bat" v.s. "ant" (shell script) conflict.
# Currently, everything that involves OpenSSL seems to hang forever on our Appveyor setup.
# Also a few C++ tests hang (on Appveyor or on Windows in general).
- ctest -C Release --timeout 600 -VV -E "(StressTestNonBlocking|PythonTestSSLSocket|python_test$|^Java)"
# TODO make it perfect ;-r
- cd %APPVEYOR_BUILD_FOLDER%
- call build\appveyor\%PROFILE:~0,4%-appveyor-build.bat
test_script:
- cd %APPVEYOR_BUILD_FOLDER%
- call build\appveyor\%PROFILE:~0,4%-appveyor-test.bat
# artifact capture disabled as it might increase service cost for little gain:
#
# artifacts:
# - path: local-thrift-inst
# name: cmake installed content
# type: zip
#
# - path: local-thrift-build\Testing
# name: ctest output
# type: zip
# RDP support: use one or the other...
#
# enables RDP for each build job so you can inspect the environment at the beginning of the job:
# init:
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#
# enables RDP at the end of the build job so you can login and re-run
# commands to see why something failed...
#on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
#
# also need:
# environment:
# APPVEYOR_RDP_PASSWORD: thr1FT2345$xyzZ

View file

@ -38,17 +38,24 @@ else
exit 1
fi
format_version () {
printf "%03d%03d%03d%03d" $(echo $1 | tr '.' ' ');
}
# we require automake 1.13 or later
# check must happen externally due to use of newer macro
AUTOMAKE_VERSION=`automake --version | grep automake | egrep -o '([0-9]{1,}\.)+[0-9]{1,}'`
if [ "$AUTOMAKE_VERSION" \< "1.13" ]; then
if [ $(format_version $AUTOMAKE_VERSION) -lt $(format_version 1.13) ]; then
echo >&2 "automake version $AUTOMAKE_VERSION is too old (need 1.13 or later)"
exit 1
fi
set -e
autoscan
$LIBTOOLIZE --copy --automake
aclocal -I ./aclocal
autoheader
sed '/undef VERSION/d' config.hin > config.hin2
mv config.hin2 config.hin
autoconf
automake --copy --add-missing --foreign

View file

@ -1,6 +1,6 @@
{
"name": "thrift",
"version": "0.10.0",
"version": "0.12.0",
"homepage": "https://git-wip-us.apache.org/repos/asf/thrift.git",
"authors": [
"Apache Thrift <dev@thrift.apache.org>"

View file

@ -1,41 +0,0 @@
import urllib.request
import sys
OUT = 'Win64OpenSSL.exe'
URL_STR = 'https://slproweb.com/download/Win64OpenSSL-%s.exe'
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_PATCH = 2
VERSION_SUFFIX = 'j'
VERSION_STR = '%d_%d_%d%s'
TRY_COUNT = 4
def main():
for patch in range(VERSION_PATCH, TRY_COUNT):
for suffix in range(TRY_COUNT):
if patch == VERSION_PATCH:
s = VERSION_SUFFIX
else:
s = 'a'
s = chr(ord(s) + suffix)
ver = VERSION_STR % (VERSION_MAJOR, VERSION_MINOR, patch, s)
url = URL_STR % ver
try:
with urllib.request.urlopen(url) as res:
if res.getcode() == 200:
with open(OUT, 'wb') as out:
out.write(res.read())
print('successfully downloaded from ' + url)
return 0
except urllib.error.HTTPError:
pass
print('failed to download from ' + url, file=sys.stderr)
print('could not download openssl', file=sys.stderr)
return 1
if __name__ == '__main__':
sys.exit(main())

View file

@ -17,17 +17,16 @@
# under the License.
#
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckSymbolExists)
# If AI_ADDRCONFIG is not defined we define it as 0
check_symbol_exists(AI_ADDRCONFIG "sys/types.h;sys/socket.h;netdb.h" HAVE_AI_ADDRCONFIG)
if(NOT HAVE_AI_ADDRCONFIG)
set(AI_ADDRCONFIG 1)
endif(NOT HAVE_AI_ADDRCONFIG)
if (Inttypes_FOUND)
# This allows the inttypes.h and stdint.h checks to succeed on platforms that
# do not natively provide there.
set (CMAKE_REQUIRED_INCLUDES ${INTTYPES_INCLUDE_DIRS})
endif ()
check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
@ -35,18 +34,22 @@ check_include_file(getopt.h HAVE_GETOPT_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(netdb.h HAVE_NETDB_H)
check_include_file(netinet/in.h HAVE_NETINET_IN_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(pthread.h HAVE_PTHREAD_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/un.h HAVE_SYS_UN_H)
check_include_file(poll.h HAVE_POLL_H)
check_include_file(sys/poll.h HAVE_SYS_POLL_H)
check_include_file(sys/select.h HAVE_SYS_SELECT_H)
check_include_file(sched.h HAVE_SCHED_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
@ -72,5 +75,5 @@ set(VERSION ${thrift_VERSION})
# generate a config.h file
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/thrift/config.h")
# HACK: Some files include thrift/config.h and some config.h so we include both. This should be cleaned up.
include_directories("${CMAKE_CURRENT_BINARY_DIR}/thrift" "${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

View file

@ -35,7 +35,7 @@ set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
set(CMAKE_COLOR_MAKEFILE ON)
# Define the generic version of the libraries here
set(GENERIC_LIB_VERSION "0.10.0")
set(GENERIC_LIB_VERSION "0.12.0")
set(GENERIC_LIB_SOVERSION "0")
# Set the default build type to release with debug info
@ -68,3 +68,26 @@ set(CMAKE_MACOSX_RPATH TRUE)
# locations and running the executables without LD_PRELOAD or similar.
# This requires the library to be built with rpath support.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#
# C++ Language Level Defaults - this depends on the compiler capabilities
#
if (NOT DEFINED CMAKE_CXX_STANDARD)
if (MSVC AND MSVC_VERSION LESS 1800)
# MSVC 2012 and earlier don't support template aliases so you have to use C++98
set(CMAKE_CXX_STANDARD 98)
message(STATUS "Setting C++98 as the default language level (for an older MSVC compiler).")
else()
set(CMAKE_CXX_STANDARD 11) # C++11
message(STATUS "Setting C++11 as the default language level.")
endif()
message(STATUS "To specify a different C++ language level, set CMAKE_CXX_STANDARD")
endif()
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED OFF) # can degrade to C++98 if compiler does not support C++11
endif()
if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF) # use standards compliant language level for portability
endif()

View file

@ -40,7 +40,17 @@ option(BUILD_LIBRARIES "Build Thrift libraries" ON)
# and enables the library if all are found. This means the default is to build as
# much as possible but leaving out libraries if their dependencies are not met.
CMAKE_DEPENDENT_OPTION(WITH_BOOST_STATIC "Build with Boost static link library" OFF "NOT MSVC" ON)
option(WITH_BOOST_FUNCTIONAL "Use boost/tr1/functional.hpp even under C++11 or later" OFF)
if (WITH_BOOST_FUNCTIONAL)
add_definitions(-DFORCE_BOOST_FUNCTIONAL)
endif()
option(WITH_BOOST_SMART_PTR "Use boost/smart_ptr.hpp even under C++11 or later" OFF)
if (WITH_BOOST_SMART_PTR)
add_definitions(-DFORCE_BOOST_SMART_PTR)
endif()
option(WITH_BOOST_STATIC "Build with Boost static link library" OFF)
set(Boost_USE_STATIC_LIBS ${WITH_BOOST_STATIC})
if (NOT WITH_BOOST_STATIC)
add_definitions(-DBOOST_ALL_DYN_LINK)
@ -84,7 +94,7 @@ if(WITH_CPP)
endif()
CMAKE_DEPENDENT_OPTION(BUILD_CPP "Build C++ library" ON
"BUILD_LIBRARIES;WITH_CPP;Boost_FOUND" OFF)
CMAKE_DEPENDENT_OPTION(WITH_PLUGIN "Build compiler plugin support" ON
CMAKE_DEPENDENT_OPTION(WITH_PLUGIN "Build compiler plugin support" OFF
"BUILD_COMPILER;BUILD_CPP" OFF)
# C GLib
@ -117,10 +127,10 @@ if(ANDROID)
CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java library" ON
"BUILD_LIBRARIES;WITH_JAVA;GRADLE_FOUND" OFF)
else()
find_package(Gradlew QUIET)
find_package(Java QUIET)
find_package(Ant QUIET)
CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java library" ON
"BUILD_LIBRARIES;WITH_JAVA;JAVA_FOUND;ANT_FOUND" OFF)
"BUILD_LIBRARIES;WITH_JAVA;JAVA_FOUND;GRADLEW_FOUND" OFF)
endif()
# Python
@ -164,7 +174,6 @@ message(STATUS "Thrift package version: ${PACKAGE_VERSION}
message(STATUS "Build configuration Summary")
message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}")
message(STATUS " Build compiler plugin support: ${WITH_PLUGIN}")
MESSAGE_DEP(PLUGIN_COMPILER_NOT_TOO_OLD "Disabled due to older compiler")
message(STATUS " Build with unit tests: ${BUILD_TESTING}")
MESSAGE_DEP(HAVE_COMPILER "Disabled because BUILD_THRIFT=OFF and no valid THRIFT_COMPILER is given")
message(STATUS " Build examples: ${BUILD_EXAMPLES}")
@ -174,6 +183,7 @@ message(STATUS " Language libraries:")
message(STATUS " Build C++ library: ${BUILD_CPP}")
MESSAGE_DEP(WITH_CPP "Disabled by WITH_CPP=OFF")
MESSAGE_DEP(Boost_FOUND "Boost headers missing")
message(STATUS " C++ Language Level: ${CXX_LANGUAGE_LEVEL}")
message(STATUS " Build C (GLib) library: ${BUILD_C_GLIB}")
MESSAGE_DEP(WITH_C_GLIB "Disabled by WITH_C_GLIB=OFF")
MESSAGE_DEP(GLIB_FOUND "GLib missing")
@ -183,7 +193,7 @@ if(ANDROID)
MESSAGE_DEP(GRADLE_FOUND "Gradle missing")
else()
MESSAGE_DEP(JAVA_FOUND "Java Runtime missing")
MESSAGE_DEP(ANT_FOUND "Ant missing")
MESSAGE_DEP(GRADLEW_FOUND "Gradle Wrapper missing")
endif()
message(STATUS " Build Python library: ${BUILD_PYTHON}")
MESSAGE_DEP(WITH_PYTHON "Disabled by WITH_PYTHON=OFF")
@ -195,16 +205,15 @@ MESSAGE_DEP(CABAL_FOUND "Cabal missing")
message(STATUS " Library features:")
message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}")
message(STATUS " Build static libraries: ${WITH_STATIC_LIB}")
message(STATUS " Build with ZLIB support: ${WITH_ZLIB}")
message(STATUS " Build with Boost static link library: ${WITH_BOOST_STATIC}")
message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}")
message(STATUS " Build with boost/tr1/functional (forced) ${WITH_BOOST_FUNCTIONAL}")
message(STATUS " Build with boost/smart_ptr (forced) ${WITH_BOOST_SMART_PTR}")
message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}")
message(STATUS " Build with libevent support: ${WITH_LIBEVENT}")
message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}")
message(STATUS " Build with Qt4 support: ${WITH_QT4}")
message(STATUS " Build with Qt5 support: ${WITH_QT5}")
message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}")
message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}")
message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}")
message(STATUS " Build with Boost static link library: ${WITH_BOOST_STATIC}")
if(MSVC)
message(STATUS " - Enabled for Visual C++")
endif()
message(STATUS " Build with ZLIB support: ${WITH_ZLIB}")
message(STATUS "----------------------------------------------------------")
endmacro(PRINT_CONFIG_SUMMARY)

View file

@ -17,6 +17,8 @@
# under the License.
#
# Uncomment this to show some basic cmake variables about platforms
# include (NewPlatformDebug)
# Visual Studio specific options
if(MSVC)
@ -59,9 +61,6 @@ if(MSVC)
set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE)
endif(WITH_MT)
# Disable Windows.h definition of macros for min and max
add_definitions("-DNOMINMAX")
# Disable boost auto linking pragmas - cmake includes the right files
add_definitions("-DBOOST_ALL_NO_LIB")
@ -71,12 +70,25 @@ if(MSVC)
message (FATAL_ERROR "Windows build does not support shared library output yet, please set -DWITH_SHARED_LIB=off")
endif()
add_definitions("/MP") # parallel build
add_definitions("/W3") # warning level 3
# VS2010 does not provide inttypes which we need for "PRId64" used in many places
find_package(Inttypes)
if (Inttypes_FOUND)
include_directories(${INTTYPES_INCLUDE_DIRS})
# OpenSSL conflicts with the definition of PRId64 unless it is defined first
add_definitions("/FIinttypes.h")
endif ()
elseif(UNIX)
find_program( MEMORYCHECK_COMMAND valgrind )
set( MEMORYCHECK_COMMAND_OPTIONS "--gen-suppressions=all --leak-check=full" )
set( MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.suppress" )
endif()
add_definitions("-D__STDC_FORMAT_MACROS")
add_definitions("-D__STDC_LIMIT_MACROS")
# WITH_*THREADS selects which threading library to use
if(WITH_BOOSTTHREADS)
add_definitions("-DUSE_BOOST_THREAD=1")
@ -84,23 +96,34 @@ elseif(WITH_STDTHREADS)
add_definitions("-DUSE_STD_THREAD=1")
endif()
# GCC and Clang.
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# FIXME -pedantic can not be used at the moment because of: https://issues.apache.org/jira/browse/THRIFT-2784
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -Wextra -pedantic")
# FIXME enabling c++11 breaks some Linux builds on Travis by triggering a g++ bug, see
# https://travis-ci.org/apache/thrift/jobs/58017022
# on the other hand, both MacOSX and FreeBSD need c++11
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -Wextra")
# C++ Language Level
set(CXX_LANGUAGE_LEVEL "C++${CMAKE_CXX_STANDARD}")
if (CMAKE_CXX_STANDARD_REQUIRED)
string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [compiler must support it]")
else()
string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [fallback to earlier if compiler does not support it]")
endif()
if (CMAKE_CXX_EXTENSIONS)
string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [with compiler-specific extensions]")
else()
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -Wno-long-long")
endif()
if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-long-long")
endif()
endif()
# If gcc older than 4.8 is detected, disable new compiler plug-in support (see THRIFT-3937)
set(PLUGIN_COMPILER_NOT_TOO_OLD ON) # simplifies messaging in DefineOptions summary
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8" AND WITH_PLUGIN)
message(STATUS "Disabling compiler plug-in support to work with older gcc compiler")
set(WITH_PLUGIN OFF)
set(PLUGIN_COMPILER_NOT_TOO_OLD OFF)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()
# Building WITH_PLUGIN requires boost memory operations, for now, and gcc >= 4.8
if (WITH_PLUGIN)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler")
endif()
message(STATUS "Forcing use of boost::smart_ptr to build WITH_PLUGIN")
add_definitions("-DFORCE_BOOST_SMART_PTR=1")
endif()

View file

@ -13,9 +13,13 @@ foreach(prefix ${LibEvent_EXTRA_PREFIXES})
list(APPEND LibEvent_LIBRARIES_PATHS "${prefix}/lib")
endforeach()
find_path(LIBEVENT_INCLUDE_DIRS event.h PATHS ${LibEvent_INCLUDE_PATHS})
# "lib" prefix is needed on Windows
find_library(LIBEVENT_LIBRARIES NAMES event libevent PATHS ${LibEvent_LIBRARIES_PATHS})
# Looking for "event.h" will find the Platform SDK include dir on windows
# so we also look for a peer header like evhttp.h to get the right path
find_path(LIBEVENT_INCLUDE_DIRS evhttp.h event.h PATHS ${LibEvent_INCLUDE_PATHS})
# "lib" prefix is needed on Windows in some cases
# newer versions of libevent use three libraries
find_library(LIBEVENT_LIBRARIES NAMES event event_core event_extra libevent PATHS ${LibEvent_LIBRARIES_PATHS})
if (LIBEVENT_LIBRARIES AND LIBEVENT_INCLUDE_DIRS)
set(Libevent_FOUND TRUE)

View file

@ -44,9 +44,6 @@
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "${PACKAGE_STRING}"
/* Version number of package */
#define VERSION "${VERSION}"
/************************** DEFINES *************************/
/* Define if the AI_ADDRCONFIG symbol is unavailable */
@ -94,6 +91,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#cmakedefine HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <signal.h> header file. */
#cmakedefine HAVE_SIGNAL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
@ -103,8 +103,8 @@
/* Define to 1 if you have the <pthread.h> header file. */
#cmakedefine HAVE_PTHREAD_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#cmakedefine HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/param.h> header file. */
#cmakedefine HAVE_SYS_PARAM_H 1
@ -121,12 +121,18 @@
/* Define to 1 if you have the <sys/un.h> header file. */
#cmakedefine HAVE_SYS_UN_H 1
/* Define to 1 if you have the <poll.h> header file. */
#cmakedefine HAVE_POLL_H 1
/* Define to 1 if you have the <sys/poll.h> header file. */
#cmakedefine HAVE_SYS_POLL_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
#cmakedefine HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sched.h> header file. */
#cmakedefine HAVE_SCHED_H 1
@ -154,4 +160,4 @@
/* Define to 1 if strerror_r returns char *. */
#cmakedefine STRERROR_R_CHAR_P 1
#endif
#endif

View file

@ -1,27 +1,198 @@
# Apache Thrift Docker containers
A set of docker containers used to build and test Apache Thrift
# Docker Integration #
### Available Containers
Due to the large number of languages supported by Apache Thrift,
docker containers are used to build and test the project on a
variety of platforms to provide maximum test coverage.
* Ubuntu - based on ubuntu:trusty (14.04)
* Centos - based on centos:6.6
## Appveyor Integration ##
## Dependencies
At this time the Appveyor scripts do not use docker containers.
Once Microsoft supports Visual Studio Build Tools running inside
nano containers (instead of Core, which is huge) then we will
consider using containers for the Windows builds as well.
* A working Docker environment. A Vagrantfile is provided which will setup an Ubuntu host and working Docker environment as well as build the Apache Thrift Docker container for testing and development
## Travis CI Integration ##
## Usage
From the Apache Thrift code base root
The Travis CI scripts use the following environment variables and
logic to determine their behavior:
* Build
### Environment Variables ###
docker build -t thrift build/docker/ubuntu
| Variable | Default | Usage |
| -------- | ----- | ------- |
| `DISTRO` | `ubuntu-bionic` | Set by various build jobs in `.travis.yml` to run builds in different containers. Not intended to be set externally.|
| `DOCKER_REPO` | `thrift/thrift-build` | The name of the Docker Hub repository to obtain and store docker images. |
| `DOCKER_USER` | `<none>` | The Docker Hub account name containing the repository. |
| `DOCKER_PASS` | `<none>` | The Docker Hub account password to use when pushing new tags. |
or
For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-bionic`
docker build -t thrift build/docker/centos
### Forks ###
* Run
If you have forked the Apache Thrift repository and you would like
to use your own Docker Hub account to store thrift build images,
you can use the Travis CI web interface to set the `DOCKER_USER`,
`DOCKER_PASS`, and `DOCKER_REPO` variables in a secure manner.
Your fork builds will then pull, push, and tag the docker images
in your account.
docker run -v $(pwd):/thrift/src -it thrift /bin/bash
### Logic ###
The Travis CI build runs in two phases - first the docker images are rebuilt
for each of the supported containers if they do not match the Dockerfile that
was used to build the most recent tag. If a `DOCKER_PASS` environment
variable is specified, the docker stage builds will attempt to log into
Docker Hub and push the resulting tags.
## Supported Containers ##
The Travis CI (continuous integration) builds use the Ubuntu Bionic
(18.04 LTS) and Xenial (16.04 LTS) images to maximize language level
coverage.
### Ubuntu ###
* bionic (stable, current)
* artful (previous stable)
* xenial (legacy)
## Unsupported Containers ##
These containers may be in various states, and may not build everything.
They can be found in the `old/` subdirectory.
### CentOS ###
* 7.3
* make check in lib/py may hang in test_sslsocket - root cause unknown
### Debian ###
* jessie
* stretch
* make check in lib/cpp fails due to https://svn.boost.org/trac10/ticket/12507
## Building like Travis CI does, locally ##
We recommend you build locally the same way Travis CI does, so that when you
submit your pull request you will run into fewer surprises. To make it a
little easier, put the following into your `~/.bash_aliases` file:
# Kill all running containers.
alias dockerkillall='docker kill $(docker ps -q)'
# Delete all stopped containers.
alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# Delete all untagged images.
alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
# Delete all stopped containers and untagged images.
alias dockerclean='dockercleanc || true && dockercleani'
# Build a thrift docker image (run from top level of git repo): argument #1 is image type (ubuntu, centos, etc).
function dockerbuild
{
docker build -t $1 build/docker/$1
}
# Run a thrift docker image: argument #1 is image type (ubuntu, centos, etc).
function dockerrun
{
docker run -v $(pwd):/thrift/src -it $1 /bin/bash
}
Then, to pull down the current image being used to build (the same way
Travis CI does it) - if it is out of date in any way it will build a
new one for you:
thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-bionic build/docker/refresh.sh
To run all unit tests (just like Travis CI does):
thrift$ dockerrun ubuntu-bionic
root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh
To run the cross tests (just like Travis CI does):
thrift$ dockerrun ubuntu-bionic
root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh
When you are done, you want to clean up occasionally so that docker isn't using lots of extra disk space:
thrift$ dockerclean
You need to run the docker commands from the root of the local clone of the
thrift git repository for them to work.
When you are done in the root docker shell you can `exit` to go back to
your user host shell. Once the unit tests and cross test passes locally,
submit the changes, and if desired squash the pull request to one commit
to make it easier to merge (the committers can squash at commit time now
that GitHub is the master repository). Now you are building like Travis CI does!
## Raw Commands for Building with Docker ##
If you do not want to use the same scripts Travis CI does, you can do it manually:
Build the image:
thrift$ docker build -t thrift build/docker/ubuntu-bionic
Open a command prompt in the image:
thrift$ docker run -v $(pwd):/thrift/src -it thrift /bin/bash
## Core Tool Versions per Dockerfile ##
Last updated: October 1, 2017
| Tool | ubuntu-xenial | ubuntu-bionic | Notes |
| :-------- | :------------ | :------------ | :---- |
| ant | 1.9.6 | 1.10.3 | |
| autoconf | 2.69 | 2.69 | |
| automake | 1.15 | 1.15.1 | |
| bison | 3.0.4 | 3.0.4 | |
| boost | 1.58.0 | 1.65.1 | |
| cmake | 3.5.1 | 3.10.2 | |
| cppcheck | 1.72 | 1.82 | |
| flex | 2.6.0 | 2.6.4 | |
| libc6 | 2.23 | 2.27 | glibc |
| libevent | 2.0.21 | 2.1.8 | |
| libstdc++ | 5.4.0 | 7.3.0 | |
| make | 4.1 | 4.1 | |
| openssl | 1.0.2g | 1.1.0g | |
| qt5 | 5.5.1 | 5.9.5 | |
## Compiler/Language Versions per Dockerfile ##
| Language | ubuntu-xenial | ubuntu-bionic | Notes |
| :-------- | :------------ | :------------ | :---- |
| as of | Mar 06, 2018 | Jul 6, 2018 | |
| as3 | | | Not in CI |
| C++ gcc | 5.4.0 | 7.3.0 | |
| C++ clang | 3.8 | 6.0 | |
| C# (mono) | 4.2.1.0 | 4.6.2.7 | |
| c_glib | 2.48.2 | 2.56.0 | |
| cl (sbcl) | | 1.4.9 | |
| cocoa | | | Not in CI |
| d | 2.075.1 | 2.081.0 | |
| dart | 1.22.1 | 1.24.3 | |
| delphi | | | Not in CI |
| dotnet | 2.1.4 | 2.1.301 | |
| erlang | 18.3 | 20.2.2 | |
| go | 1.7.6 | 1.10.3 | |
| haskell | 7.10.3 | 8.0.2 | |
| haxe | 3.2.1 | 3.4.4 | THRIFT-4352: avoid 3.4.2 |
| java | 1.8.0_151 | 1.8.0_171 | |
| js | | | Unsure how to look for version info? |
| lua | 5.2.4 | 5.2.4 | Lua 5.3: see THRIFT-4386 |
| nodejs | 6.13.0 | 8.11.3 | |
| ocaml | | 4.05.0 | THRIFT-4517: ocaml 4.02.3 on xenial appears broken |
| perl | 5.22.1 | 5.26.1 | |
| php | 7.0.22 | 7.2.5 | |
| python | 2.7.12 | 2.7.15rc1 | |
| python3 | 3.5.2 | 3.6.5 | |
| ruby | 2.3.1p112 | 2.5.1p57 | |
| rust | 1.17.0 | 1.24.1 | |
| smalltalk | | | Not in CI |
| swift | | | Not in CI |

View file

@ -1,59 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Base system bootstrap script
$bootstrap_script = <<__BOOTSTRAP__
echo "Provisioning defaults"
sudo apt-get update -y
sudo apt-get upgrade -y
# Install default packages
sudo apt-get install -y build-essential curl git
# Install latest Docker version
sudo curl -sSL https://get.docker.io/gpg | sudo apt-key add -
sudo echo "deb http://get.docker.io/ubuntu docker main" > /etc/apt/sources.list.d/docker.list
sudo apt-get update -y
sudo apt-get install -y linux-image-extra-`uname -r` aufs-tools
sudo apt-get install -y lxc-docker
echo "Finished provisioning defaults"
__BOOTSTRAP__
Vagrant.configure("2") do |config|
config.vm.box = "trusty64"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |vbox|
vbox.customize ["modifyvm", :id, "--memory", "1024"]
vbox.customize ["modifyvm", :id, "--cpus", "2"]
end
# Setup the default bootstrap script for our ubuntu base box image
config.vm.provision "shell", inline: $bootstrap_script
# Setup the custom docker image from our Ubuntu Dockerfile
config.vm.provision "docker" do |d|
d.build_image "/vagrant/ubuntu", args: "-t thrift"
end
# Setup the custom docker image from our Centos Dockerfile
#config.vm.provision "docker" do |d|
# d.build_image "/vagrant/centos", args: "-t thrift-centos"
#end
end

View file

@ -1,142 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Apache Thrift Docker build environment for Centos
#
# Known missing client libraries:
# - D
# - Haxe
# - Lua
#
FROM centos:7
MAINTAINER Apache Thrift <dev@thrift.apache.org>
RUN yum install -y epel-release
# General dependencies
RUN yum install -y \
tar \
m4 \
perl \
clang \
gcc \
gcc-c++ \
git \
libtool \
autoconf \
make \
bison \
bison-devel \
flex
# C++ dependencies
RUN yum install -y \
boost-devel-static \
zlib-devel \
openssl-devel \
libevent-devel
# Java Dependencies
RUN yum install -y \
ant \
junit \
ant-junit \
java-1.7.0-openjdk-devel
# Python Dependencies
RUN yum install -y \
python-devel \
python-pip \
python-setuptools \
python-six \
python-twisted-web && \
pip install -U backports.ssl_match_hostname ipaddress tornado
# Ruby Dependencies
RUN yum install -y \
ruby \
ruby-devel \
rubygems && \
gem install bundler rake
# Perl Dependencies
RUN yum install -y \
perl-Bit-Vector \
perl-Class-Accessor \
perl-ExtUtils-MakeMaker \
perl-Test-Simple \
perl-IO-Socket-SSL \
perl-Net-SSLeay \
perl-Crypt-SSLeay
# PHP Dependencies
RUN yum install -y \
php \
php-devel \
php-pear \
re2c \
php-phpunit-PHPUnit \
bzip2
# GLibC Dependencies
RUN yum install -y glib2-devel
# Erlang Dependencies
RUN curl -sSL http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.repo -o /etc/yum.repos.d/erlang_solutions.repo && \
yum install -y \
erlang-kernel \
erlang-erts \
erlang-stdlib \
erlang-eunit \
erlang-rebar \
erlang-tools
# Go Dependencies
RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
ENV PATH /usr/local/go/bin:$PATH
# Haskell Dependencies
RUN yum -y install haskell-platform
# Node.js Dependencies
RUN yum install -y \
nodejs \
nodejs-devel \
npm
# C# Dependencies
RUN yum install -y \
mono-core \
mono-devel \
mono-web-devel \
mono-extras \
# MinGW Dependencies
RUN yum install -y \
mingw32-binutils \
mingw32-crt \
mingw32-nsis
# CMake
RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.0.tar.gz | tar -xz && \
cd cmake-3.4.0 && ./bootstrap && make -j4 && make install && \
cd .. && rm -rf cmake-3.4.0
# Clean up
RUN rm -rf /tmp/* && \
yum clean all
ENV THRIFT_ROOT /thrift
RUN mkdir -p $THRIFT_ROOT/src
COPY Dockerfile $THRIFT_ROOT/
WORKDIR $THRIFT_ROOT/src

View file

@ -1,54 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Apache Thrift Docker build environment for Centos 6
#
# This file is intended for testing old packages that are not available for
# latest Ubuntu LTS/Debian/CentOS. Currently, it is only used for Python 2.6.
#
FROM centos:6
MAINTAINER Apache Thrift <dev@thrift.apache.org>
RUN yum install -y epel-release && \
yum install -y \
autoconf \
bison \
bison-devel \
clang \
flex \
gcc \
gcc-c++ \
git \
libtool \
m4 \
make \
perl \
tar \
python-devel \
python-setuptools \
python-twisted-web \
python-pip \
&& yum clean all
# optional dependencies
RUN pip install ipaddress backports.ssl_match_hostname tornado
# CMake
RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \
cd cmake-3.4.1 && ./bootstrap && make -j4 && make install && \
cd .. && rm -rf cmake-3.4.1
ENV THRIFT_ROOT /thrift
RUN mkdir -p $THRIFT_ROOT/src
COPY Dockerfile $THRIFT_ROOT/
WORKDIR $THRIFT_ROOT/src

View file

@ -1,192 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Apache Thrift Docker build environment for Centos
#
# Known missing client libraries:
# - None
FROM buildpack-deps:jessie-scm
MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
# Add apt sources
# Dart
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
sed -i /etc/apt/sources.list.d/dart_stable.list -e 's/https:/http:/g'
RUN apt-get update && apt-get install -y --no-install-recommends \
`# General dependencies` \
bison \
build-essential \
clang \
cmake \
debhelper \
flex \
pkg-config
RUN apt-get update && apt-get install -y --no-install-recommends \
`# C++ dependencies` \
libboost-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-test-dev \
libboost-thread-dev \
libevent-dev \
libssl-dev \
qt5-default \
qtbase5-dev \
qtbase5-dev-tools
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Java dependencies` \
ant \
ant-optional \
openjdk-7-jdk \
maven
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Python dependencies` \
python-all \
python-all-dbg \
python-all-dev \
python-pip \
python-setuptools \
python-twisted \
python-zope.interface \
python3-all \
python3-all-dbg \
python3-all-dev \
python3-setuptools \
python3-pip
RUN echo 'deb http://deb.debian.org/debian jessie-backports main' >> /etc/apt/sources.list \
&& apt-get update && apt-get install -y --no-install-recommends \
`# Ruby dependencies` \
ruby \
ruby-bundler \
ruby-dev \
`# Perl dependencies` \
libbit-vector-perl \
libclass-accessor-class-perl \
libcrypt-ssleay-perl \
libio-socket-ssl-perl \
libnet-ssleay-perl
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Php dependencies` \
php5 \
php5-dev \
php5-cli \
php-pear \
re2c \
phpunit \
`# GlibC dependencies` \
libglib2.0-dev
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Erlang dependencies` \
erlang-base \
erlang-eunit \
erlang-dev \
erlang-tools \
rebar
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Haskell dependencies` \
ghc \
cabal-install \
`# Haxe dependencies` \
neko \
neko-dev \
libneko0
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Node.js dependencies` \
nodejs \
nodejs-dev \
nodejs-legacy \
npm
RUN apt-get update && apt-get install -y --no-install-recommends \
`# CSharp dependencies` \
libmono-system-web2.0-cil \
mono-devel
RUN apt-get update && apt-get install -y --no-install-recommends \
`# D dependencies` \
xdg-utils \
`# Dart dependencies` \
dart \
`# Lua dependencies` \
lua5.2 \
lua5.2-dev \
`# MinGW dependencies` \
mingw32 \
mingw32-binutils \
`# mingw32-runtime` \
nsis \
`# Clean up` \
&& rm -rf /var/cache/apt/* && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /var/tmp/*
# Ruby
RUN gem install bundler --no-ri --no-rdoc
# Python optional dependencies
RUN pip2 install -U ipaddress backports.ssl_match_hostname tornado
RUN pip3 install -U backports.ssl_match_hostname tornado
# Go
RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
ENV PATH /usr/local/go/bin:$PATH
# Haxe
RUN mkdir -p /usr/lib/haxe && \
curl http://haxe.org/website-content/downloads/3.2.0/downloads/haxe-3.2.0-linux64.tar.gz | \
tar -C /usr/lib/haxe --strip-components=1 -xz && \
ln -s /usr/lib/haxe/haxe /usr/bin/haxe && \
ln -s /usr/lib/haxe/haxelib /usr/bin/haxelib && \
mkdir -p /usr/lib/haxe/lib && \
chmod -R 777 /usr/lib/haxe/lib && \
haxelib setup /usr/lib/haxe/lib && \
haxelib install hxcpp
# D
RUN curl -sSL http://downloads.dlang.org/releases/2.x/2.070.0/dmd_2.070.0-0_amd64.deb -o /tmp/dmd_2.070.0-0_amd64.deb && \
dpkg -i /tmp/dmd_2.070.0-0_amd64.deb && \
rm /tmp/dmd_2.070.0-0_amd64.deb && \
curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \
curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \
mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \
mv libevent-master/deimos/* openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \
mv libevent-master/C/* openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \
rm -rf libevent-master openssl-master && \
echo 'gcc -Wl,--no-as-needed $*' > /usr/local/bin/gcc-dmd && \
chmod 755 /usr/local/bin/gcc-dmd && \
echo 'CC=/usr/local/bin/gcc-dmd' >> /etc/dmd.conf
# Dart
ENV PATH /usr/lib/dart/bin:$PATH
# Force utf8 locale to successfully build Haskell tf-random
ENV LC_ALL C.UTF-8
ENV THRIFT_ROOT /thrift
RUN mkdir -p $THRIFT_ROOT/src
COPY Dockerfile $THRIFT_ROOT/
WORKDIR $THRIFT_ROOT/src

View file

@ -19,5 +19,5 @@ for LIB in $BUILD_LIBS; do
done
$MAKEPROG -j3
cpack
ctest -VV
# was: -E "(concurrency_test|processor_test)"
ctest -VV -E "(python_test)"
# disabled cmake python_test for now since it fails in travis under centos

View file

@ -1,209 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Apache Thrift Docker build environment for Centos
#
# Known missing client libraries:
# - None
FROM buildpack-deps:trusty-scm
MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
# Add apt sources
# Erlang
RUN echo 'deb http://packages.erlang-solutions.com/debian trusty contrib' > /etc/apt/sources.list.d/erlang_solutions.list && \
curl -sSL https://packages.erlang-solutions.com/debian/erlang_solutions.asc | apt-key add -
# Dart
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
sed -i /etc/apt/sources.list.d/dart_stable.list -e 's/https:/http:/g'
# Consider using mirror nearby when building locally
# TODO: Provide option via --build-arg=...
# RUN sed -i /etc/apt/sources.list -e 's!http://archive.ubuntu.com/ubuntu/!http://your/mirror/!g'
RUN apt-get update && apt-get install -y --no-install-recommends \
`# General dependencies` \
bison \
build-essential \
clang \
cmake \
debhelper \
flex \
ninja-build \
pkg-config \
`# Included in buildpack-deps` \
`# autoconf` \
`# automake` \
`# g++` \
`# git` \
`# libtool` \
`# make`
RUN apt-get update && apt-get install -y --no-install-recommends \
`# C++ dependencies` \
`# libevent and OpenSSL are needed by D too` \
libboost-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-test-dev \
libboost-thread-dev \
libevent-dev \
libssl-dev \
qt5-default \
qtbase5-dev \
qtbase5-dev-tools
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Java dependencies` \
ant \
ant-optional \
openjdk-7-jdk \
maven
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Python dependencies` \
`# TODO:` \
`# Install twisted and zope.interface via pip. we need twisted at ./configure time, otherwise` \
`# py.twisted tests are skipped.` \
python-all \
python-all-dbg \
python-all-dev \
python-pip \
python-setuptools \
python-twisted \
python-zope.interface \
python3-all \
python3-all-dbg \
python3-all-dev \
python3-setuptools \
python3-pip
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Ruby dependencies` \
ruby \
ruby-bundler \
ruby-dev \
`# Perl dependencies` \
libbit-vector-perl \
libclass-accessor-class-perl \
libcrypt-ssleay-perl \
libio-socket-ssl-perl \
libnet-ssleay-perl
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Php dependencies` \
php5 \
php5-dev \
php5-cli \
php-pear \
re2c \
phpunit \
`# GlibC dependencies` \
libglib2.0-dev
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Erlang dependencies` \
erlang-base \
erlang-eunit \
erlang-dev \
erlang-tools \
rebar
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Haskell dependencies` \
ghc \
cabal-install \
`# Haxe dependencies` \
neko \
neko-dev \
libneko0
RUN apt-get update && apt-get install -y --no-install-recommends \
`# Node.js dependencies` \
nodejs \
nodejs-dev \
nodejs-legacy
RUN apt-get update && apt-get install -y --no-install-recommends \
`# CSharp dependencies` \
libmono-system-web2.0-cil \
mono-devel
RUN apt-get update && apt-get install -y --no-install-recommends \
`# D dependencies` \
xdg-utils \
`# Dart dependencies` \
dart \
`# Lua dependencies` \
lua5.2 \
lua5.2-dev \
`# MinGW dependencies` \
mingw32 \
mingw32-binutils \
mingw32-runtime \
nsis \
`# Clean up` \
&& rm -rf /var/cache/apt/* && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && \
rm -rf /var/tmp/*
# Ruby
RUN gem install bundler --no-ri --no-rdoc
# Python optional dependencies
RUN pip2 install -U ipaddress backports.ssl_match_hostname tornado
RUN pip3 install -U backports.ssl_match_hostname tornado
# Go
RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
ENV PATH /usr/local/go/bin:$PATH
# Haxe
RUN mkdir -p /usr/lib/haxe && \
curl http://haxe.org/website-content/downloads/3.2.0/downloads/haxe-3.2.0-linux64.tar.gz | \
tar -C /usr/lib/haxe --strip-components=1 -xz && \
ln -s /usr/lib/haxe/haxe /usr/bin/haxe && \
ln -s /usr/lib/haxe/haxelib /usr/bin/haxelib && \
mkdir -p /usr/lib/haxe/lib && \
chmod -R 777 /usr/lib/haxe/lib && \
haxelib setup /usr/lib/haxe/lib && \
haxelib install hxcpp
# Node.js
RUN curl -sSL https://www.npmjs.com/install.sh | sh
# D
RUN curl -sSL http://downloads.dlang.org/releases/2.x/2.070.0/dmd_2.070.0-0_amd64.deb -o /tmp/dmd_2.070.0-0_amd64.deb && \
dpkg -i /tmp/dmd_2.070.0-0_amd64.deb && \
rm /tmp/dmd_2.070.0-0_amd64.deb && \
curl -sSL https://github.com/D-Programming-Deimos/openssl/archive/master.tar.gz| tar xz && \
curl -sSL https://github.com/D-Programming-Deimos/libevent/archive/master.tar.gz| tar xz && \
mkdir -p /usr/include/dmd/druntime/import/deimos /usr/include/dmd/druntime/import/C && \
mv libevent-master/deimos/* openssl-master/deimos/* /usr/include/dmd/druntime/import/deimos/ && \
mv libevent-master/C/* openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \
rm -rf libevent-master openssl-master && \
echo 'gcc -Wl,--no-as-needed $*' > /usr/local/bin/gcc-dmd && \
chmod 755 /usr/local/bin/gcc-dmd && \
echo 'CC=/usr/local/bin/gcc-dmd' >> /etc/dmd.conf
# Dart
ENV PATH /usr/lib/dart/bin:$PATH
ENV THRIFT_ROOT /thrift
RUN mkdir -p $THRIFT_ROOT/src
COPY Dockerfile $THRIFT_ROOT/
WORKDIR $THRIFT_ROOT/src

View file

@ -16,30 +16,37 @@
# specific language governing permissions and limitations
# under the License.
#
cmake_minimum_required(VERSION 2.8.12)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/thrift/version.h)
if(MSVC)
# The winflexbison generator outputs some macros that conflict with the Visual Studio 2010 copy of stdint.h
# This might be fixed in later versions of Visual Studio, but an easy solution is to include stdint.h first
if(HAVE_STDINT_H)
add_definitions(-D__STDC_FORMAT_MACROS)
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(/FI"stdint.h")
endif(HAVE_STDINT_H)
endif()
find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)
# create directory for thrifty and thriftl
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thrift/)
# Create flex and bison files and build the lib parse static library
BISON_TARGET(thrifty ${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/thrifty.yy ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc)
FLEX_TARGET(thriftl ${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/thriftl.ll ${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc)
ADD_FLEX_BISON_DEPENDENCY(thriftl thrifty)
# HACK: Work around the fact that bison crates a .hh file but we need a .h file
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.h
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh
)
set(libparse_SOURCES
set(parse_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc
${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc
${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.h
${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh
)
add_library(libparse STATIC ${libparse_SOURCES})
add_library(parse STATIC ${parse_SOURCES})
# Create the thrift compiler
set(compiler_core
@ -55,6 +62,9 @@ set(thrift-compiler_SOURCES
src/thrift/audit/t_audit.cpp
)
set(thrift_compiler_LANGS
)
# This macro adds an option THRIFT_COMPILER_${NAME}
# that allows enabling or disabling certain languages
macro(THRIFT_ADD_COMPILER name description initial)
@ -63,6 +73,7 @@ macro(THRIFT_ADD_COMPILER name description initial)
option(${enabler} ${description} ${initial})
if(${enabler})
list(APPEND thrift-compiler_SOURCES ${src})
list(APPEND thrift_compiler_LANGS ${name})
endif()
endmacro()
@ -74,6 +85,7 @@ THRIFT_ADD_COMPILER(as3 "Enable compiler for ActionScript 3" ON)
THRIFT_ADD_COMPILER(dart "Enable compiler for Dart" ON)
THRIFT_ADD_COMPILER(haxe "Enable compiler for Haxe" ON)
THRIFT_ADD_COMPILER(csharp "Enable compiler for C#" ON)
THRIFT_ADD_COMPILER(netcore "Enable compiler for .NET Core" ON)
THRIFT_ADD_COMPILER(py "Enable compiler for Python 2.0" ON)
THRIFT_ADD_COMPILER(rb "Enable compiler for Ruby" ON)
THRIFT_ADD_COMPILER(perl "Enable compiler for Perl" ON)
@ -94,15 +106,17 @@ THRIFT_ADD_COMPILER(go "Enable compiler for Go" ON)
THRIFT_ADD_COMPILER(d "Enable compiler for D" ON)
THRIFT_ADD_COMPILER(lua "Enable compiler for Lua" ON)
THRIFT_ADD_COMPILER(gv "Enable compiler for GraphViz" ON)
THRIFT_ADD_COMPILER(rs "Enable compiler for Rust" ON)
THRIFT_ADD_COMPILER(xml "Enable compiler for XML" ON)
# Thrift is looking for include files in the src directory
# we also add the current binary directory for generated files
include_directories(${CMAKE_CURRENT_BINARY_DIR} src)
if(NOT ${WITH_PLUGIN})
if(NOT DEFINED WITH_PLUGIN OR NOT ${WITH_PLUGIN})
list(APPEND thrift-compiler_SOURCES ${compiler_core})
endif()
add_executable(thrift-compiler ${thrift-compiler_SOURCES})
if(${WITH_PLUGIN})
@ -111,7 +125,7 @@ if(${WITH_PLUGIN})
src/thrift/audit/t_audit.cpp
src/thrift/generate/t_cpp_generator.cc
)
target_link_libraries(thrift-bootstrap libparse)
target_link_libraries(thrift-bootstrap parse)
set(PLUGIN_GEN_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin/plugin_types.h
@ -144,11 +158,12 @@ if(${WITH_PLUGIN})
LINK_AGAINST_THRIFT_LIBRARY(thrift-compiler thriftc)
endif()
set_target_properties(thrift-compiler PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin/)
set_target_properties(thrift-compiler PROPERTIES OUTPUT_NAME thrift)
target_link_libraries(thrift-compiler libparse)
target_link_libraries(thrift-compiler parse)
install(TARGETS thrift-compiler DESTINATION "${BIN_INSTALL_DIR}")
install(TARGETS thrift-compiler DESTINATION bin)
if(${WITH_PLUGIN})
# Install the headers

View file

@ -71,7 +71,7 @@ compiler_core = src/thrift/common.h \
src/thrift/parse/parse.cc \
src/thrift/generate/t_generator.h \
src/thrift/generate/t_oop_generator.h \
src/thrift/generate/t_html_generator.h
src/thrift/generate/t_html_generator.h
thrift_SOURCES = src/thrift/main.h \
src/thrift/main.cc \
@ -87,6 +87,8 @@ thrift_SOURCES += src/thrift/generate/t_c_glib_generator.cc \
src/thrift/generate/t_dart_generator.cc \
src/thrift/generate/t_haxe_generator.cc \
src/thrift/generate/t_csharp_generator.cc \
src/thrift/generate/t_netcore_generator.cc \
src/thrift/generate/t_netcore_generator.h \
src/thrift/generate/t_py_generator.cc \
src/thrift/generate/t_rb_generator.cc \
src/thrift/generate/t_perl_generator.cc \
@ -106,10 +108,12 @@ thrift_SOURCES += src/thrift/generate/t_c_glib_generator.cc \
src/thrift/generate/t_go_generator.cc \
src/thrift/generate/t_gv_generator.cc \
src/thrift/generate/t_d_generator.cc \
src/thrift/generate/t_lua_generator.cc
src/thrift/generate/t_lua_generator.cc \
src/thrift/generate/t_rs_generator.cc \
src/thrift/generate/t_cl_generator.cc
thrift_CPPFLAGS = -I$(srcdir)/src
thrift_CXXFLAGS = -Wall -Wextra -pedantic
thrift_CXXFLAGS = -Wall -Wextra -pedantic -Werror
thrift_LDADD = @LEXLIB@ src/thrift/libparse.a
if !WITH_PLUGIN
@ -151,7 +155,7 @@ include_generatedir = $(include_thriftdir)/generate
include_generate_HEADERS = src/thrift/generate/t_generator.h \
src/thrift/generate/t_generator_registry.h \
src/thrift/generate/t_oop_generator.h \
src/thrift/generate/t_html_generator.h
src/thrift/generate/t_html_generator.h
include_parsedir = $(include_thriftdir)/parse
include_parse_HEADERS = src/thrift/parse/t_service.h \

View file

@ -1,83 +1,175 @@
# Build compiler using CMake
# Build Thrift IDL compiler using CMake
Use the following steps to build using cmake:
<!-- TOC -->
mkdir cmake-build
cd cmake-build
cmake ..
make
- [Build Thrift IDL compiler using CMake](#build-thrift-idl-compiler-using-cmake)
- [Build on Unix-like System](#build-on-unix-like-system)
- [Prerequisites](#prerequisites)
- [Build using CMake](#build-using-cmake)
- [Build with Eclipse IDE](#build-with-eclipse-ide)
- [Build with XCode IDE in MacOS](#build-with-xcode-ide-in-macos)
- [Usage of other IDEs](#usage-of-other-ides)
- [Build on Windows](#build-on-windows)
- [Prerequisites](#prerequisites-1)
- [Build using Git Bash](#build-using-git-bash)
- [Using Visual Studio and Win flex-bison](#using-visual-studio-and-win-flex-bison)
- [Cross compile using mingw32 and generate a Windows Installer with CPack](#cross-compile-using-mingw32-and-generate-a-windows-installer-with-cpack)
- [Other cases](#other-cases)
- [Building the Thrift IDL compiler in Windows without CMake](#building-the-thrift-idl-compiler-in-windows-without-cmake)
- [Unit tests for compiler](#unit-tests-for-compiler)
- [Using boost test](#using-boost-test)
- [Using Catch C++ test library](#using-catch-c-test-library)
- [Have a Happy free time and holidays](#have-a-happy-free-time-and-holidays)
<!-- /TOC -->
### Create an eclipse project
## Build on Unix-like System
mkdir cmake-ec && cd cmake-ec
cmake -G "Eclipse CDT4 - Unix Makefiles" ..
make
### Prerequisites
- Install CMake
- Install flex and bison
### Build using CMake
- Go to **thrift\compiler\cpp**
- Use the following steps to build using cmake:
```
mkdir cmake-build && cd cmake-build
cmake ..
make
```
#### Build with Eclipse IDE
- Go to **thrift\compiler\cpp**
- Use the following steps to build using cmake:
```
mkdir cmake-ec && cd cmake-ec
cmake -G "Eclipse CDT4 - Unix Makefiles" ..
make
```
Now open the folder cmake-ec using eclipse.
#### Build with XCode IDE in MacOS
- Install/update flex, bison and cmake with brew
```
brew install cmake
brew install bison
```
- Go to **thrift\compiler\cpp**
- Run commands in command line:
```
mkdir cmake-build && cd cmake-build
cmake -G "Xcode" -DWITH_PLUGIN=OFF ..
cmake --build .
```
#### Usage of other IDEs
Please check list of supported IDE
```
cmake --help
```
## Build on Windows
### Prerequisites
- Install CMake - https://cmake.org/download/
- In case if you want to build without Git Bash - install winflexbison - https://sourceforge.net/projects/winflexbison/
- In case if you want to build with Visual Studio - install Visual Studio
- Better to use the latest stable Visual Studio Community Edition - https://www.visualstudio.com/vs/whatsnew/ (ensure that you installed workload "Desktop Development with C++" for VS2017) - Microsoft added some support for CMake and improving it in Visual Studio
### Build using Git Bash
Git Bash provides flex and bison
- Go to **thrift\compiler\cpp**
- Use the following steps to build using cmake:
```
mkdir cmake-vs && cd cmake-vs
cmake -DWITH_SHARED_LIB=off ..
cmake --build .
```
### Using Visual Studio and Win flex-bison
- Generate a Visual Studio project for version of Visual Studio which you have (**cmake --help** can show list of supportable VS versions):
- Run commands in command line:
```
mkdir cmake-vs
cd cmake-vs
cmake -G "Visual Studio 15 2017" -DWITH_PLUGIN=OFF ..
```
- Now open the folder cmake-vs using Visual Studio.
### Cross compile using mingw32 and generate a Windows Installer with CPack
mkdir cmake-mingw32 && cd cmake-mingw32
cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
cpack
## Build on windows
### using Git Bash
Git Bash provides flex and bison, so you just need to do this:
mkdir cmake-vs && cd cmake-vs
cmake -DWITH_SHARED_LIB=off ..
### using Win flex-bison
In order to build on windows with winflexbison a few additional steps are necessary:
1. Download winflexbison from http://sourceforge.net/projects/winflexbison/
2. Extract the winflex bison files to for e.g. C:\winflexbison
3. Make the CMake variables point to the correct binaries.
* FLEX_EXECUTABLE = C:/winbuild/win_flex.exe
* BISON_EXECUTABLE = C:/winbuild/win_bison.exe
4. Generate a Visual Studio project:
```
mkdir cmake-vs && cd cmake-vs
cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off ..
mkdir cmake-mingw32 && cd cmake-mingw32
cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
cpack
```
5. Now open the folder build_vs using Visual Studio 2013.
# Building the Thrift IDL compiler in Windows
# Other cases
If you don't want to use CMake you can use the already available Visual Studio
2010 solution.
The Visual Studio project contains pre-build commands to generate the
thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build
the compiler. These depend on bison, flex and their dependencies to
work properly.
Download flex & bison as described above.
Place these binaries somewhere in the path and
rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
## Building the Thrift IDL compiler in Windows without CMake
If you don't want to use CMake you can use the already available Visual Studio 2010 solution.
The Visual Studio project contains pre-build commands to generate the thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build the compiler.
These depend on bison, flex and their dependencies to work properly.
Download flex & bison as described above.
Place these binaries somewhere in the path and rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
If this doesn't work on a system, try these manual pre-build steps.
Open compiler.sln and remove the Pre-build commands under the project's
Properties -> Build Events -> Pre-Build Events.
Open compiler.sln and remove the Pre-build commands under the project's: Properties -> Build Events -> Pre-Build Events.
From a command prompt:
> cd thrift/compiler/cpp
> flex -osrc\thrift\thriftl.cc src\thrift\thriftl.ll
```
cd thrift/compiler/cpp
flex -o src\thrift\thriftl.cc src\thrift\thriftl.ll
```
In the generated thriftl.cc, comment out #include <unistd.h>
Place a copy of bison.simple in thrift/compiler/cpp
> bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
> move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
```
bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
```
Bison might generate the yacc header file "thrifty.cc.h" with just one h ".h" extension; in this case you'll have to rename to "thrifty.h".
> move src\thrift\version.h.in src\thrift\version.h
```
move src\thrift\version.h.in src\thrift\version.h
```
Download inttypes.h from the interwebs and place it in an include path
location (e.g. thrift/compiler/cpp/src).
Build the compiler in Visual Studio.
# Unit tests for compiler
## Using boost test
- pls check **test** folder
## Using Catch C++ test library
Added generic way to cover code by tests for many languages (you just need to make a correct header file for generator for your language - example in **netcore** implementation)
- pls check **tests** folder
# Have a Happy free time and holidays

View file

@ -51,12 +51,13 @@
<ClInclude Include="src\thrift\version.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\thrift\audit\t_audit.cpp"/>
<ClCompile Include="src\thrift\audit\t_audit.cpp" />
<ClCompile Include="src\thrift\common.cc" />
<ClCompile Include="src\thrift\generate\t_as3_generator.cc" />
<ClCompile Include="src\thrift\generate\t_cocoa_generator.cc" />
<ClCompile Include="src\thrift\generate\t_cpp_generator.cc" />
<ClCompile Include="src\thrift\generate\t_csharp_generator.cc" />
<ClCompile Include="src\thrift\generate\t_netcore_generator.cc" />
<ClCompile Include="src\thrift\generate\t_c_glib_generator.cc" />
<ClCompile Include="src\thrift\generate\t_d_generator.cc" />
<ClCompile Include="src\thrift\generate\t_dart_generator.cc" />
@ -78,6 +79,7 @@
<ClCompile Include="src\thrift\generate\t_php_generator.cc" />
<ClCompile Include="src\thrift\generate\t_py_generator.cc" />
<ClCompile Include="src\thrift\generate\t_rb_generator.cc" />
<ClCompile Include="src\thrift\generate\t_rs_generator.cc" />
<ClCompile Include="src\thrift\generate\t_st_generator.cc" />
<ClCompile Include="src\thrift\generate\t_swift_generator.cc" />
<ClCompile Include="src\thrift\generate\t_xml_generator.cc" />
@ -194,7 +196,6 @@
</Link>
<PreBuildEvent>
<Command>flex -o "src\\thrift\\thriftl.cc" src/thrift/thriftl.ll &amp;&amp; bison -y -o "src\\thrift\\thrifty.cc" --defines="src\\thrift\\thrifty.hh" src/thrift/thrifty.yy</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -208,6 +209,7 @@
<PreprocessorDefinitions>WIN32;MINGW;YY_NO_UNISTD_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>thrift\windows\config.h</ForcedIncludeFiles>
<CompileAs>CompileAsCpp</CompileAs>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -217,7 +219,6 @@
</Link>
<PreBuildEvent>
<Command>flex -o "src\\thrift\\thriftl.cc" src/thrift/thriftl.ll &amp;&amp; bison -y -o "src\\thrift\\thrifty.cc" --defines="src\\thrift\\thrifty.hh" src/thrift/thrifty.yy</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -231,6 +232,7 @@
<PreprocessorDefinitions>WIN32;MINGW;YY_NO_UNISTD_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>thrift\windows\config.h</ForcedIncludeFiles>
<CompileAs>CompileAsCpp</CompileAs>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -240,10 +242,9 @@
</Link>
<PreBuildEvent>
<Command>flex -o "src\\thrift\\thriftl.cc" src/thrift/thriftl.ll &amp;&amp; bison -y -o "src\\thrift\\thrifty.cc" --defines="src\\thrift\\thrifty.hh" src/thrift/thrifty.yy</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View file

@ -161,6 +161,9 @@
<ClCompile Include="src\generate\t_rb_generator.cc">
<Filter>generate</Filter>
</ClCompile>
<ClCompile Include="src\generate\t_rs_generator.cc">
<Filter>generate</Filter>
</ClCompile>
<ClCompile Include="src\generate\t_st_generator.cc">
<Filter>generate</Filter>
</ClCompile>
@ -193,4 +196,4 @@
<None Include="src\thriftl.ll" />
<None Include="src\thrifty.yy" />
</ItemGroup>
</Project>
</Project>

View file

@ -202,8 +202,8 @@ bool compare_defaults(t_const_value* newStructDefault, t_const_value* oldStructD
}
case t_const_value::CV_MAP:
{
const std::map<t_const_value*, t_const_value*> newMap = newStructDefault->get_map();
const std::map<t_const_value*, t_const_value*> oldMap = oldStructDefault->get_map();
const std::map<t_const_value*, t_const_value*, t_const_value::value_compare> newMap = newStructDefault->get_map();
const std::map<t_const_value*, t_const_value*, t_const_value::value_compare> oldMap = oldStructDefault->get_map();
bool defaultValuesCompare = (oldMap.size() == newMap.size());

View file

@ -31,7 +31,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -83,13 +83,13 @@ public:
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
void print_const_value(std::ofstream& out,
void print_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value,
bool in_static,
bool defval = false);
std::string render_const_value(ofstream& out,
std::string render_const_value(ostream& out,
std::string name,
t_type* type,
t_const_value* value);
@ -100,19 +100,19 @@ public:
void generate_as3_struct(t_struct* tstruct, bool is_exception);
void generate_as3_struct_definition(std::ofstream& out,
void generate_as3_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool in_class = false,
bool is_result = false);
// removed -- equality,compare_to
void generate_as3_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_as3_validator(std::ofstream& out, t_struct* tstruct);
void generate_as3_struct_result_writer(std::ofstream& out, t_struct* tstruct);
void generate_as3_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_as3_struct_tostring(std::ofstream& out, t_struct* tstruct, bool bindable);
void generate_as3_meta_data_map(std::ofstream& out, t_struct* tstruct);
void generate_field_value_meta_data(std::ofstream& out, t_type* type);
void generate_as3_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_as3_validator(std::ostream& out, t_struct* tstruct);
void generate_as3_struct_result_writer(std::ostream& out, t_struct* tstruct);
void generate_as3_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_as3_struct_tostring(std::ostream& out, t_struct* tstruct, bool bindable);
void generate_as3_meta_data_map(std::ostream& out, t_struct* tstruct);
void generate_field_value_meta_data(std::ostream& out, t_type* type);
std::string get_as3_type_string(t_type* type);
void generate_reflection_setters(std::ostringstream& out,
t_type* type,
@ -122,15 +122,15 @@ public:
t_type* type,
std::string field_name,
std::string cap_name);
void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
void generate_as3_bean_boilerplate(std::ofstream& out, t_struct* tstruct, bool bindable);
void generate_generic_field_getters_setters(std::ostream& out, t_struct* tstruct);
void generate_generic_isset_method(std::ostream& out, t_struct* tstruct);
void generate_as3_bean_boilerplate(std::ostream& out, t_struct* tstruct, bool bindable);
void generate_function_helpers(t_function* tfunction);
std::string get_cap_name(std::string name);
std::string generate_isset_check(t_field* field);
std::string generate_isset_check(std::string field);
void generate_isset_set(ofstream& out, t_field* field);
void generate_isset_set(ostream& out, t_field* field);
// removed std::string isset_field_id(t_field* field);
void generate_service_interface(t_service* tservice);
@ -143,38 +143,38 @@ public:
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string iter,
std::string map);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
void generate_as3_doc(std::ofstream& out, t_doc* tdoc);
void generate_as3_doc(std::ostream& out, t_doc* tdoc);
void generate_as3_doc(std::ofstream& out, t_function* tdoc);
void generate_as3_doc(std::ostream& out, t_function* tdoc);
/**
* Helper rendering functions
@ -208,7 +208,7 @@ private:
*/
std::string package_name_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_service_;
std::string package_dir_;
bool bindable_;
@ -353,8 +353,8 @@ void t_as3_generator::generate_typedef(t_typedef* ttypedef) {
void t_as3_generator::generate_enum(t_enum* tenum) {
// Make output file
string f_enum_name = package_dir_ + "/" + (tenum->get_name()) + ".as";
ofstream f_enum;
f_enum.open(f_enum_name.c_str());
ofstream_with_content_based_conditional_update f_enum;
f_enum.open(f_enum_name);
// Comment and package it
f_enum << autogen_comment() << as3_package() << endl;
@ -416,8 +416,8 @@ void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
}
string f_consts_name = package_dir_ + "/" + program_name_ + "Constants.as";
ofstream f_consts;
f_consts.open(f_consts_name.c_str());
ofstream_with_content_based_conditional_update f_consts;
f_consts.open(f_consts_name);
// Print header
f_consts << autogen_comment() << as3_package();
@ -443,7 +443,7 @@ void t_as3_generator::generate_consts(std::vector<t_const*> consts) {
f_consts.close();
}
void t_as3_generator::print_const_value(std::ofstream& out,
void t_as3_generator::print_const_value(std::ostream& out,
string name,
t_type* type,
t_const_value* value,
@ -471,8 +471,8 @@ void t_as3_generator::print_const_value(std::ofstream& out,
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();"
<< endl;
if (!in_static) {
@ -516,8 +516,8 @@ void t_as3_generator::print_const_value(std::ofstream& out,
}
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
@ -567,7 +567,7 @@ void t_as3_generator::print_const_value(std::ofstream& out,
}
}
string t_as3_generator::render_const_value(ofstream& out,
string t_as3_generator::render_const_value(ostream& out,
string name,
t_type* type,
t_const_value* value) {
@ -644,7 +644,7 @@ void t_as3_generator::generate_xception(t_struct* txception) {
void t_as3_generator::generate_as3_struct(t_struct* tstruct, bool is_exception) {
// Make output file
string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".as";
ofstream f_struct;
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
f_struct << autogen_comment() << as3_package();
@ -678,7 +678,7 @@ void t_as3_generator::generate_as3_struct(t_struct* tstruct, bool is_exception)
* @param in_class If inside a class, needs to be static class
* @param is_result If this is a result it needs a different writer
*/
void t_as3_generator::generate_as3_struct_definition(ofstream& out,
void t_as3_generator::generate_as3_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception,
bool in_class,
@ -782,7 +782,7 @@ void t_as3_generator::generate_as3_struct_definition(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_as3_generator::generate_as3_struct_reader(ofstream& out, t_struct* tstruct) {
void t_as3_generator::generate_as3_struct_reader(ostream& out, t_struct* tstruct) {
out << indent() << "public function read(iprot:TProtocol):void {" << endl;
indent_up();
@ -862,7 +862,7 @@ void t_as3_generator::generate_as3_struct_reader(ofstream& out, t_struct* tstruc
// generates as3 method to perform various checks
// (e.g. check that all required fields are set)
void t_as3_generator::generate_as3_validator(ofstream& out, t_struct* tstruct) {
void t_as3_generator::generate_as3_validator(ostream& out, t_struct* tstruct) {
indent(out) << "public function validate():void {" << endl;
indent_up();
@ -912,7 +912,7 @@ void t_as3_generator::generate_as3_validator(ofstream& out, t_struct* tstruct) {
*
* @param tstruct The struct definition
*/
void t_as3_generator::generate_as3_struct_writer(ofstream& out, t_struct* tstruct) {
void t_as3_generator::generate_as3_struct_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public function write(oprot:TProtocol):void {" << endl;
indent_up();
@ -971,7 +971,7 @@ void t_as3_generator::generate_as3_struct_writer(ofstream& out, t_struct* tstruc
*
* @param tstruct The struct definition
*/
void t_as3_generator::generate_as3_struct_result_writer(ofstream& out, t_struct* tstruct) {
void t_as3_generator::generate_as3_struct_result_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public function write(oprot:TProtocol):void {" << endl;
indent_up();
@ -1044,7 +1044,7 @@ void t_as3_generator::generate_reflection_setters(ostringstream& out,
indent_down();
}
void t_as3_generator::generate_generic_field_getters_setters(std::ofstream& out,
void t_as3_generator::generate_generic_field_getters_setters(std::ostream& out,
t_struct* tstruct) {
std::ostringstream getter_stream;
@ -1100,7 +1100,7 @@ void t_as3_generator::generate_generic_field_getters_setters(std::ofstream& out,
}
// Creates a generic isSet method that takes the field number as argument
void t_as3_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct) {
void t_as3_generator::generate_generic_isset_method(std::ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -1134,7 +1134,7 @@ void t_as3_generator::generate_generic_isset_method(std::ofstream& out, t_struct
*
* @param tstruct The struct definition
*/
void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
void t_as3_generator::generate_as3_bean_boilerplate(ostream& out,
t_struct* tstruct,
bool bindable) {
const vector<t_field*>& fields = tstruct->get_members();
@ -1216,7 +1216,7 @@ void t_as3_generator::generate_as3_bean_boilerplate(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
void t_as3_generator::generate_as3_struct_tostring(ostream& out,
t_struct* tstruct,
bool bindable) {
// If it's bindable, it extends EventDispatcher so toString is an override.
@ -1251,7 +1251,7 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
indent_up();
}
if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
if (field->get_type()->is_binary()) {
indent(out) << " ret += \"BINARY\";" << endl;
} else if (field->get_type()->is_enum()) {
indent(out) << "var " << field->get_name()
@ -1293,7 +1293,7 @@ void t_as3_generator::generate_as3_struct_tostring(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_as3_generator::generate_as3_meta_data_map(ofstream& out, t_struct* tstruct) {
void t_as3_generator::generate_as3_meta_data_map(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -1381,7 +1381,7 @@ std::string t_as3_generator::get_as3_type_string(t_type* type) {
}
}
void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
void t_as3_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
out << endl;
indent_up();
indent_up();
@ -1960,7 +1960,7 @@ void t_as3_generator::generate_process_function(t_service* tservice, t_function*
* @param tfield The field
* @param prefix The variable name or container for this field
*/
void t_as3_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_as3_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
if (type->is_void()) {
@ -1984,7 +1984,7 @@ void t_as3_generator::generate_deserialize_field(ofstream& out, t_field* tfield,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "readBinary();";
} else {
out << "readString();";
@ -2025,7 +2025,7 @@ void t_as3_generator::generate_deserialize_field(ofstream& out, t_field* tfield,
/**
* Generates an unserializer for a struct, invokes read()
*/
void t_as3_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_as3_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl << indent()
<< prefix << ".read(iprot);" << endl;
}
@ -2033,7 +2033,7 @@ void t_as3_generator::generate_deserialize_struct(ofstream& out, t_struct* tstru
/**
* Deserializes a container by reading its size and then iterating
*/
void t_as3_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_as3_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
string obj;
@ -2093,7 +2093,7 @@ void t_as3_generator::generate_deserialize_container(ofstream& out, t_type* ttyp
/**
* Generates code to deserialize a map
*/
void t_as3_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
void t_as3_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) {
string key = tmp("_key");
string val = tmp("_val");
t_field fkey(tmap->get_key_type(), key);
@ -2111,7 +2111,7 @@ void t_as3_generator::generate_deserialize_map_element(ofstream& out, t_map* tma
/**
* Deserializes a set element
*/
void t_as3_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
void t_as3_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
@ -2125,7 +2125,7 @@ void t_as3_generator::generate_deserialize_set_element(ofstream& out, t_set* tse
/**
* Deserializes a list element
*/
void t_as3_generator::generate_deserialize_list_element(ofstream& out,
void t_as3_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
string elem = tmp("_elem");
@ -2144,7 +2144,7 @@ void t_as3_generator::generate_deserialize_list_element(ofstream& out,
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_as3_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_as3_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
// Do nothing for void types
@ -2168,7 +2168,7 @@ void t_as3_generator::generate_serialize_field(ofstream& out, t_field* tfield, s
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "writeBinary(" << name << ");";
} else {
out << "writeString(" << name << ");";
@ -2213,7 +2213,7 @@ void t_as3_generator::generate_serialize_field(ofstream& out, t_field* tfield, s
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_as3_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_as3_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
out << indent() << prefix << ".write(oprot);" << endl;
}
@ -2224,7 +2224,7 @@ void t_as3_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct
* @param ttype The type of container
* @param prefix String prefix for fields
*/
void t_as3_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_as3_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
if (ttype->is_map()) {
@ -2282,7 +2282,7 @@ void t_as3_generator::generate_serialize_container(ofstream& out, t_type* ttype,
/**
* Serializes the members of a map.
*/
void t_as3_generator::generate_serialize_map_element(ofstream& out,
void t_as3_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string iter,
string map) {
@ -2295,7 +2295,7 @@ void t_as3_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_as3_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_as3_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2303,7 +2303,7 @@ void t_as3_generator::generate_serialize_set_element(ofstream& out, t_set* tset,
/**
* Serializes the members of a list.
*/
void t_as3_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
void t_as3_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2390,7 +2390,7 @@ string t_as3_generator::declare_field(t_field* tfield, bool init) {
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
if (ttype->is_base_type() && tfield->get_value() != NULL) {
ofstream dummy;
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
@ -2539,7 +2539,7 @@ string t_as3_generator::constant_name(string name) {
/**
* Emits a As3Doc comment if the provided object has a doc in Thrift
*/
void t_as3_generator::generate_as3_doc(ofstream& out, t_doc* tdoc) {
void t_as3_generator::generate_as3_doc(ostream& out, t_doc* tdoc) {
if (tdoc->has_doc()) {
generate_docstring_comment(out, "/**\n", " * ", tdoc->get_doc(), " */\n");
}
@ -2548,7 +2548,7 @@ void t_as3_generator::generate_as3_doc(ofstream& out, t_doc* tdoc) {
/**
* Emits a As3Doc comment if the provided function object has a doc in Thrift
*/
void t_as3_generator::generate_as3_doc(ofstream& out, t_function* tfunction) {
void t_as3_generator::generate_as3_doc(ostream& out, t_function* tfunction) {
if (tfunction->has_doc()) {
stringstream ss;
ss << tfunction->get_doc();
@ -2573,7 +2573,7 @@ std::string t_as3_generator::generate_isset_check(std::string field_name) {
return "is" + get_cap_name("set") + get_cap_name(field_name) + "()";
}
void t_as3_generator::generate_isset_set(ofstream& out, t_field* field) {
void t_as3_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
indent(out) << "this.__isset_" << field->get_name() << " = true;" << endl;
}

View file

@ -33,7 +33,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -116,10 +116,10 @@ public:
private:
/* file streams */
ofstream f_types_;
ofstream f_types_impl_;
ofstream f_header_;
ofstream f_service_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_types_impl_;
ofstream_with_content_based_conditional_update f_header_;
ofstream_with_content_based_conditional_update f_service_;
/* namespace variables */
string nspace;
@ -145,8 +145,8 @@ private:
bool pointer = false,
bool constant = false,
bool reference = false);
void declare_local_variable(ofstream& out, t_type* ttype, string& base_name, bool for_hash_table);
void declore_local_variable_for_write(ofstream& out, t_type* ttype, string& base_name);
void declare_local_variable(ostream& out, t_type* ttype, string& base_name, bool for_hash_table);
void declore_local_variable_for_write(ostream& out, t_type* ttype, string& base_name);
/* generation functions */
void generate_const_initializer(string name,
@ -159,51 +159,51 @@ private:
void generate_service_processor(t_service* tservice);
void generate_service_server(t_service* tservice);
void generate_object(t_struct* tstruct);
void generate_struct_writer(ofstream& out,
void generate_struct_writer(ostream& out,
t_struct* tstruct,
string this_name,
string this_get = "",
bool is_function = true);
void generate_struct_reader(ofstream& out,
void generate_struct_reader(ostream& out,
t_struct* tstruct,
string this_name,
string this_get = "",
bool is_function = true);
void generate_serialize_field(ofstream& out,
void generate_serialize_field(ostream& out,
t_field* tfield,
string prefix,
string suffix,
int error_ret);
void generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix, int error_ret);
void generate_serialize_container(ofstream& out, t_type* ttype, string prefix, int error_ret);
void generate_serialize_map_element(ofstream& out,
void generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix, int error_ret);
void generate_serialize_container(ostream& out, t_type* ttype, string prefix, int error_ret);
void generate_serialize_map_element(ostream& out,
t_map* tmap,
string key,
string value,
int error_ret);
void generate_serialize_set_element(ofstream& out, t_set* tset, string element, int error_ret);
void generate_serialize_list_element(ofstream& out,
void generate_serialize_set_element(ostream& out, t_set* tset, string element, int error_ret);
void generate_serialize_list_element(ostream& out,
t_list* tlist,
string list,
string index,
int error_ret);
void generate_deserialize_field(ofstream& out,
void generate_deserialize_field(ostream& out,
t_field* tfield,
string prefix,
string suffix,
int error_ret,
bool allocate = true);
void generate_deserialize_struct(ofstream& out,
void generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix,
int error_ret,
bool allocate = true);
void generate_deserialize_container(ofstream& out, t_type* ttype, string prefix, int error_ret);
void generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix, int error_ret);
void generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix, int error_ret);
void generate_deserialize_list_element(ofstream& out,
void generate_deserialize_container(ostream& out, t_type* ttype, string prefix, int error_ret);
void generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix, int error_ret);
void generate_deserialize_set_element(ostream& out, t_set* tset, string prefix, int error_ret);
void generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix,
string index,
@ -250,11 +250,21 @@ void t_c_glib_generator::init_generator() {
/* include other thrift includes */
const vector<t_program*>& includes = program_->get_includes();
for (size_t i = 0; i < includes.size(); ++i) {
f_types_ << "/* other thrift includes */" << endl << "#include \"" << this->nspace_lc
<< initial_caps_to_underscores(includes[i]->get_name()) << "_types.h\"" << endl;
if (!includes.empty()) {
f_types_ << "/* other thrift includes */" << endl;
for (vector<t_program*>::const_iterator iter = includes.begin();
iter != includes.end();
++iter) {
const std::string& include_nspace = (*iter)->get_namespace("c_glib");
std::string include_nspace_prefix =
include_nspace.empty() ? "" : initial_caps_to_underscores(include_nspace) + "_";
f_types_ << "#include \"" << include_nspace_prefix
<< initial_caps_to_underscores((*iter)->get_name()) << "_types.h\"" << endl;
}
f_types_ << endl;
}
f_types_ << endl;
/* include custom headers */
const vector<string>& c_includes = program_->get_c_includes();
@ -579,7 +589,7 @@ string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_con
// TODO: discuss whether or not to implement TSet, THashSet or GHashSet
cname = "GHashTable";
} else if (ttype->is_list()) {
t_type* etype = ((t_list*)ttype)->get_elem_type();
t_type* etype = get_true_type(((t_list*)ttype)->get_elem_type());
if (etype->is_void()) {
throw std::runtime_error("compiler error: list element type cannot be void");
}
@ -602,7 +612,8 @@ string t_c_glib_generator::type_name(t_type* ttype, bool in_typedef, bool is_con
}
// check for a namespace
string pname = this->nspace + ttype->get_name();
t_program* tprogram = ttype->get_program();
string pname = (tprogram ? tprogram->get_namespace("c_glib") : "") + ttype->get_name();
if (is_complex_type(ttype)) {
pname += " *";
@ -997,8 +1008,8 @@ void t_c_glib_generator::generate_const_initializer(string name,
if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
ostringstream initializers;
// initialize any constants that may be referenced by this initializer
@ -1171,8 +1182,8 @@ void t_c_glib_generator::generate_const_initializer(string name,
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
ostringstream initializers;
ostringstream appenders;
@ -1831,8 +1842,10 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) {
string service_name_lc = to_lower_case(initial_caps_to_underscores(service_name_));
string service_name_uc = to_upper_case(service_name_lc);
string class_name = this->nspace + service_name_ + "Handler";
string class_name_lc = to_lower_case(initial_caps_to_underscores(class_name));
string service_handler_name = service_name_ + "Handler";
string class_name = this->nspace + service_handler_name;
string class_name_lc = this->nspace_lc + initial_caps_to_underscores(service_handler_name);
string class_name_uc = to_upper_case(class_name_lc);
string parent_class_name;
@ -2051,8 +2064,10 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) {
string service_name_lc = to_lower_case(initial_caps_to_underscores(service_name_));
string service_name_uc = to_upper_case(service_name_lc);
string class_name = this->nspace + service_name_ + "Processor";
string class_name_lc = to_lower_case(initial_caps_to_underscores(class_name));
string service_processor_name = service_name_ + "Processor";
string class_name = this->nspace + service_processor_name;
string class_name_lc = this->nspace_lc + initial_caps_to_underscores(service_processor_name);
string class_name_uc = to_upper_case(class_name_lc);
string parent_class_name;
@ -2784,7 +2799,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) {
string name_uc = to_upper_case(name_u);
string class_name = this->nspace + name;
string class_name_lc = to_lower_case(initial_caps_to_underscores(class_name));
string class_name_lc = this->nspace_lc + initial_caps_to_underscores(name);
string class_name_uc = to_upper_case(class_name_lc);
string function_name;
@ -3124,7 +3139,8 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) {
<< "THRIFT_UNUSED_VAR (object);" << endl;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
t_type* member_type = (*m_iter)->get_type();
t_type* t = get_true_type(member_type);
if (t->is_base_type()) {
string dval = " = ";
if (t->is_enum()) {
@ -3139,10 +3155,14 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) {
indent(f_types_impl_) << "object->" << (*m_iter)->get_name() << dval << ";" << endl;
} else if (t->is_struct()) {
string name = (*m_iter)->get_name();
string type_name_uc
= to_upper_case(initial_caps_to_underscores((*m_iter)->get_type()->get_name()));
indent(f_types_impl_) << "object->" << name << " = g_object_new (" << this->nspace_uc
<< "TYPE_" << type_name_uc << ", NULL);" << endl;
t_program* type_program = member_type->get_program();
string type_nspace = type_program ? type_program->get_namespace("c_glib") : "";
string type_nspace_prefix =
type_nspace.empty() ? "" : initial_caps_to_underscores(type_nspace) + "_";
string type_name_uc = to_upper_case(initial_caps_to_underscores(member_type->get_name()));
indent(f_types_impl_) << "object->" << name << " = g_object_new ("
<< to_upper_case(type_nspace_prefix) << "TYPE_" << type_name_uc
<< ", NULL);" << endl;
} else if (t->is_xception()) {
string name = (*m_iter)->get_name();
indent(f_types_impl_) << "object->" << name << " = NULL;" << endl;
@ -3424,7 +3444,12 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) {
<< "G_PARAM_READWRITE));" << endl;
indent_down();
} else if (member_type->is_struct() || member_type->is_xception()) {
string param_type = this->nspace_uc + "TYPE_"
t_program* type_program = member_type->get_program();
string type_nspace = type_program ? type_program->get_namespace("c_glib") : "";
string type_nspace_prefix =
type_nspace.empty() ? "" : initial_caps_to_underscores(type_nspace) + "_";
string param_type = to_upper_case(type_nspace_prefix) + "TYPE_"
+ to_upper_case(initial_caps_to_underscores(member_type->get_name()));
args_indent += string(20, ' ');
@ -3480,7 +3505,7 @@ void t_c_glib_generator::generate_object(t_struct* tstruct) {
/**
* Generates functions to write Thrift structures to a stream.
*/
void t_c_glib_generator::generate_struct_writer(ofstream& out,
void t_c_glib_generator::generate_struct_writer(ostream& out,
t_struct* tstruct,
string this_name,
string this_get,
@ -3553,7 +3578,7 @@ void t_c_glib_generator::generate_struct_writer(ofstream& out,
/**
* Generates code to read Thrift structures from a stream.
*/
void t_c_glib_generator::generate_struct_reader(ofstream& out,
void t_c_glib_generator::generate_struct_reader(ostream& out,
t_struct* tstruct,
string this_name,
string this_get,
@ -3690,7 +3715,7 @@ void t_c_glib_generator::generate_struct_reader(ofstream& out,
indent(out) << "}" << endl << endl;
}
void t_c_glib_generator::generate_serialize_field(ofstream& out,
void t_c_glib_generator::generate_serialize_field(ostream& out,
t_field* tfield,
string prefix,
string suffix,
@ -3734,7 +3759,7 @@ void t_c_glib_generator::generate_serialize_field(ofstream& out,
out << "double (protocol, " << name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "binary (protocol, " << name << " ? ((GByteArray *) " << name << ")->data : NULL, "
<< name << " ? ((GByteArray *) " << name << ")->len : 0";
} else {
@ -3756,7 +3781,7 @@ void t_c_glib_generator::generate_serialize_field(ofstream& out,
}
}
void t_c_glib_generator::generate_serialize_struct(ofstream& out,
void t_c_glib_generator::generate_serialize_struct(ostream& out,
t_struct* tstruct,
string prefix,
int error_ret) {
@ -3766,7 +3791,7 @@ void t_c_glib_generator::generate_serialize_struct(ofstream& out,
<< indent() << "xfer += ret;" << endl << endl;
}
void t_c_glib_generator::generate_serialize_container(ofstream& out,
void t_c_glib_generator::generate_serialize_container(ostream& out,
t_type* ttype,
string prefix,
int error_ret) {
@ -3923,7 +3948,7 @@ void t_c_glib_generator::generate_serialize_container(ofstream& out,
scope_down(out);
}
void t_c_glib_generator::generate_serialize_map_element(ofstream& out,
void t_c_glib_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string key,
string value,
@ -3935,7 +3960,7 @@ void t_c_glib_generator::generate_serialize_map_element(ofstream& out,
generate_serialize_field(out, &vfield, "", "", error_ret);
}
void t_c_glib_generator::generate_serialize_set_element(ofstream& out,
void t_c_glib_generator::generate_serialize_set_element(ostream& out,
t_set* tset,
string element,
int error_ret) {
@ -3943,7 +3968,7 @@ void t_c_glib_generator::generate_serialize_set_element(ofstream& out,
generate_serialize_field(out, &efield, "", "", error_ret);
}
void t_c_glib_generator::generate_serialize_list_element(ofstream& out,
void t_c_glib_generator::generate_serialize_list_element(ostream& out,
t_list* tlist,
string list,
string index,
@ -3975,7 +4000,7 @@ void t_c_glib_generator::generate_serialize_list_element(ofstream& out,
}
/* deserializes a field of any type. */
void t_c_glib_generator::generate_deserialize_field(ofstream& out,
void t_c_glib_generator::generate_deserialize_field(ostream& out,
t_field* tfield,
string prefix,
string suffix,
@ -4010,7 +4035,7 @@ void t_c_glib_generator::generate_deserialize_field(ofstream& out,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "binary (protocol, &data, &len";
} else {
out << "string (protocol, &" << name;
@ -4042,7 +4067,7 @@ void t_c_glib_generator::generate_deserialize_field(ofstream& out,
<< endl;
// load the byte array with the data
if (tbase == t_base_type::TYPE_STRING && ((t_base_type*)type)->is_binary()) {
if (tbase == t_base_type::TYPE_STRING && type->is_binary()) {
indent(out) << name << " = g_byte_array_new();" << endl;
indent(out) << "g_byte_array_append (" << name << ", (guint8 *) data, (guint) len);" << endl;
indent(out) << "g_free (data);" << endl;
@ -4061,14 +4086,14 @@ void t_c_glib_generator::generate_deserialize_field(ofstream& out,
// if the type is not required and this is a thrift struct (no prefix),
// set the isset variable. if the type is required, then set the
// local variable indicating the value was set, so that we can do // validation later.
if (tfield->get_req() != t_field::T_REQUIRED && prefix != "") {
if (prefix != "" && tfield->get_req() != t_field::T_REQUIRED) {
indent(out) << prefix << "__isset_" << tfield->get_name() << suffix << " = TRUE;" << endl;
} else if (tfield->get_req() == t_field::T_REQUIRED && prefix != "") {
} else if (prefix != "" && tfield->get_req() == t_field::T_REQUIRED) {
indent(out) << "isset_" << tfield->get_name() << " = TRUE;" << endl;
}
}
void t_c_glib_generator::generate_deserialize_struct(ofstream& out,
void t_c_glib_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix,
int error_ret,
@ -4101,7 +4126,7 @@ void t_c_glib_generator::generate_deserialize_struct(ofstream& out,
out << indent() << "}" << endl << indent() << "xfer += ret;" << endl;
}
void t_c_glib_generator::generate_deserialize_container(ofstream& out,
void t_c_glib_generator::generate_deserialize_container(ostream& out,
t_type* ttype,
string prefix,
int error_ret) {
@ -4202,7 +4227,7 @@ void t_c_glib_generator::generate_deserialize_container(ofstream& out,
scope_down(out);
}
void t_c_glib_generator::declare_local_variable(ofstream& out, t_type* ttype, string& name, bool for_hash_table) {
void t_c_glib_generator::declare_local_variable(ostream& out, t_type* ttype, string& name, bool for_hash_table) {
string tname = type_name(ttype);
/* If the given type is a typedef, find its underlying type so we
@ -4226,7 +4251,7 @@ void t_c_glib_generator::declare_local_variable(ofstream& out, t_type* ttype, st
}
}
void t_c_glib_generator::declore_local_variable_for_write(ofstream& out,
void t_c_glib_generator::declore_local_variable_for_write(ostream& out,
t_type* ttype,
string& name) {
string tname = type_name(ttype);
@ -4236,7 +4261,7 @@ void t_c_glib_generator::declore_local_variable_for_write(ofstream& out,
out << indent() << tname << ptr << name << init_val << ";" << endl;
}
void t_c_glib_generator::generate_deserialize_map_element(ofstream& out,
void t_c_glib_generator::generate_deserialize_map_element(ostream& out,
t_map* tmap,
string prefix,
int error_ret) {
@ -4270,7 +4295,7 @@ void t_c_glib_generator::generate_deserialize_map_element(ofstream& out,
indent_down();
}
void t_c_glib_generator::generate_deserialize_set_element(ofstream& out,
void t_c_glib_generator::generate_deserialize_set_element(ostream& out,
t_set* tset,
string prefix,
int error_ret) {
@ -4290,7 +4315,7 @@ void t_c_glib_generator::generate_deserialize_set_element(ofstream& out,
indent_down();
}
void t_c_glib_generator::generate_deserialize_list_element(ofstream& out,
void t_c_glib_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix,
string index,

View file

@ -0,0 +1,558 @@
/*
* Copyright (c) 2008- Patrick Collison <patrick@collison.ie>
* Copyright (c) 2006- Facebook
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <boost/tokenizer.hpp>
#include <sys/stat.h>
#include <sys/types.h>
#include <sstream>
#include <string>
#include <algorithm>
#include "thrift/platform.h"
#include "t_oop_generator.h"
using namespace std;
/**
* Common Lisp code generator.
*
* @author Patrick Collison <patrick@collison.ie>
*/
class t_cl_generator : public t_oop_generator {
public:
t_cl_generator(
t_program* program,
const std::map<std::string, std::string>& parsed_options,
const std::string& option_string)
: t_oop_generator(program)
{
no_asd = false;
system_prefix = "thrift-gen-";
std::map<std::string, std::string>::const_iterator iter;
for(iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
if(iter->first.compare("no_asd") == 0) {
no_asd = true;
} else if (iter->first.compare("sys_pref") == 0) {
system_prefix = iter->second;
} else {
throw "unknown option cl:" + iter->first;
}
}
out_dir_base_ = "gen-cl";
copy_options_ = option_string;
}
void init_generator();
void close_generator();
void generate_typedef (t_typedef* ttypedef);
void generate_enum (t_enum* tenum);
void generate_const (t_const* tconst);
void generate_struct (t_struct* tstruct);
void generate_xception (t_struct* txception);
void generate_service (t_service* tservice);
void generate_cl_struct (std::ostream& out, t_struct* tstruct, bool is_exception);
void generate_cl_struct_internal (std::ostream& out, t_struct* tstruct, bool is_exception);
void generate_exception_sig(std::ostream& out, t_function* f);
std::string render_const_value(t_type* type, t_const_value* value);
std::string cl_autogen_comment();
void asdf_def(std::ostream &out);
void package_def(std::ostream &out);
void package_in(std::ostream &out);
std::string generated_package();
std::string prefix(std::string name);
std::string package_of(t_program* program);
std::string package();
std::string render_includes();
std::string type_name(t_type* ttype);
std::string typespec (t_type *t);
std::string function_signature(t_function* tfunction);
std::string argument_list(t_struct* tstruct);
std::string cl_docstring(std::string raw);
private:
int temporary_var;
/**
* Isolate the variable definitions, as they can require structure definitions
*/
ofstream_with_content_based_conditional_update f_asd_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_vars_;
std::string copy_options_;
bool no_asd;
std::string system_prefix;
};
void t_cl_generator::init_generator() {
MKDIR(get_out_dir().c_str());
string program_dir = get_out_dir() + "/" + program_name_;
MKDIR(program_dir.c_str());
temporary_var = 0;
string f_types_name = program_dir + "/" + program_name_ + "-types.lisp";
string f_vars_name = program_dir + "/" + program_name_ + "-vars.lisp";
f_types_.open(f_types_name.c_str());
f_types_ << cl_autogen_comment() << endl;
f_vars_.open(f_vars_name.c_str());
f_vars_ << cl_autogen_comment() << endl;
package_def(f_types_);
package_in(f_types_);
package_in(f_vars_);
if (!no_asd) {
string f_asd_name = program_dir + "/" + system_prefix + program_name_ + ".asd";
f_asd_.open(f_asd_name.c_str());
f_asd_ << cl_autogen_comment() << endl;
asdf_def(f_asd_);
}
}
/**
* Renders all the imports necessary for including another Thrift program
*/
string t_cl_generator::render_includes() {
const vector<t_program*>& includes = program_->get_includes();
string result = "";
result += ":depends-on (:thrift";
for (size_t i = 0; i < includes.size(); ++i) {
result += " :" + system_prefix + underscore(includes[i]->get_name());
}
result += ")\n";
return result;
}
string t_cl_generator::package_of(t_program* program) {
string prefix = program->get_namespace("cl");
return prefix.empty() ? "thrift-generated" : prefix;
}
string t_cl_generator::package() {
return package_of(program_);
}
string t_cl_generator::prefix(string symbol) {
return "\"" + symbol + "\"";
}
string t_cl_generator::cl_autogen_comment() {
return
std::string(";;; ") + "Autogenerated by Thrift\n" +
";;; DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
";;; options string: " + copy_options_ + "\n";
}
string t_cl_generator::cl_docstring(string raw) {
replace(raw.begin(), raw.end(), '"', '\'');
return raw;
}
void t_cl_generator::close_generator() {
f_asd_.close();
f_types_.close();
f_vars_.close();
}
string t_cl_generator::generated_package() {
return program_->get_namespace("cpp");
}
void t_cl_generator::asdf_def(std::ostream &out) {
out << "(asdf:defsystem #:" << system_prefix << program_name_ << endl;
indent_up();
out << indent() << render_includes()
<< indent() << ":serial t" << endl
<< indent() << ":components ("
<< "(:file \"" << program_name_ << "-types\") "
<< "(:file \"" << program_name_ << "-vars\")))" << endl;
indent_down();
}
/***
* Generate a package definition. Add use references equivalent to the idl file's include statements.
*/
void t_cl_generator::package_def(std::ostream &out) {
const vector<t_program*>& includes = program_->get_includes();
out << "(thrift:def-package :" << package();
if ( includes.size() > 0 ) {
out << " :use (";
for (size_t i = 0; i < includes.size(); ++i) {
out << " :" << includes[i]->get_name();
}
out << ")";
}
out << ")" << endl << endl;
}
void t_cl_generator::package_in(std::ostream &out) {
out << "(cl:in-package :" << package() << ")" << endl << endl;
}
/**
* Generates a typedef. This is not done in Common Lisp, types are all implicit.
*
* @param ttypedef The type definition
*/
void t_cl_generator::generate_typedef(t_typedef* ttypedef) {
(void)ttypedef;
}
void t_cl_generator::generate_enum(t_enum* tenum) {
f_types_ << "(thrift:def-enum " << prefix(tenum->get_name()) << endl;
vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter;
int value = -1;
indent_up();
f_types_ << indent() << "(";
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
value = (*c_iter)->get_value();
if(c_iter != constants.begin()) f_types_ << endl << indent() << " ";
f_types_ << "(\"" << (*c_iter)->get_name() << "\" . " << value << ")";
}
indent_down();
f_types_ << "))" << endl << endl;
}
/**
* Generate a constant value
*/
void t_cl_generator::generate_const(t_const* tconst) {
t_type* type = tconst->get_type();
string name = tconst->get_name();
t_const_value* value = tconst->get_value();
f_vars_ << "(thrift:def-constant " << prefix(name) << " " << render_const_value(type, value) << ")"
<< endl << endl;
}
/**
* Prints the value of a constant with the given type. Note that type checking
* is NOT performed in this function as it is always run beforehand using the
* validate_types method in main.cc
*/
string t_cl_generator::render_const_value(t_type* type, t_const_value* value) {
type = get_true_type(type);
std::ostringstream out;
if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
out << "\"" << value->get_string() << "\"";
break;
case t_base_type::TYPE_BOOL:
out << (value->get_integer() > 0 ? "t" : "nil");
break;
case t_base_type::TYPE_I8:
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
case t_base_type::TYPE_I64:
out << value->get_integer();
break;
case t_base_type::TYPE_DOUBLE:
if (value->get_type() == t_const_value::CV_INTEGER) {
out << value->get_integer();
} else {
out << value->get_double();
}
break;
default:
throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
}
} else if (type->is_enum()) {
indent(out) << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
out << (type->is_struct() ? "(make-instance '" : "(make-exception '") <<
lowercase(type->get_name()) << " " << endl;
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
if (field_type == NULL) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
out << indent() << ":" << v_iter->first->get_string() << " " <<
render_const_value(field_type, v_iter->second) << endl;
}
out << indent() << ")";
indent_down();
} else if (type->is_map()) {
// emit an hash form with both keys and values to be evaluated
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
out << "(thrift:map ";
indent_up();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << endl << indent()
<< "(cl:cons " << render_const_value(ktype, v_iter->first) << " "
<< render_const_value(vtype, v_iter->second) << ")";
}
indent_down();
out << indent() << ")";
} else if (type->is_list() || type->is_set()) {
t_type* etype;
if (type->is_list()) {
etype = ((t_list*)type)->get_elem_type();
} else {
etype = ((t_set*)type)->get_elem_type();
}
if (type->is_set()) {
out << "(thrift:set" << endl;
} else {
out << "(thrift:list" << endl;
}
indent_up();
indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << indent() << render_const_value(etype, *v_iter) << endl;
}
out << indent() << ")";
indent_down();
indent_down();
} else {
throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
}
return out.str();
}
void t_cl_generator::generate_struct(t_struct* tstruct) {
generate_cl_struct(f_types_, tstruct, false);
}
void t_cl_generator::generate_xception(t_struct* txception) {
generate_cl_struct(f_types_, txception, true);
}
void t_cl_generator::generate_cl_struct_internal(std::ostream& out, t_struct* tstruct, bool is_exception) {
(void)is_exception;
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
out << "(";
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_const_value* value = (*m_iter)->get_value();
t_type* type = (*m_iter)->get_type();
if (m_iter != members.begin()) {
out << endl << indent() << " ";
}
out << "(" << prefix((*m_iter)->get_name()) << " " <<
( (NULL != value) ? render_const_value(type, value) : "nil" ) <<
" :id " << (*m_iter)->get_key();
if ( type->is_base_type() && "string" == typespec(type) )
if ( ((t_base_type*)type)->is_binary() )
out << " :type binary";
else
out << " :type string";
else
out << " :type " << typespec(type);
if ( (*m_iter)->get_req() == t_field::T_OPTIONAL ) {
out << " :optional t";
}
if ( (*m_iter)->has_doc()) {
out << " :documentation \"" << cl_docstring((*m_iter)->get_doc()) << "\"";
}
out <<")";
}
out << ")";
}
void t_cl_generator::generate_cl_struct(std::ostream& out, t_struct* tstruct, bool is_exception = false) {
std::string name = type_name(tstruct);
out << (is_exception ? "(thrift:def-exception " : "(thrift:def-struct ") <<
prefix(name) << endl;
indent_up();
if ( tstruct->has_doc() ) {
out << indent() ;
out << "\"" << cl_docstring(tstruct->get_doc()) << "\"" << endl;
}
out << indent() ;
generate_cl_struct_internal(out, tstruct, is_exception);
indent_down();
out << ")" << endl << endl;
}
void t_cl_generator::generate_exception_sig(std::ostream& out, t_function* f) {
generate_cl_struct_internal(out, f->get_xceptions(), true);
}
void t_cl_generator::generate_service(t_service* tservice) {
string extends_client;
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
if (tservice->get_extends() != NULL) {
extends_client = type_name(tservice->get_extends());
}
extends_client = extends_client.empty() ? "nil" : prefix(extends_client);
f_types_ << "(thrift:def-service " << prefix(service_name_) << " "
<< extends_client;
indent_up();
if ( tservice->has_doc()) {
f_types_ << endl << indent()
<< "(:documentation \"" << cl_docstring(tservice->get_doc()) << "\")";
}
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_function* function = *f_iter;
string fname = function->get_name();
string signature = function_signature(function);
t_struct* exceptions = function->get_xceptions();
const vector<t_field*>& xmembers = exceptions->get_members();
f_types_ << endl << indent() << "(:method " << prefix(fname);
f_types_ << " (" << signature << " " << typespec((*f_iter)->get_returntype()) << ")";
if (xmembers.size() > 0) {
f_types_ << endl << indent() << " :exceptions " ;
generate_exception_sig(f_types_, function);
}
if ( (*f_iter)->is_oneway() ) {
f_types_ << endl << indent() << " :oneway t";
}
if ( (*f_iter)->has_doc() ) {
f_types_ << endl << indent() << " :documentation \""
<< cl_docstring((*f_iter)->get_doc()) << "\"";
}
f_types_ << ")";
}
f_types_ << ")" << endl << endl;
indent_down();
}
string t_cl_generator::typespec(t_type *t) {
t = get_true_type(t);
if (t -> is_binary()){
return "binary";
} else if (t->is_base_type()) {
return type_name(t);
} else if (t->is_map()) {
t_map *m = (t_map*) t;
return "(thrift:map " + typespec(m->get_key_type()) + " " +
typespec(m->get_val_type()) + ")";
} else if (t->is_struct() || t->is_xception()) {
return "(struct " + prefix(type_name(t)) + ")";
} else if (t->is_list()) {
return "(thrift:list " + typespec(((t_list*) t)->get_elem_type()) + ")";
} else if (t->is_set()) {
return "(thrift:set " + typespec(((t_set*) t)->get_elem_type()) + ")";
} else if (t->is_enum()) {
return "(enum \"" + ((t_enum*) t)->get_name() + "\")";
} else {
throw "Sorry, I don't know how to generate this: " + type_name(t);
}
}
string t_cl_generator::function_signature(t_function* tfunction) {
return argument_list(tfunction->get_arglist());
}
string t_cl_generator::argument_list(t_struct* tstruct) {
stringstream res;
res << "(";
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
bool first = true;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if (first) {
first = false;
} else {
res << " ";
}
res << "(" + prefix((*f_iter)->get_name()) << " " <<
typespec((*f_iter)->get_type()) << " " <<
(*f_iter)->get_key() << ")";
}
res << ")";
return res.str();
}
string t_cl_generator::type_name(t_type* ttype) {
string prefix = "";
t_program* program = ttype->get_program();
if (program != NULL && program != program_)
prefix = package_of(program) == package() ? "" : package_of(program) + ":";
string name = ttype->get_name();
if (ttype->is_struct() || ttype->is_xception())
name = lowercase(ttype->get_name());
return prefix + name;
}
THRIFT_REGISTER_GENERATOR(
cl,
"Common Lisp",
" no_asd: Do not define ASDF systems for each generated Thrift program.\n"
" sys_pref= The prefix to give ASDF system names. Default: thrift-gen-\n")

View file

@ -109,35 +109,35 @@ public:
bool box_it = false);
void generate_cocoa_struct(t_struct* tstruct, bool is_exception);
void generate_cocoa_struct_interface(std::ofstream& out,
void generate_cocoa_struct_interface(std::ostream& out,
t_struct* tstruct,
bool is_xception = false);
void generate_cocoa_struct_implementation(std::ofstream& out,
void generate_cocoa_struct_implementation(std::ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool is_result = false);
void generate_cocoa_struct_initializer_signature(std::ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_init_with_coder_method(ofstream& out,
void generate_cocoa_struct_initializer_signature(std::ostream& out, t_struct* tstruct);
void generate_cocoa_struct_init_with_coder_method(ostream& out,
t_struct* tstruct,
bool is_exception);
void generate_cocoa_struct_encode_with_coder_method(ofstream& out,
void generate_cocoa_struct_encode_with_coder_method(ostream& out,
t_struct* tstruct,
bool is_exception);
void generate_cocoa_struct_copy_method(ofstream& out,
void generate_cocoa_struct_copy_method(ostream& out,
t_struct* tstruct,
bool is_exception);
void generate_cocoa_struct_hash_method(ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_is_equal_method(ofstream& out,
void generate_cocoa_struct_hash_method(ostream& out, t_struct* tstruct);
void generate_cocoa_struct_is_equal_method(ostream& out,
t_struct* tstruct,
bool is_exception);
void generate_cocoa_struct_field_accessor_implementations(std::ofstream& out,
void generate_cocoa_struct_field_accessor_implementations(std::ostream& out,
t_struct* tstruct,
bool is_exception);
void generate_cocoa_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_result_writer(std::ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_validator(std::ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_description(std::ofstream& out, t_struct* tstruct);
void generate_cocoa_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_cocoa_struct_result_writer(std::ostream& out, t_struct* tstruct);
void generate_cocoa_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_cocoa_struct_validator(std::ostream& out, t_struct* tstruct);
void generate_cocoa_struct_description(std::ostream& out, t_struct* tstruct);
std::string function_result_helper_struct_type(t_service *tservice, t_function* tfunction);
std::string function_args_helper_struct_type(t_service* tservice, t_function* tfunction);
@ -147,29 +147,29 @@ public:
* Service-level generation functions
*/
void generate_cocoa_service_protocol(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_async_protocol(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_protocol(std::ostream& out, t_service* tservice);
void generate_cocoa_service_async_protocol(std::ostream& out, t_service* tservice);
void generate_cocoa_service_client_interface(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_client_async_interface(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_client_interface(std::ostream& out, t_service* tservice);
void generate_cocoa_service_client_async_interface(std::ostream& out, t_service* tservice);
void generate_cocoa_service_client_send_function_implementation(ofstream& out,
void generate_cocoa_service_client_send_function_implementation(ostream& out,
t_service* tservice,
t_function* tfunction,
bool needs_protocol);
void generate_cocoa_service_client_send_function_invocation(ofstream& out, t_function* tfunction);
void generate_cocoa_service_client_send_async_function_invocation(ofstream& out,
void generate_cocoa_service_client_send_function_invocation(ostream& out, t_function* tfunction);
void generate_cocoa_service_client_send_async_function_invocation(ostream& out,
t_function* tfunction,
string failureBlockName);
void generate_cocoa_service_client_recv_function_implementation(ofstream& out,
void generate_cocoa_service_client_recv_function_implementation(ostream& out,
t_service* tservice,
t_function* tfunction,
bool needs_protocol);
void generate_cocoa_service_client_implementation(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_client_async_implementation(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_client_implementation(std::ostream& out, t_service* tservice);
void generate_cocoa_service_client_async_implementation(std::ostream& out, t_service* tservice);
void generate_cocoa_service_server_interface(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_server_implementation(std::ofstream& out, t_service* tservice);
void generate_cocoa_service_server_interface(std::ostream& out, t_service* tservice);
void generate_cocoa_service_server_implementation(std::ostream& out, t_service* tservice);
void generate_cocoa_service_helpers(t_service* tservice);
void generate_service_client(t_service* tservice);
void generate_service_server(t_service* tservice);
@ -179,34 +179,34 @@ public:
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string fieldName);
void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string fieldName);
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string fieldName = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string fieldName = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string iter,
std::string map);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out,
void generate_serialize_list_element(std::ostream& out,
t_list* tlist,
std::string index,
std::string listName);
@ -238,6 +238,12 @@ public:
std::string getter_name(string field_name);
std::string setter_name(string field_name);
bool type_can_be_copy(t_type* ttype) {
ttype = get_true_type(ttype);
return ttype->is_string();
}
bool type_can_be_null(t_type* ttype) {
ttype = get_true_type(ttype);
@ -254,8 +260,8 @@ private:
* File streams
*/
std::ofstream f_header_;
std::ofstream f_impl_;
ofstream_with_content_based_conditional_update f_header_;
ofstream_with_content_based_conditional_update f_impl_;
bool log_unexpected_;
bool validate_required_;
@ -568,7 +574,7 @@ void t_cocoa_generator::generate_xception(t_struct* txception) {
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_interface(ofstream& out,
void t_cocoa_generator::generate_cocoa_struct_interface(ostream& out,
t_struct* tstruct,
bool is_exception) {
@ -618,7 +624,7 @@ void t_cocoa_generator::generate_cocoa_struct_interface(ofstream& out,
* Generate signature for initializer of struct with a parameter for
* each field.
*/
void t_cocoa_generator::generate_cocoa_struct_initializer_signature(ofstream& out,
void t_cocoa_generator::generate_cocoa_struct_initializer_signature(ostream& out,
t_struct* tstruct) {
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
@ -641,7 +647,7 @@ void t_cocoa_generator::generate_cocoa_struct_initializer_signature(ofstream& ou
* Generate the initWithCoder method for this struct so it's compatible with
* the NSCoding protocol
*/
void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream& out,
void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ostream& out,
t_struct* tstruct,
bool is_exception) {
@ -713,7 +719,7 @@ void t_cocoa_generator::generate_cocoa_struct_init_with_coder_method(ofstream& o
* Generate the encodeWithCoder method for this struct so it's compatible with
* the NSCoding protocol
*/
void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream& out,
void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ostream& out,
t_struct* tstruct,
bool is_exception) {
@ -780,7 +786,7 @@ void t_cocoa_generator::generate_cocoa_struct_encode_with_coder_method(ofstream&
/**
* Generate the copy method for this struct
*/
void t_cocoa_generator::generate_cocoa_struct_copy_method(ofstream& out, t_struct* tstruct, bool is_exception) {
void t_cocoa_generator::generate_cocoa_struct_copy_method(ostream& out, t_struct* tstruct, bool is_exception) {
out << indent() << "- (instancetype) copyWithZone:(NSZone *)zone" << endl;
scope_up(out);
@ -815,7 +821,7 @@ void t_cocoa_generator::generate_cocoa_struct_copy_method(ofstream& out, t_struc
/**
* Generate the hash method for this struct
*/
void t_cocoa_generator::generate_cocoa_struct_hash_method(ofstream& out, t_struct* tstruct) {
void t_cocoa_generator::generate_cocoa_struct_hash_method(ostream& out, t_struct* tstruct) {
indent(out) << "- (NSUInteger) hash" << endl;
scope_up(out);
out << indent() << "NSUInteger hash = 17;" << endl;
@ -846,7 +852,7 @@ void t_cocoa_generator::generate_cocoa_struct_hash_method(ofstream& out, t_struc
/**
* Generate the isEqual method for this struct
*/
void t_cocoa_generator::generate_cocoa_struct_is_equal_method(ofstream& out, t_struct* tstruct, bool is_exception) {
void t_cocoa_generator::generate_cocoa_struct_is_equal_method(ostream& out, t_struct* tstruct, bool is_exception) {
indent(out) << "- (BOOL) isEqual: (id) anObject" << endl;
scope_up(out);
@ -913,7 +919,7 @@ void t_cocoa_generator::generate_cocoa_struct_is_equal_method(ofstream& out, t_s
* @param is_exception Is this an exception?
* @param is_result If this is a result it needs a different writer
*/
void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream& out,
void t_cocoa_generator::generate_cocoa_struct_implementation(ostream& out,
t_struct* tstruct,
bool is_exception,
bool is_result) {
@ -1017,7 +1023,7 @@ void t_cocoa_generator::generate_cocoa_struct_implementation(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_reader(ofstream& out, t_struct* tstruct) {
void t_cocoa_generator::generate_cocoa_struct_reader(ostream& out, t_struct* tstruct) {
out << "- (BOOL) read: (id <TProtocol>) inProtocol error: (NSError *__autoreleasing *)__thriftError" << endl;
scope_up(out);
@ -1111,7 +1117,7 @@ void t_cocoa_generator::generate_cocoa_struct_reader(ofstream& out, t_struct* ts
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_writer(ofstream& out, t_struct* tstruct) {
void t_cocoa_generator::generate_cocoa_struct_writer(ostream& out, t_struct* tstruct) {
out << indent() << "- (BOOL) write: (id <TProtocol>) outProtocol error: (NSError *__autoreleasing *)__thriftError {" << endl;
indent_up();
@ -1162,7 +1168,7 @@ void t_cocoa_generator::generate_cocoa_struct_writer(ofstream& out, t_struct* ts
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_result_writer(ofstream& out, t_struct* tstruct) {
void t_cocoa_generator::generate_cocoa_struct_result_writer(ostream& out, t_struct* tstruct) {
out << indent() << "- (BOOL) write: (id <TProtocol>) outProtocol error: (NSError *__autoreleasing *)__thriftError {" << endl;
indent_up();
@ -1225,7 +1231,7 @@ void t_cocoa_generator::generate_cocoa_struct_result_writer(ofstream& out, t_str
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out, t_struct* tstruct) {
void t_cocoa_generator::generate_cocoa_struct_validator(ostream& out, t_struct* tstruct) {
out << indent() << "- (BOOL) validate: (NSError *__autoreleasing *)__thriftError {" << endl;
indent_up();
@ -1259,7 +1265,7 @@ void t_cocoa_generator::generate_cocoa_struct_validator(ofstream& out, t_struct*
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_field_accessor_implementations(ofstream& out,
void t_cocoa_generator::generate_cocoa_struct_field_accessor_implementations(ostream& out,
t_struct* tstruct,
bool is_exception) {
(void)is_exception;
@ -1298,7 +1304,7 @@ void t_cocoa_generator::generate_cocoa_struct_field_accessor_implementations(ofs
*
* @param tstruct The struct definition
*/
void t_cocoa_generator::generate_cocoa_struct_description(ofstream& out, t_struct* tstruct) {
void t_cocoa_generator::generate_cocoa_struct_description(ostream& out, t_struct* tstruct) {
// Allow use of debugDescription so the app can add description via a cateogory/extension
if (debug_descriptions_) {
@ -1428,7 +1434,7 @@ void t_cocoa_generator::generate_function_helpers(t_service *tservice, t_functio
*
* @param tservice The service to generate a protocol definition for
*/
void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out, t_service* tservice) {
void t_cocoa_generator::generate_cocoa_service_protocol(ostream& out, t_service* tservice) {
out << "@protocol " << cocoa_prefix_ << tservice->get_name() << " <NSObject>" << endl;
vector<t_function*> functions = tservice->get_functions();
@ -1452,7 +1458,7 @@ void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out, t_service
*
* @param tservice The service to generate a protocol definition for
*/
void t_cocoa_generator::generate_cocoa_service_async_protocol(ofstream& out, t_service* tservice) {
void t_cocoa_generator::generate_cocoa_service_async_protocol(ostream& out, t_service* tservice) {
out << "@protocol " << cocoa_prefix_ << tservice->get_name() << "Async"
<< " <NSObject>" << endl;
@ -1472,7 +1478,7 @@ void t_cocoa_generator::generate_cocoa_service_async_protocol(ofstream& out, t_s
*
* @param tservice The service to generate a client interface definition for
*/
void t_cocoa_generator::generate_cocoa_service_client_interface(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_client_interface(ostream& out,
t_service* tservice) {
out << "@interface " << cocoa_prefix_ << tservice->get_name() << "Client : TBaseClient <"
<< cocoa_prefix_ << tservice->get_name() << "> " << endl;
@ -1488,7 +1494,7 @@ void t_cocoa_generator::generate_cocoa_service_client_interface(ofstream& out,
*
* @param tservice The service to generate a client interface definition for
*/
void t_cocoa_generator::generate_cocoa_service_client_async_interface(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_client_async_interface(ostream& out,
t_service* tservice) {
out << "@interface " << cocoa_prefix_ << tservice->get_name() << "ClientAsync : TBaseClient <"
<< cocoa_prefix_ << tservice->get_name() << "Async> " << endl
@ -1506,7 +1512,7 @@ void t_cocoa_generator::generate_cocoa_service_client_async_interface(ofstream&
*
* @param tservice The service to generate a client interface definition for
*/
void t_cocoa_generator::generate_cocoa_service_server_interface(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_server_interface(ostream& out,
t_service* tservice) {
out << "@interface " << cocoa_prefix_ << tservice->get_name()
<< "Processor : NSObject <TProcessor> " << endl;
@ -1519,7 +1525,7 @@ void t_cocoa_generator::generate_cocoa_service_server_interface(ofstream& out,
}
void t_cocoa_generator::generate_cocoa_service_client_send_function_implementation(
ofstream& out,
ostream& out,
t_service *tservice,
t_function* tfunction,
bool needs_protocol) {
@ -1577,7 +1583,7 @@ void t_cocoa_generator::generate_cocoa_service_client_send_function_implementati
}
void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementation(
ofstream& out,
ostream& out,
t_service* tservice,
t_function* tfunction,
bool needs_protocol) {
@ -1666,7 +1672,7 @@ void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementati
* @param tfunction The service to generate an implementation for
*/
void t_cocoa_generator::generate_cocoa_service_client_send_function_invocation(
ofstream& out,
ostream& out,
t_function* tfunction) {
t_struct* arg_struct = tfunction->get_arglist();
@ -1696,7 +1702,7 @@ void t_cocoa_generator::generate_cocoa_service_client_send_function_invocation(
* @param tfunction The service to generate an implementation for
*/
void t_cocoa_generator::generate_cocoa_service_client_send_async_function_invocation(
ofstream& out,
ostream& out,
t_function* tfunction,
string failureBlockName) {
@ -1730,7 +1736,7 @@ void t_cocoa_generator::generate_cocoa_service_client_send_async_function_invoca
*
* @param tservice The service to generate an implementation for
*/
void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_client_implementation(ostream& out,
t_service* tservice) {
string name = cocoa_prefix_ + tservice->get_name() + "Client";
@ -1814,7 +1820,7 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o
*
* @param tservice The service to generate an implementation for
*/
void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ostream& out,
t_service* tservice) {
string name = cocoa_prefix_ + tservice->get_name() + "ClientAsync";
@ -1974,7 +1980,7 @@ void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ofstr
*
* @param tservice The service to generate an implementation for
*/
void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& out,
void t_cocoa_generator::generate_cocoa_service_server_implementation(ostream& out,
t_service* tservice) {
string name = cocoa_prefix_ + tservice->get_name() + "Processor";
@ -2150,7 +2156,7 @@ void t_cocoa_generator::generate_cocoa_service_server_implementation(ofstream& o
* @param tfield The field
* @param fieldName The variable name for this field
*/
void t_cocoa_generator::generate_deserialize_field(ofstream& out,
void t_cocoa_generator::generate_deserialize_field(ostream& out,
t_field* tfield,
string fieldName) {
t_type* type = get_true_type(tfield->get_type());
@ -2174,7 +2180,7 @@ void t_cocoa_generator::generate_deserialize_field(ofstream& out,
throw "compiler error: cannot serialize void field in a struct: " + tfield->get_name();
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "readBinary:&" << fieldName << " error: __thriftError]";
} else {
out << "readString:&" << fieldName << " error: __thriftError]";
@ -2216,7 +2222,7 @@ void t_cocoa_generator::generate_deserialize_field(ofstream& out,
/**
* Generates an unserializer for a struct, allocates the struct and invokes read:
*/
void t_cocoa_generator::generate_deserialize_struct(ofstream& out,
void t_cocoa_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string fieldName) {
indent(out) << type_name(tstruct) << fieldName << " = [[" << type_name(tstruct, true)
@ -2227,7 +2233,7 @@ void t_cocoa_generator::generate_deserialize_struct(ofstream& out,
/**
* Deserializes a container by reading its size and then iterating
*/
void t_cocoa_generator::generate_deserialize_container(ofstream& out,
void t_cocoa_generator::generate_deserialize_container(ostream& out,
t_type* ttype,
string fieldName) {
string size = tmp("_size");
@ -2348,7 +2354,7 @@ string t_cocoa_generator::unbox(t_type* ttype, string field_name) {
/**
* Generates code to deserialize a map element
*/
void t_cocoa_generator::generate_deserialize_map_element(ofstream& out,
void t_cocoa_generator::generate_deserialize_map_element(ostream& out,
t_map* tmap,
string fieldName) {
string key = tmp("_key");
@ -2368,7 +2374,7 @@ void t_cocoa_generator::generate_deserialize_map_element(ofstream& out,
/**
* Deserializes a set element
*/
void t_cocoa_generator::generate_deserialize_set_element(ofstream& out,
void t_cocoa_generator::generate_deserialize_set_element(ostream& out,
t_set* tset,
string fieldName) {
string elem = tmp("_elem");
@ -2383,7 +2389,7 @@ void t_cocoa_generator::generate_deserialize_set_element(ofstream& out,
/**
* Deserializes a list element
*/
void t_cocoa_generator::generate_deserialize_list_element(ofstream& out,
void t_cocoa_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string fieldName) {
string elem = tmp("_elem");
@ -2401,7 +2407,7 @@ void t_cocoa_generator::generate_deserialize_list_element(ofstream& out,
* @param tfield The field to serialize
* @param fieldName Name to of the variable holding the field
*/
void t_cocoa_generator::generate_serialize_field(ofstream& out, t_field* tfield, string fieldName) {
void t_cocoa_generator::generate_serialize_field(ostream& out, t_field* tfield, string fieldName) {
t_type* type = get_true_type(tfield->get_type());
// Do nothing for void types
@ -2423,7 +2429,7 @@ void t_cocoa_generator::generate_serialize_field(ofstream& out, t_field* tfield,
throw "compiler error: cannot serialize void field in a struct: " + fieldName;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "writeBinary: " << fieldName << " error: __thriftError]";
} else {
out << "writeString: " << fieldName << " error: __thriftError]";
@ -2468,7 +2474,7 @@ void t_cocoa_generator::generate_serialize_field(ofstream& out, t_field* tfield,
* @param tstruct The struct to serialize
* @param fieldName Name of variable holding struct
*/
void t_cocoa_generator::generate_serialize_struct(ofstream& out,
void t_cocoa_generator::generate_serialize_struct(ostream& out,
t_struct* tstruct,
string fieldName) {
(void)tstruct;
@ -2481,7 +2487,7 @@ void t_cocoa_generator::generate_serialize_struct(ofstream& out,
* @param ttype The type of container
* @param fieldName Name of variable holding container
*/
void t_cocoa_generator::generate_serialize_container(ofstream& out,
void t_cocoa_generator::generate_serialize_container(ostream& out,
t_type* ttype,
string fieldName) {
scope_up(out);
@ -2547,7 +2553,7 @@ void t_cocoa_generator::generate_serialize_container(ofstream& out,
/**
* Serializes the members of a map.
*/
void t_cocoa_generator::generate_serialize_map_element(ofstream& out,
void t_cocoa_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string key,
string mapName) {
@ -2560,7 +2566,7 @@ void t_cocoa_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_cocoa_generator::generate_serialize_set_element(ofstream& out,
void t_cocoa_generator::generate_serialize_set_element(ostream& out,
t_set* tset,
string elementName) {
t_field efield(tset->get_elem_type(), elementName);
@ -2570,7 +2576,7 @@ void t_cocoa_generator::generate_serialize_set_element(ofstream& out,
/**
* Serializes the members of a list.
*/
void t_cocoa_generator::generate_serialize_list_element(ofstream& out,
void t_cocoa_generator::generate_serialize_list_element(ostream& out,
t_list* tlist,
string index,
string listName) {
@ -2733,8 +2739,8 @@ void t_cocoa_generator::print_const_value(ostream& out,
indent(out);
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
if (defval)
out << type_name(type) << " ";
out << name << " = [" << type_name(type, true) << " new];"
@ -2758,8 +2764,8 @@ void t_cocoa_generator::print_const_value(ostream& out,
indent(mapout);
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
if (defval)
mapout << type_name(type) << " ";
mapout << name << " = @{";
@ -2824,7 +2830,7 @@ string t_cocoa_generator::render_const_value(ostream& out,
case t_base_type::TYPE_STRING:
// We must handle binary constant but the syntax of IDL defines
// nothing about binary constant.
// if ((t_base_type*)type)->is_binary())
// if type->is_binary())
// // binary code
render << "@\"" << get_escaped_string(value) << '"';
break;
@ -2904,8 +2910,8 @@ string t_cocoa_generator::render_const_value(string name,
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
if (val.size() > 0)
render << "[[" << type_name(type, true) << " alloc] initWith";
else
@ -2937,8 +2943,8 @@ string t_cocoa_generator::render_const_value(string name,
render << "[[NSDictionary alloc] initWithObjectsAndKeys: ";
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
bool first = true;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(name, ktype, v_iter->first, true);
@ -3011,7 +3017,9 @@ string t_cocoa_generator::declare_property(t_field* tfield) {
std::ostringstream render;
render << "@property (";
if (type_can_be_null(tfield->get_type())) {
if (type_can_be_copy(tfield->get_type())) {
render << "copy, ";
} else if (type_can_be_null(tfield->get_type())) {
render << "strong, ";
} else {
render << "assign, ";

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -100,46 +100,46 @@ public:
void generate_union(t_struct* tunion);
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
void generate_property(ofstream& out, t_field* tfield, bool isPublic, bool generateIsset);
void generate_csharp_property(ofstream& out,
void generate_property(ostream& out, t_field* tfield, bool isPublic, bool generateIsset);
void generate_csharp_property(ostream& out,
t_field* tfield,
bool isPublic,
bool includeIsset = true,
std::string fieldPrefix = "");
bool print_const_value(std::ofstream& out,
bool print_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value,
bool in_static,
bool defval = false,
bool needtype = false);
std::string render_const_value(std::ofstream& out,
std::string render_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value);
void print_const_constructor(std::ofstream& out, std::vector<t_const*> consts);
void print_const_def_value(std::ofstream& out,
void print_const_constructor(std::ostream& out, std::vector<t_const*> consts);
void print_const_def_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value);
void generate_csharp_struct(t_struct* tstruct, bool is_exception);
void generate_csharp_union(t_struct* tunion);
void generate_csharp_struct_definition(std::ofstream& out,
void generate_csharp_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool in_class = false,
bool is_result = false);
void generate_csharp_union_definition(std::ofstream& out, t_struct* tunion);
void generate_csharp_union_class(std::ofstream& out, t_struct* tunion, t_field* tfield);
void generate_csharp_wcffault(std::ofstream& out, t_struct* tstruct);
void generate_csharp_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_csharp_struct_result_writer(std::ofstream& out, t_struct* tstruct);
void generate_csharp_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_csharp_struct_tostring(std::ofstream& out, t_struct* tstruct);
void generate_csharp_struct_equals(std::ofstream& out, t_struct* tstruct);
void generate_csharp_struct_hashcode(std::ofstream& out, t_struct* tstruct);
void generate_csharp_union_reader(std::ofstream& out, t_struct* tunion);
void generate_csharp_union_definition(std::ostream& out, t_struct* tunion);
void generate_csharp_union_class(std::ostream& out, t_struct* tunion, t_field* tfield);
void generate_csharp_wcffault(std::ostream& out, t_struct* tstruct);
void generate_csharp_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_csharp_struct_result_writer(std::ostream& out, t_struct* tstruct);
void generate_csharp_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_csharp_struct_tostring(std::ostream& out, t_struct* tstruct);
void generate_csharp_struct_equals(std::ostream& out, t_struct* tstruct);
void generate_csharp_struct_hashcode(std::ostream& out, t_struct* tstruct);
void generate_csharp_union_reader(std::ostream& out, t_struct* tunion);
void generate_function_helpers(t_function* tfunction);
void generate_service_interface(t_service* tservice);
@ -156,36 +156,36 @@ public:
void generate_process_function(t_service* tservice, t_function* function);
void generate_process_function_async(t_service* tservice, t_function* function);
void generate_deserialize_field(std::ofstream& out,
void generate_deserialize_field(std::ostream& out,
t_field* tfield,
std::string prefix = "",
bool is_propertyless = false);
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out, t_list* list, std::string prefix = "");
void generate_serialize_field(std::ofstream& out,
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ostream& out, t_list* list, std::string prefix = "");
void generate_serialize_field(std::ostream& out,
t_field* tfield,
std::string prefix = "",
bool is_element = false,
bool is_propertyless = false);
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string iter,
std::string map);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
void generate_csharp_doc(std::ofstream& out, t_field* field);
void generate_csharp_doc(std::ofstream& out, t_doc* tdoc);
void generate_csharp_doc(std::ofstream& out, t_function* tdoc);
void generate_csharp_docstring_comment(std::ofstream& out, string contents);
void generate_csharp_doc(std::ostream& out, t_field* field);
void generate_csharp_doc(std::ostream& out, t_doc* tdoc);
void generate_csharp_doc(std::ostream& out, t_function* tdoc);
void generate_csharp_docstring_comment(std::ostream& out, string contents);
void start_csharp_namespace(std::ofstream& out);
void end_csharp_namespace(std::ofstream& out);
void start_csharp_namespace(std::ostream& out);
void end_csharp_namespace(std::ostream& out);
std::string csharp_type_usings();
std::string csharp_thrift_usings();
@ -224,7 +224,7 @@ public:
private:
std::string namespace_name_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_service_;
std::string namespace_dir_;
bool async_;
bool nullable_;
@ -403,14 +403,14 @@ void t_csharp_generator::init_keywords() {
csharp_keywords["yield"] = 1;
}
void t_csharp_generator::start_csharp_namespace(ofstream& out) {
void t_csharp_generator::start_csharp_namespace(ostream& out) {
if (!namespace_name_.empty()) {
out << "namespace " << namespace_name_ << "\n";
scope_up(out);
}
}
void t_csharp_generator::end_csharp_namespace(ofstream& out) {
void t_csharp_generator::end_csharp_namespace(ostream& out) {
if (!namespace_name_.empty()) {
scope_down(out);
}
@ -438,7 +438,7 @@ void t_csharp_generator::generate_typedef(t_typedef* ttypedef) {
void t_csharp_generator::generate_enum(t_enum* tenum) {
string f_enum_name = namespace_dir_ + "/" + (tenum->get_name()) + ".cs";
ofstream f_enum;
ofstream_with_content_based_conditional_update f_enum;
f_enum.open(f_enum_name.c_str());
f_enum << autogen_comment() << endl;
@ -471,7 +471,7 @@ void t_csharp_generator::generate_consts(std::vector<t_const*> consts) {
return;
}
string f_consts_name = namespace_dir_ + '/' + program_name_ + ".Constants.cs";
ofstream f_consts;
ofstream_with_content_based_conditional_update f_consts;
f_consts.open(f_consts_name.c_str());
f_consts << autogen_comment() << csharp_type_usings() << endl;
@ -504,15 +504,15 @@ void t_csharp_generator::generate_consts(std::vector<t_const*> consts) {
f_consts.close();
}
void t_csharp_generator::print_const_def_value(std::ofstream& out,
void t_csharp_generator::print_const_def_value(std::ostream& out,
string name,
t_type* type,
t_const_value* value) {
if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
prepare_member_name_mapping((t_struct*)type);
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_field* field = NULL;
@ -532,8 +532,8 @@ void t_csharp_generator::print_const_def_value(std::ofstream& out,
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
@ -557,7 +557,7 @@ void t_csharp_generator::print_const_def_value(std::ofstream& out,
}
}
void t_csharp_generator::print_const_constructor(std::ofstream& out, std::vector<t_const*> consts) {
void t_csharp_generator::print_const_constructor(std::ostream& out, std::vector<t_const*> consts) {
indent(out) << "static " << make_valid_csharp_identifier(program_name_).c_str() << "Constants()"
<< endl;
scope_up(out);
@ -574,7 +574,7 @@ void t_csharp_generator::print_const_constructor(std::ofstream& out, std::vector
// it seems like all that methods that call this are using in_static to be the opposite of what it
// would imply
bool t_csharp_generator::print_const_value(std::ofstream& out,
bool t_csharp_generator::print_const_value(std::ostream& out,
string name,
t_type* type,
t_const_value* value,
@ -614,7 +614,7 @@ bool t_csharp_generator::print_const_value(std::ofstream& out,
return need_static_construction;
}
std::string t_csharp_generator::render_const_value(ofstream& out,
std::string t_csharp_generator::render_const_value(ostream& out,
string name,
t_type* type,
t_const_value* value) {
@ -671,7 +671,7 @@ void t_csharp_generator::generate_xception(t_struct* txception) {
void t_csharp_generator::generate_csharp_struct(t_struct* tstruct, bool is_exception) {
string f_struct_name = namespace_dir_ + "/" + (tstruct->get_name()) + ".cs";
ofstream f_struct;
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
@ -682,7 +682,7 @@ void t_csharp_generator::generate_csharp_struct(t_struct* tstruct, bool is_excep
f_struct.close();
}
void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
void t_csharp_generator::generate_csharp_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception,
bool in_class,
@ -843,7 +843,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
} else {
out << ", ";
}
out << type_name((*m_iter)->get_type()) << " " << (*m_iter)->get_name();
out << type_name((*m_iter)->get_type()) << " " << normalize_name((*m_iter)->get_name());
}
}
out << ") : this() {" << endl;
@ -851,7 +851,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if (field_is_required((*m_iter))) {
indent(out) << "this." << prop_name((*m_iter)) << " = " << (*m_iter)->get_name() << ";"
indent(out) << "this." << prop_name((*m_iter)) << " = " << normalize_name((*m_iter)->get_name()) << ";"
<< endl;
}
}
@ -885,7 +885,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
}
}
void t_csharp_generator::generate_csharp_wcffault(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_wcffault(ostream& out, t_struct* tstruct) {
out << endl;
indent(out) << "#if !SILVERLIGHT" << endl;
indent(out) << "[Serializable]" << endl;
@ -915,7 +915,7 @@ void t_csharp_generator::generate_csharp_wcffault(ofstream& out, t_struct* tstru
out << endl;
}
void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_struct_reader(ostream& out, t_struct* tstruct) {
indent(out) << "public void Read (TProtocol iprot)" << endl;
scope_up(out);
@ -986,7 +986,10 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
if (field_is_required((*f_iter))) {
indent(out) << "if (!isset_" << (*f_iter)->get_name() << ")" << endl;
indent_up();
indent(out) << "throw new TProtocolException(TProtocolException.INVALID_DATA);" << endl;
out << indent()
<< "throw new TProtocolException(TProtocolException.INVALID_DATA, "
<< "\"required field " << prop_name((*f_iter)) << " not set\");"
<< endl;
indent_down();
}
}
@ -1002,7 +1005,7 @@ void t_csharp_generator::generate_csharp_struct_reader(ofstream& out, t_struct*
indent(out) << "}" << endl << endl;
}
void t_csharp_generator::generate_csharp_struct_writer(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_struct_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public void Write(TProtocol oprot) {" << endl;
indent_up();
@ -1022,20 +1025,36 @@ void t_csharp_generator::generate_csharp_struct_writer(ofstream& out, t_struct*
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool is_required = field_is_required((*f_iter));
bool has_default = field_has_default((*f_iter));
if (nullable_ && !has_default && !is_required) {
indent(out) << "if (" << prop_name((*f_iter)) << " != null) {" << endl;
indent_up();
} else if (!is_required) {
bool null_allowed = type_can_be_null((*f_iter)->get_type());
bool null_allowed = type_can_be_null((*f_iter)->get_type());
if (is_required)
{
if (null_allowed) {
indent(out) << "if (" << prop_name((*f_iter)) << " != null && __isset."
<< normalize_name((*f_iter)->get_name()) << ") {" << endl;
indent_up();
} else {
indent(out) << "if (__isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
indent(out) << "if (" << prop_name((*f_iter)) << " == null)" << endl;
indent_up();
out << indent()
<< "throw new TProtocolException(TProtocolException.INVALID_DATA, "
<< "\"required field " << prop_name((*f_iter)) << " not set\");"
<< endl;
indent_down();
}
}
else
{
if (nullable_ && !has_default) {
indent(out) << "if (" << prop_name((*f_iter)) << " != null) {" << endl;
}
else if (null_allowed) {
out << indent()
<< "if (" << prop_name((*f_iter)) << " != null && __isset."
<< normalize_name((*f_iter)->get_name()) << ") {"
<< endl;
}
else {
indent(out) << "if (__isset." << normalize_name((*f_iter)->get_name()) << ") {" << endl;
}
indent_up();
}
indent(out) << "field.Name = \"" << (*f_iter)->get_name() << "\";" << endl;
indent(out) << "field.Type = " << type_to_enum((*f_iter)->get_type()) << ";" << endl;
indent(out) << "field.ID = " << (*f_iter)->get_key() << ";" << endl;
@ -1065,7 +1084,7 @@ void t_csharp_generator::generate_csharp_struct_writer(ofstream& out, t_struct*
indent(out) << "}" << endl << endl;
}
void t_csharp_generator::generate_csharp_struct_result_writer(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_struct_result_writer(ostream& out, t_struct* tstruct) {
indent(out) << "public void Write(TProtocol oprot) {" << endl;
indent_up();
@ -1137,7 +1156,7 @@ void t_csharp_generator::generate_csharp_struct_result_writer(ofstream& out, t_s
indent(out) << "}" << endl << endl;
}
void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_struct_tostring(ostream& out, t_struct* tstruct) {
indent(out) << "public override string ToString() {" << endl;
indent_up();
@ -1211,7 +1230,7 @@ void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct
void t_csharp_generator::generate_csharp_union(t_struct* tunion) {
string f_union_name = namespace_dir_ + "/" + (tunion->get_name()) + ".cs";
ofstream f_union;
ofstream_with_content_based_conditional_update f_union;
f_union.open(f_union_name.c_str());
@ -1222,7 +1241,7 @@ void t_csharp_generator::generate_csharp_union(t_struct* tunion) {
f_union.close();
}
void t_csharp_generator::generate_csharp_union_definition(std::ofstream& out, t_struct* tunion) {
void t_csharp_generator::generate_csharp_union_definition(std::ostream& out, t_struct* tunion) {
// Let's define the class first
start_csharp_namespace(out);
@ -1273,7 +1292,7 @@ void t_csharp_generator::generate_csharp_union_definition(std::ofstream& out, t_
end_csharp_namespace(out);
}
void t_csharp_generator::generate_csharp_union_class(std::ofstream& out,
void t_csharp_generator::generate_csharp_union_class(std::ostream& out,
t_struct* tunion,
t_field* tfield) {
indent(out) << "public class " << tfield->get_name() << " : " << tunion->get_name() << " {"
@ -1322,7 +1341,7 @@ void t_csharp_generator::generate_csharp_union_class(std::ofstream& out,
indent(out) << "}" << endl << endl;
}
void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_struct_equals(ostream& out, t_struct* tstruct) {
indent(out) << "public override bool Equals(object that) {" << endl;
indent_up();
@ -1350,7 +1369,7 @@ void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct*
<< normalize_name((*f_iter)->get_name()) << ") || (";
}
t_type* ttype = (*f_iter)->get_type();
if (ttype->is_container() || (ttype->is_base_type() && (((t_base_type*)ttype)->is_binary()))) {
if (ttype->is_container() || ttype->is_binary()) {
out << "TCollections.Equals(";
} else {
out << "System.Object.Equals(";
@ -1371,7 +1390,7 @@ void t_csharp_generator::generate_csharp_struct_equals(ofstream& out, t_struct*
indent(out) << "}" << endl << endl;
}
void t_csharp_generator::generate_csharp_struct_hashcode(ofstream& out, t_struct* tstruct) {
void t_csharp_generator::generate_csharp_struct_hashcode(ostream& out, t_struct* tstruct) {
indent(out) << "public override int GetHashCode() {" << endl;
indent_up();
@ -1671,6 +1690,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
if (!async_) {
indent(f_service_) << "#if SILVERLIGHT" << endl;
indent(f_service_) << endl;
}
// Begin_
indent(f_service_) << "public " << function_signature_async_begin(*f_iter, "Begin_") << endl;
@ -1747,51 +1767,52 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
indent(f_service_) << "#endif" << endl << endl;
}
// "Normal" Synchronous invoke
generate_csharp_doc(f_service_, *f_iter);
indent(f_service_) << "public " << function_signature(*f_iter) << endl;
scope_up(f_service_);
// silverlight invoke
if (!async_) {
indent(f_service_) << "#if !SILVERLIGHT" << endl;
indent(f_service_) << "send_" << funname << "(";
indent(f_service_) << "#if SILVERLIGHT" << endl;
first = true;
indent(f_service_) << "var asyncResult = Begin_" << funname << "(null, null";
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
if (first) {
first = false;
} else {
f_service_ << ", ";
}
f_service_ << normalize_name((*fld_iter)->get_name());
f_service_ << ", " << normalize_name((*fld_iter)->get_name());
}
f_service_ << ");" << endl;
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
f_service_ << "recv_" << funname << "();" << endl;
f_service_ << "End_" << funname << "(asyncResult);" << endl;
}
f_service_ << endl;
indent(f_service_) << "#else" << endl;
}
// Silverlight synchronous invoke
indent(f_service_) << "var asyncResult = Begin_" << funname << "(null, null";
// synchronous invoke
indent(f_service_) << "send_" << funname << "(";
first = true;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << ", " << normalize_name((*fld_iter)->get_name());
if (first) {
first = false;
} else {
f_service_ << ", ";
}
f_service_ << normalize_name((*fld_iter)->get_name());
}
f_service_ << ");" << endl;
if (!(*f_iter)->is_oneway()) {
f_service_ << indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
f_service_ << "End_" << funname << "(asyncResult);" << endl;
f_service_ << "recv_" << funname << "();" << endl;
}
f_service_ << endl;
@ -1810,12 +1831,8 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
if (!async_) {
indent(f_service_) << "#if SILVERLIGHT" << endl;
}
indent(f_service_) << "public " << function_signature_async_begin(&send_function) << endl;
if (!async_) {
indent(f_service_) << "#else" << endl;
indent(f_service_) << "public " << function_signature(&send_function) << endl;
indent(f_service_) << "#endif" << endl;
}
scope_up(f_service_);
f_service_ << indent() << "oprot_.WriteMessageBegin(new TMessage(\"" << funname << "\", "
@ -1830,20 +1847,40 @@ void t_csharp_generator::generate_service_client(t_service* tservice) {
f_service_ << indent() << "args.Write(oprot_);" << endl << indent()
<< "oprot_.WriteMessageEnd();" << endl;
;
indent(f_service_) << "return oprot_.Transport.BeginFlush(callback, state);" << endl;
scope_down(f_service_);
f_service_ << endl;
if (!async_) {
indent(f_service_) << "#if SILVERLIGHT" << endl;
}
indent(f_service_) << "return oprot_.Transport.BeginFlush(callback, state);" << endl;
if (!async_) {
indent(f_service_) << "#else" << endl;
indent(f_service_) << "oprot_.Transport.Flush();" << endl;
f_service_ << endl;
}
indent(f_service_) << "public " << function_signature(&send_function) << endl;
scope_up(f_service_);
f_service_ << indent() << "oprot_.WriteMessageBegin(new TMessage(\"" << funname << "\", "
<< ((*f_iter)->is_oneway() ? "TMessageType.Oneway" : "TMessageType.Call")
<< ", seqid_));" << endl << indent() << argsname << " args = new " << argsname
<< "();" << endl;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "args." << prop_name(*fld_iter) << " = "
<< normalize_name((*fld_iter)->get_name()) << ";" << endl;
}
f_service_ << indent() << "args.Write(oprot_);" << endl << indent()
<< "oprot_.WriteMessageEnd();" << endl;
indent(f_service_) << "oprot_.Transport.Flush();" << endl;
cleanup_member_name_mapping(arg_struct);
scope_down(f_service_);
if (!async_) {
indent(f_service_) << "#endif" << endl;
}
cleanup_member_name_mapping(arg_struct);
scope_down(f_service_);
f_service_ << endl;
if (!(*f_iter)->is_oneway()) {
@ -2030,7 +2067,7 @@ void t_csharp_generator::generate_service_server_async(t_service* tservice) {
string extends_processor = "";
if (tservice->get_extends() != NULL) {
extends = type_name(tservice->get_extends());
extends_processor = extends + ".Processor, ";
extends_processor = extends + ".AsyncProcessor, ";
}
indent(f_service_) << "public class AsyncProcessor : " << extends_processor << "TAsyncProcessor {" << endl;
@ -2359,7 +2396,7 @@ void t_csharp_generator::generate_process_function_async(t_service* tservice, t_
f_service_ << endl;
}
void t_csharp_generator::generate_csharp_union_reader(std::ofstream& out, t_struct* tunion) {
void t_csharp_generator::generate_csharp_union_reader(std::ostream& out, t_struct* tunion) {
// Thanks to THRIFT-1768, we don't need to check for required fields in the union
const vector<t_field*>& fields = tunion->get_members();
vector<t_field*>::const_iterator f_iter;
@ -2433,7 +2470,7 @@ void t_csharp_generator::generate_csharp_union_reader(std::ofstream& out, t_stru
indent(out) << "}" << endl << endl;
}
void t_csharp_generator::generate_deserialize_field(ofstream& out,
void t_csharp_generator::generate_deserialize_field(ostream& out,
t_field* tfield,
string prefix,
bool is_propertyless) {
@ -2468,7 +2505,7 @@ void t_csharp_generator::generate_deserialize_field(ofstream& out,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "ReadBinary();";
} else {
out << "ReadString();";
@ -2506,7 +2543,7 @@ void t_csharp_generator::generate_deserialize_field(ofstream& out,
}
}
void t_csharp_generator::generate_deserialize_struct(ofstream& out,
void t_csharp_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
if (union_ && tstruct->is_union()) {
@ -2517,7 +2554,7 @@ void t_csharp_generator::generate_deserialize_struct(ofstream& out,
}
}
void t_csharp_generator::generate_deserialize_container(ofstream& out,
void t_csharp_generator::generate_deserialize_container(ostream& out,
t_type* ttype,
string prefix) {
scope_up(out);
@ -2568,7 +2605,7 @@ void t_csharp_generator::generate_deserialize_container(ofstream& out,
scope_down(out);
}
void t_csharp_generator::generate_deserialize_map_element(ofstream& out,
void t_csharp_generator::generate_deserialize_map_element(ostream& out,
t_map* tmap,
string prefix) {
string key = tmp("_key");
@ -2586,7 +2623,7 @@ void t_csharp_generator::generate_deserialize_map_element(ofstream& out,
indent(out) << prefix << "[" << key << "] = " << val << ";" << endl;
}
void t_csharp_generator::generate_deserialize_set_element(ofstream& out,
void t_csharp_generator::generate_deserialize_set_element(ostream& out,
t_set* tset,
string prefix) {
string elem = tmp("_elem");
@ -2599,7 +2636,7 @@ void t_csharp_generator::generate_deserialize_set_element(ofstream& out,
indent(out) << prefix << ".Add(" << elem << ");" << endl;
}
void t_csharp_generator::generate_deserialize_list_element(ofstream& out,
void t_csharp_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
string elem = tmp("_elem");
@ -2612,7 +2649,7 @@ void t_csharp_generator::generate_deserialize_list_element(ofstream& out,
indent(out) << prefix << ".Add(" << elem << ");" << endl;
}
void t_csharp_generator::generate_serialize_field(ofstream& out,
void t_csharp_generator::generate_serialize_field(ostream& out,
t_field* tfield,
string prefix,
bool is_element,
@ -2645,7 +2682,7 @@ void t_csharp_generator::generate_serialize_field(ofstream& out,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "WriteBinary(";
} else {
out << "WriteString(";
@ -2685,14 +2722,14 @@ void t_csharp_generator::generate_serialize_field(ofstream& out,
}
}
void t_csharp_generator::generate_serialize_struct(ofstream& out,
void t_csharp_generator::generate_serialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
(void)tstruct;
out << indent() << prefix << ".Write(oprot);" << endl;
}
void t_csharp_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_csharp_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
if (ttype->is_map()) {
@ -2744,7 +2781,7 @@ void t_csharp_generator::generate_serialize_container(ofstream& out, t_type* tty
scope_down(out);
}
void t_csharp_generator::generate_serialize_map_element(ofstream& out,
void t_csharp_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string iter,
string map) {
@ -2754,25 +2791,25 @@ void t_csharp_generator::generate_serialize_map_element(ofstream& out,
generate_serialize_field(out, &vfield, "", true);
}
void t_csharp_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_csharp_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield, "", true);
}
void t_csharp_generator::generate_serialize_list_element(ofstream& out,
void t_csharp_generator::generate_serialize_list_element(ostream& out,
t_list* tlist,
string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield, "", true);
}
void t_csharp_generator::generate_property(ofstream& out,
void t_csharp_generator::generate_property(ostream& out,
t_field* tfield,
bool isPublic,
bool generateIsset) {
generate_csharp_property(out, tfield, isPublic, generateIsset, "_");
}
void t_csharp_generator::generate_csharp_property(ofstream& out,
void t_csharp_generator::generate_csharp_property(ostream& out,
t_field* tfield,
bool isPublic,
bool generateIsset,
@ -2801,6 +2838,8 @@ void t_csharp_generator::generate_csharp_property(ofstream& out,
}
if (ttype->is_base_type()) {
use_nullable = ((t_base_type*)ttype)->get_base() != t_base_type::TYPE_STRING;
} else if (ttype->is_enum()) {
use_nullable = true;
}
}
indent(out) << "return " << fieldPrefix + tfield->get_name() << ";" << endl;
@ -2888,6 +2927,7 @@ void t_csharp_generator::prepare_member_name_mapping(void* scope,
const string& structname) {
// begin new scope
member_mapping_scope dummy;
dummy.scope_member = 0;
member_mapping_scopes.push_back(dummy);
member_mapping_scope& active = member_mapping_scopes.back();
active.scope_member = scope;
@ -3018,7 +3058,7 @@ string t_csharp_generator::declare_field(t_field* tfield, bool init, std::string
ttype = ((t_typedef*)ttype)->get_type();
}
if (ttype->is_base_type() && field_has_default(tfield)) {
ofstream dummy;
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
@ -3136,11 +3176,11 @@ string t_csharp_generator::type_to_enum(t_type* type) {
throw "INVALID TYPE IN type_to_enum: " + type->get_name();
}
void t_csharp_generator::generate_csharp_docstring_comment(ofstream& out, string contents) {
void t_csharp_generator::generate_csharp_docstring_comment(ostream& out, string contents) {
generate_docstring_comment(out, "/// <summary>\n", "/// ", contents, "/// </summary>\n");
}
void t_csharp_generator::generate_csharp_doc(ofstream& out, t_field* field) {
void t_csharp_generator::generate_csharp_doc(ostream& out, t_field* field) {
if (field->get_type()->is_enum()) {
string combined_message = field->get_doc() + "\n<seealso cref=\""
+ get_enum_class_name(field->get_type()) + "\"/>";
@ -3150,13 +3190,13 @@ void t_csharp_generator::generate_csharp_doc(ofstream& out, t_field* field) {
}
}
void t_csharp_generator::generate_csharp_doc(ofstream& out, t_doc* tdoc) {
void t_csharp_generator::generate_csharp_doc(ostream& out, t_doc* tdoc) {
if (tdoc->has_doc()) {
generate_csharp_docstring_comment(out, tdoc->get_doc());
}
}
void t_csharp_generator::generate_csharp_doc(ofstream& out, t_function* tfunction) {
void t_csharp_generator::generate_csharp_doc(ostream& out, t_function* tfunction) {
if (tfunction->has_doc()) {
stringstream ps;
const vector<t_field*>& fields = tfunction->get_arglist()->get_members();

View file

@ -103,7 +103,7 @@ protected:
// Include type modules from other imported programs.
const vector<t_program*>& includes = program_->get_includes();
for (size_t i = 0; i < includes.size(); ++i) {
f_types_ << "import " << render_package(*(includes[i])) << includes[i]->get_name()
f_types_ << "public import " << render_package(*(includes[i])) << includes[i]->get_name()
<< "_types;" << endl;
}
if (!includes.empty())
@ -118,7 +118,7 @@ protected:
virtual void generate_consts(std::vector<t_const*> consts) {
if (!consts.empty()) {
string f_consts_name = package_dir_ + program_name_ + "_constants.d";
ofstream f_consts;
ofstream_with_content_based_conditional_update f_consts;
f_consts.open(f_consts_name.c_str());
f_consts << autogen_comment() << "module " << render_package(*program_) << program_name_
@ -131,6 +131,7 @@ protected:
vector<t_const*>::iterator c_iter;
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
this->emit_doc(*c_iter, f_consts);
string name = (*c_iter)->get_name();
t_type* type = (*c_iter)->get_type();
indent(f_consts) << "immutable(" << render_type_name(type) << ") " << name << ";" << endl;
@ -159,6 +160,7 @@ protected:
}
virtual void generate_typedef(t_typedef* ttypedef) {
this->emit_doc(ttypedef, f_types_);
f_types_ << indent() << "alias " << render_type_name(ttypedef->get_type()) << " "
<< ttypedef->get_symbolic() << ";" << endl << endl;
}
@ -166,21 +168,17 @@ protected:
virtual void generate_enum(t_enum* tenum) {
vector<t_enum_value*> constants = tenum->get_constants();
this->emit_doc(tenum, f_types_);
string enum_name = tenum->get_name();
f_types_ << indent() << "enum " << enum_name << " {" << endl;
indent_up();
vector<t_enum_value*>::const_iterator c_iter;
bool first = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
if (first) {
first = false;
} else {
f_types_ << "," << endl;
}
this->emit_doc(*c_iter, f_types_);
indent(f_types_) << (*c_iter)->get_name();
f_types_ << " = " << (*c_iter)->get_value();
f_types_ << " = " << (*c_iter)->get_value() << ",";
}
f_types_ << endl;
@ -203,7 +201,7 @@ protected:
// Service implementation file includes
string f_servicename = package_dir_ + svc_name + ".d";
std::ofstream f_service;
ofstream_with_content_based_conditional_update f_service;
f_service.open(f_servicename.c_str());
f_service << autogen_comment() << "module " << render_package(*program_) << svc_name << ";"
<< endl << endl;
@ -225,6 +223,7 @@ protected:
extends = " : " + render_type_name(tservice->get_extends());
}
this->emit_doc(tservice, f_service);
f_service << indent() << "interface " << svc_name << extends << " {" << endl;
indent_up();
@ -236,6 +235,7 @@ protected:
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator fn_iter;
for (fn_iter = functions.begin(); fn_iter != functions.end(); ++fn_iter) {
this->emit_doc(*fn_iter, f_service);
f_service << indent();
print_function_signature(f_service, *fn_iter);
f_service << ";" << endl;
@ -339,12 +339,26 @@ protected:
// Server skeleton generation.
string f_skeletonname = package_dir_ + svc_name + "_server.skeleton.d";
std::ofstream f_skeleton;
ofstream_with_content_based_conditional_update f_skeleton;
f_skeleton.open(f_skeletonname.c_str());
print_server_skeleton(f_skeleton, tservice);
f_skeleton.close();
}
void emit_doc(t_doc *doc, std::ostream& out) {
if (!doc->has_doc()) {
return;
}
indent(out) << "/**" << std::endl;
indent_up();
// No endl -- comments reliably have a newline at the end.
// This is true even for stuff like:
// /** method infos */ void foo(/** huh?*/ 1: i64 stuff)
indent(out) << doc->get_doc();
indent_down();
indent(out) << "*/" << std::endl;
}
private:
/**
* Writes a server skeleton for the passed service to out.
@ -381,8 +395,8 @@ private:
out << indent() << "// Your implementation goes here." << endl << indent() << "writeln(\""
<< (*f_iter)->get_name() << " called\");" << endl;
t_base_type* rt = (t_base_type*)(*f_iter)->get_returntype();
if (rt->get_base() != t_base_type::TYPE_VOID) {
t_type* rt = (*f_iter)->get_returntype();
if (!rt->is_void()) {
indent(out) << "return typeof(return).init;" << endl;
}
@ -543,8 +557,8 @@ private:
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -562,8 +576,8 @@ private:
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(ktype, v_iter->first);
string val = render_const_value(vtype, v_iter->second);
@ -719,8 +733,8 @@ private:
* File streams, stored here to avoid passing them as parameters to every
* function.
*/
ofstream f_types_;
ofstream f_header_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_header_;
string package_dir_;
};

View file

@ -31,7 +31,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -141,13 +141,13 @@ public:
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
void print_const_value(std::ofstream& out,
void print_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value,
bool in_static,
bool defval = false);
std::string render_const_value(ofstream& out,
std::string render_const_value(ostream& out,
std::string name,
t_type* type,
t_const_value* value);
@ -158,21 +158,21 @@ public:
void generate_dart_struct(t_struct* tstruct, bool is_exception);
void generate_dart_struct_definition(std::ofstream& out,
void generate_dart_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool is_result = false,
string export_file_name = "");
void generate_dart_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_dart_validator(std::ofstream& out, t_struct* tstruct);
void generate_dart_struct_result_writer(std::ofstream& out, t_struct* tstruct);
void generate_dart_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_dart_struct_tostring(std::ofstream& out, t_struct* tstruct);
void generate_dart_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_dart_validator(std::ostream& out, t_struct* tstruct);
void generate_dart_struct_result_writer(std::ostream& out, t_struct* tstruct);
void generate_dart_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_dart_struct_tostring(std::ostream& out, t_struct* tstruct);
std::string get_dart_type_string(t_type* type);
void generate_generic_field_getters(std::ofstream& out, t_struct* tstruct);
void generate_generic_field_setters(std::ofstream& out, t_struct* tstruct);
void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
void generate_dart_bean_boilerplate(std::ofstream& out, t_struct* tstruct);
void generate_generic_field_getters(std::ostream& out, t_struct* tstruct);
void generate_generic_field_setters(std::ostream& out, t_struct* tstruct);
void generate_generic_isset_method(std::ostream& out, t_struct* tstruct);
void generate_dart_bean_boilerplate(std::ostream& out, t_struct* tstruct);
void generate_function_helpers(t_function* tfunction);
std::string init_value(t_field* tfield);
@ -184,7 +184,7 @@ public:
std::string get_constants_class_name(std::string name);
std::string generate_isset_check(t_field* field);
std::string generate_isset_check(std::string field);
void generate_isset_set(ofstream& out, t_field* field);
void generate_isset_set(ostream& out, t_field* field);
void generate_service_interface(t_service* tservice);
void generate_service_helpers(t_service* tservice);
@ -196,38 +196,38 @@ public:
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string iter,
std::string map);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
void generate_dart_doc(std::ofstream& out, t_doc* tdoc);
void generate_dart_doc(std::ostream& out, t_doc* tdoc);
void generate_dart_doc(std::ofstream& out, t_function* tdoc);
void generate_dart_doc(std::ostream& out, t_function* tdoc);
/**
* Helper rendering functions
@ -265,7 +265,7 @@ public:
std::string constant_name(std::string name);
private:
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_service_;
std::string library_name_;
std::string library_prefix_;
@ -391,7 +391,7 @@ void t_dart_generator::generate_dart_library() {
f_library_name = get_out_dir() + "/" + library_name_ + ".dart";
}
ofstream f_library;
ofstream_with_content_based_conditional_update f_library;
f_library.open(f_library_name.c_str());
f_library << autogen_comment() << endl;
@ -413,7 +413,7 @@ void t_dart_generator::export_class_to_library(string file_name, string class_na
void t_dart_generator::generate_dart_pubspec() {
string f_pubspec_name = base_dir_ + "/pubspec.yaml";
ofstream f_pubspec;
ofstream_with_content_based_conditional_update f_pubspec;
f_pubspec.open(f_pubspec_name.c_str());
indent(f_pubspec) << "name: " << library_name_ << endl;
@ -478,7 +478,7 @@ void t_dart_generator::generate_enum(t_enum* tenum) {
string file_name = get_file_name(tenum->get_name());
string f_enum_name = src_dir_ + "/" + file_name + ".dart";
ofstream f_enum;
ofstream_with_content_based_conditional_update f_enum;
f_enum.open(f_enum_name.c_str());
// Comment and add library
@ -540,7 +540,7 @@ void t_dart_generator::generate_consts(std::vector<t_const*> consts) {
string file_name = get_file_name(class_name);
string f_consts_name = src_dir_ + "/" + file_name + ".dart";
ofstream f_consts;
ofstream_with_content_based_conditional_update f_consts;
f_consts.open(f_consts_name.c_str());
// Print header
@ -566,7 +566,7 @@ void t_dart_generator::generate_consts(std::vector<t_const*> consts) {
f_consts.close();
}
void t_dart_generator::print_const_value(std::ofstream& out,
void t_dart_generator::print_const_value(std::ostream& out,
string name,
t_type* type,
t_const_value* value,
@ -594,8 +594,8 @@ void t_dart_generator::print_const_value(std::ofstream& out,
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
out << type_name(type) << " " << name << " = new " << type_name(type) << "()";
indent_up();
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
@ -623,8 +623,8 @@ void t_dart_generator::print_const_value(std::ofstream& out,
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
@ -668,7 +668,7 @@ void t_dart_generator::print_const_value(std::ofstream& out,
}
}
string t_dart_generator::render_const_value(ofstream& out,
string t_dart_generator::render_const_value(ostream& out,
string name,
t_type* type,
t_const_value* value) {
@ -740,7 +740,7 @@ void t_dart_generator::generate_xception(t_struct* txception) {
void t_dart_generator::generate_dart_struct(t_struct* tstruct, bool is_exception) {
string file_name = get_file_name(tstruct->get_name());
string f_struct_name = src_dir_ + "/" + file_name + ".dart";
ofstream f_struct;
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
f_struct << autogen_comment() << dart_library(file_name) << endl;
@ -764,7 +764,7 @@ void t_dart_generator::generate_dart_struct(t_struct* tstruct, bool is_exception
* @param in_class If inside a class, needs to be static class
* @param is_result If this is a result it needs a different writer
*/
void t_dart_generator::generate_dart_struct_definition(ofstream& out,
void t_dart_generator::generate_dart_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception,
bool is_result,
@ -777,10 +777,10 @@ void t_dart_generator::generate_dart_struct_definition(ofstream& out,
}
indent(out) << "class " << class_name << " ";
if (is_exception) {
out << "extends Error ";
}
out << "implements TBase";
if (is_exception) {
out << ", Exception ";
}
scope_up(out);
indent(out) << "static final TStruct _STRUCT_DESC = new TStruct(\"" << class_name
@ -861,7 +861,7 @@ void t_dart_generator::generate_dart_struct_definition(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_dart_generator::generate_dart_struct_reader(ofstream& out, t_struct* tstruct) {
void t_dart_generator::generate_dart_struct_reader(ostream& out, t_struct* tstruct) {
indent(out) << "read(TProtocol iprot)";
scope_up(out);
@ -949,7 +949,7 @@ void t_dart_generator::generate_dart_struct_reader(ofstream& out, t_struct* tstr
// generates dart method to perform various checks
// (e.g. check that all required fields are set)
void t_dart_generator::generate_dart_validator(ofstream& out, t_struct* tstruct) {
void t_dart_generator::generate_dart_validator(ostream& out, t_struct* tstruct) {
indent(out) << "validate()";
scope_up(out);
@ -1000,7 +1000,7 @@ void t_dart_generator::generate_dart_validator(ofstream& out, t_struct* tstruct)
*
* @param tstruct The struct definition
*/
void t_dart_generator::generate_dart_struct_writer(ofstream& out, t_struct* tstruct) {
void t_dart_generator::generate_dart_struct_writer(ostream& out, t_struct* tstruct) {
out << indent() << "write(TProtocol oprot)";
scope_up(out);
@ -1056,7 +1056,7 @@ void t_dart_generator::generate_dart_struct_writer(ofstream& out, t_struct* tstr
*
* @param tstruct The struct definition
*/
void t_dart_generator::generate_dart_struct_result_writer(ofstream& out, t_struct* tstruct) {
void t_dart_generator::generate_dart_struct_result_writer(ostream& out, t_struct* tstruct) {
indent(out) << "write(TProtocol oprot)";
scope_up(out);
@ -1097,7 +1097,7 @@ void t_dart_generator::generate_dart_struct_result_writer(ofstream& out, t_struc
scope_down(out, endl2);
}
void t_dart_generator::generate_generic_field_getters(std::ofstream& out,
void t_dart_generator::generate_generic_field_getters(std::ostream& out,
t_struct* tstruct) {
// create the getter
indent(out) << "getFieldValue(int fieldID)";
@ -1127,7 +1127,7 @@ void t_dart_generator::generate_generic_field_getters(std::ofstream& out,
scope_down(out, endl2); // method
}
void t_dart_generator::generate_generic_field_setters(std::ofstream& out,
void t_dart_generator::generate_generic_field_setters(std::ostream& out,
t_struct* tstruct) {
// create the setter
@ -1172,7 +1172,7 @@ void t_dart_generator::generate_generic_field_setters(std::ofstream& out,
}
// Creates a generic isSet method that takes the field number as argument
void t_dart_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct) {
void t_dart_generator::generate_generic_isset_method(std::ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -1208,7 +1208,7 @@ void t_dart_generator::generate_generic_isset_method(std::ofstream& out, t_struc
*
* @param tstruct The struct definition
*/
void t_dart_generator::generate_dart_bean_boilerplate(ofstream& out,
void t_dart_generator::generate_dart_bean_boilerplate(ostream& out,
t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -1257,7 +1257,7 @@ void t_dart_generator::generate_dart_bean_boilerplate(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_dart_generator::generate_dart_struct_tostring(ofstream& out,
void t_dart_generator::generate_dart_struct_tostring(ostream& out,
t_struct* tstruct) {
indent(out) << "String toString()";
scope_up(out);
@ -1292,7 +1292,7 @@ void t_dart_generator::generate_dart_struct_tostring(ofstream& out,
scope_up(out);
}
if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
if (field->get_type()->is_binary()) {
indent(out) << "ret.write(\"BINARY\");" << endl;
} else if (field->get_type()->is_enum()) {
indent(out) << "String " << field_name << "_name = "
@ -1784,7 +1784,7 @@ void t_dart_generator::generate_process_function(t_service* tservice, t_function
* @param tfield The field
* @param prefix The variable name or container for this field
*/
void t_dart_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_dart_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
string field_name = get_member_name(tfield->get_name());
@ -1809,7 +1809,7 @@ void t_dart_generator::generate_deserialize_field(ofstream& out, t_field* tfield
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "readBinary();";
} else {
out << "readString();";
@ -1850,7 +1850,7 @@ void t_dart_generator::generate_deserialize_field(ofstream& out, t_field* tfield
/**
* Generates an unserializer for a struct, invokes read()
*/
void t_dart_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_dart_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix) {
indent(out) << prefix << " = new " << type_name(tstruct) << "();" << endl;
indent(out) << prefix << ".read(iprot);" << endl;
}
@ -1858,7 +1858,7 @@ void t_dart_generator::generate_deserialize_struct(ofstream& out, t_struct* tstr
/**
* Deserializes a container by reading its size and then iterating
*/
void t_dart_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_dart_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
indent(out);
scope_up(out, "");
@ -1915,7 +1915,7 @@ void t_dart_generator::generate_deserialize_container(ofstream& out, t_type* tty
/**
* Generates code to deserialize a map
*/
void t_dart_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
void t_dart_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) {
string key = tmp("_key");
string val = tmp("_val");
t_field fkey(tmap->get_key_type(), key);
@ -1933,7 +1933,7 @@ void t_dart_generator::generate_deserialize_map_element(ofstream& out, t_map* tm
/**
* Deserializes a set element
*/
void t_dart_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
void t_dart_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
@ -1947,7 +1947,7 @@ void t_dart_generator::generate_deserialize_set_element(ofstream& out, t_set* ts
/**
* Deserializes a list element
*/
void t_dart_generator::generate_deserialize_list_element(ofstream& out,
void t_dart_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
string elem = tmp("_elem");
@ -1966,7 +1966,7 @@ void t_dart_generator::generate_deserialize_list_element(ofstream& out,
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_dart_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_dart_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
string field_name = get_member_name(tfield->get_name());
@ -1991,7 +1991,7 @@ void t_dart_generator::generate_serialize_field(ofstream& out, t_field* tfield,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "writeBinary(" << name << ");";
} else {
out << "writeString(" << name << ");";
@ -2036,7 +2036,7 @@ void t_dart_generator::generate_serialize_field(ofstream& out, t_field* tfield,
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_dart_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_dart_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
indent(out) << prefix << ".write(oprot);" << endl;
}
@ -2047,7 +2047,7 @@ void t_dart_generator::generate_serialize_struct(ofstream& out, t_struct* tstruc
* @param ttype The type of container
* @param prefix String prefix for fields
*/
void t_dart_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_dart_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
indent(out);
scope_up(out, "");
@ -2098,7 +2098,7 @@ void t_dart_generator::generate_serialize_container(ofstream& out, t_type* ttype
/**
* Serializes the members of a map.
*/
void t_dart_generator::generate_serialize_map_element(ofstream& out,
void t_dart_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string iter,
string map) {
@ -2111,7 +2111,7 @@ void t_dart_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_dart_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_dart_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2119,7 +2119,7 @@ void t_dart_generator::generate_serialize_set_element(ofstream& out, t_set* tset
/**
* Serializes the members of a list.
*/
void t_dart_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
void t_dart_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2194,7 +2194,7 @@ string t_dart_generator::declare_field(t_field* tfield, bool init) {
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
if (ttype->is_base_type() && tfield->get_value() != NULL) {
ofstream dummy;
std:: ofstream dummy;
result += " = " + render_const_value(dummy, field_name, ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
@ -2452,7 +2452,7 @@ string t_dart_generator::constant_name(string name) {
/**
* Emits a doc comment if the provided object has a doc in Thrift
*/
void t_dart_generator::generate_dart_doc(ofstream& out, t_doc* tdoc) {
void t_dart_generator::generate_dart_doc(ostream& out, t_doc* tdoc) {
if (tdoc->has_doc()) {
generate_docstring_comment(out, "", "/// ", tdoc->get_doc(), "");
}
@ -2461,7 +2461,7 @@ void t_dart_generator::generate_dart_doc(ofstream& out, t_doc* tdoc) {
/**
* Emits a doc comment if the provided function object has a doc in Thrift
*/
void t_dart_generator::generate_dart_doc(ofstream& out, t_function* tfunction) {
void t_dart_generator::generate_dart_doc(ostream& out, t_function* tfunction) {
if (tfunction->has_doc()) {
stringstream ss;
ss << tfunction->get_doc();
@ -2488,7 +2488,7 @@ std::string t_dart_generator::generate_isset_check(std::string field_name) {
return "is" + get_cap_name("set") + get_cap_name(field_name) + "()";
}
void t_dart_generator::generate_isset_set(ofstream& out, t_field* field) {
void t_dart_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
string field_name = get_member_name(field->get_name());
indent(out) << "this.__isset_" << field_name << " = true;" << endl;

View file

@ -65,6 +65,7 @@ public:
constprefix_ = false;
events_ = false;
xmldoc_ = false;
async_ = false;
for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
if( iter->first.compare("ansistr_binary") == 0) {
ansistr_binary_ = true;
@ -76,6 +77,8 @@ public:
events_ = true;
} else if( iter->first.compare("xmldoc") == 0) {
xmldoc_ = true;
} else if( iter->first.compare("async") == 0) {
async_ = true;
} else {
throw "unknown option delphi:" + iter->first;
}
@ -128,7 +131,7 @@ public:
bool is_xception_class,
bool is_union,
bool is_xception_factory,
std::string xception_factroy_name);
std::string xception_factory_name);
void generate_delphi_clear_union_value(ostream& out,
std::string cls_prefix,
std::string name,
@ -138,7 +141,7 @@ public:
bool is_xception_class,
bool is_union,
bool is_xception_factory,
std::string xception_factroy_name);
std::string xception_factory_name);
void generate_delphi_isset_reader_impl(ostream& out,
std::string cls_prefix,
std::string name,
@ -236,6 +239,7 @@ public:
void generate_function_helpers(t_function* tfunction);
void generate_service_interface(t_service* tservice);
void generate_service_interface(t_service* tservice, bool for_async);
void generate_service_helpers(t_service* tservice);
void generate_service_client(t_service* tservice);
void generate_service_server(t_service* tservice);
@ -323,6 +327,7 @@ public:
std::string prefix = "",
bool is_xception_class = false);
std::string function_signature(t_function* tfunction,
bool for_async,
std::string full_cls = "",
bool is_xception = false);
std::string argument_list(t_struct* tstruct);
@ -399,6 +404,7 @@ private:
bool constprefix_;
bool events_;
bool xmldoc_;
bool async_;
void indent_up_impl() { ++indent_impl_; };
void indent_down_impl() { --indent_impl_; };
std::string indent_impl() {
@ -636,10 +642,21 @@ void t_delphi_generator::create_keywords() {
// reserved/predefined variables and types (lowercase!)
delphi_keywords["result"] = 1;
delphi_keywords["system"] = 1;
delphi_keywords["sysutils"] = 1;
delphi_keywords["thrift"] = 1;
delphi_keywords["tbytes"] = 1;
delphi_keywords["tobject"] = 1;
delphi_keywords["tclass"] = 1;
delphi_keywords["tinterfacedobject"] = 1;
delphi_keywords["ansistring"] = 1;
delphi_keywords["string"] = 1;
delphi_keywords["boolean"] = 1;
delphi_keywords["shortint"] = 1;
delphi_keywords["smallint"] = 1;
delphi_keywords["integer"] = 1;
delphi_keywords["int64"] = 1;
delphi_keywords["double"] = 1;
delphi_reserved_method["create"] = 1;
delphi_reserved_method["free"] = 1;
@ -721,15 +738,19 @@ void t_delphi_generator::init_generator() {
has_enum = false;
has_const = false;
create_keywords();
add_delphi_uses_list("Classes");
add_delphi_uses_list("SysUtils");
add_delphi_uses_list("Generics.Collections");
if(async_) {
add_delphi_uses_list("System.Threading");
}
add_delphi_uses_list("Thrift");
add_delphi_uses_list("Thrift.Utils");
add_delphi_uses_list("Thrift.Collections");
add_delphi_uses_list("Thrift.Protocol");
add_delphi_uses_list("Thrift.Transport");
if (register_types_) {
add_delphi_uses_list("Thrift.TypeRegistry");
}
@ -742,7 +763,7 @@ void t_delphi_generator::init_generator() {
unitname = includes[i]->get_name();
nsname = includes[i]->get_namespace("delphi");
if ("" != nsname) {
unitname = nsname;
unitname = normalize_name(nsname);
}
add_delphi_uses_list(unitname);
}
@ -762,8 +783,10 @@ void t_delphi_generator::close_generator() {
}
}
unitname = normalize_name(unitname);
std::string f_name = get_out_dir() + "/" + unitname + ".pas";
std::ofstream f_all;
ofstream_with_content_based_conditional_update f_all;
f_all.open(f_name.c_str());
@ -1195,8 +1218,8 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars,
if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -1215,8 +1238,8 @@ void t_delphi_generator::print_const_def_value(std::ostream& vars,
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(vars, out, name, ktype, v_iter->first);
string val = render_const_value(vars, out, name, vtype, v_iter->second);
@ -1460,8 +1483,6 @@ void t_delphi_generator::generate_delphi_struct_impl(ostream& out,
indent_up_impl();
if (is_exception && (!is_x_factory)) {
indent_impl(out) << "inherited Create('');" << endl;
indent_impl(out) << "F" << exception_factory_name << " := T" << exception_factory_name
<< "Impl.Create;" << endl;
} else {
indent_impl(out) << "inherited;" << endl;
}
@ -1507,6 +1528,19 @@ void t_delphi_generator::generate_delphi_struct_impl(ostream& out,
indent_down_impl();
indent_impl(out) << "end;" << endl << endl;
if (is_exception && (!is_x_factory)) {
indent_impl(out) << "function " << cls_prefix << cls_nm << "." << exception_factory_name
<< ": I" << exception_factory_name << ";" << endl;
indent_impl(out) << "begin" << endl;
indent_up_impl();
indent_impl(out) << "if F" << exception_factory_name << " = nil" << endl;
indent_impl(out) << "then F" << exception_factory_name << " := T" << exception_factory_name << "Impl.Create;" << endl;
indent_impl(out) << endl;
indent_impl(out) << "result := F" << exception_factory_name << ";" << endl;
indent_down_impl();
indent_impl(out) << "end;" << endl << endl;
}
if (tstruct->is_union()) {
indent_impl(out) << "procedure " << cls_prefix << cls_nm << "."
<< "ClearUnionValues;" << endl;
@ -1692,7 +1726,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "__isset_" + prop_name(*m_iter, is_exception);
indent(out) << "property " << isset_name << ": Boolean read Get" << isset_name << ";"
indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << ";"
<< endl;
}
}
@ -1741,7 +1775,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "F__isset_" + prop_name(*m_iter, is_exception);
indent(out) << isset_name << ": Boolean;" << endl;
indent(out) << isset_name << ": System.Boolean;" << endl;
}
}
}
@ -1764,7 +1798,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "__isset_" + prop_name(*m_iter, is_exception);
indent(out) << "function Get" << isset_name << ": Boolean;" << endl;
indent(out) << "function Get" << isset_name << ": System.Boolean;" << endl;
}
}
}
@ -1790,8 +1824,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
if (is_exception && (!is_x_factory)) {
out << endl;
indent(out) << "// Exception Factory" << endl;
indent(out) << "property " << exception_factory_name << ": " << struct_intf_name << " read F"
<< exception_factory_name << " write F" << exception_factory_name << ";" << endl;
indent(out) << "function " << exception_factory_name << ": " << struct_intf_name << ";" << endl;
}
if ((!is_exception) || is_x_factory) {
@ -1821,7 +1854,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "__isset_" + prop_name(*m_iter, is_exception);
indent(out) << "property " << isset_name << ": Boolean read Get" << isset_name << ";"
indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << ";"
<< endl;
}
}
@ -1850,19 +1883,28 @@ void t_delphi_generator::generate_service(t_service* tservice) {
}
void t_delphi_generator::generate_service_interface(t_service* tservice) {
generate_service_interface(tservice,false);
if(async_) {
generate_service_interface(tservice,true);
}
}
void t_delphi_generator::generate_service_interface(t_service* tservice, bool for_async) {
string extends = "";
string extends_iface = "";
string iface_name = for_async ? "IAsync" : "Iface";
indent_up();
generate_delphi_doc(s_service, tservice);
if (tservice->get_extends() != NULL) {
extends = type_name(tservice->get_extends(), true, true);
extends_iface = extends + ".Iface";
extends_iface = extends + "." + iface_name;
generate_delphi_doc(s_service, tservice);
indent(s_service) << "Iface = interface(" << extends_iface << ")" << endl;
indent(s_service) << iface_name << " = interface(" << extends_iface << ")" << endl;
} else {
indent(s_service) << "Iface = interface" << endl;
indent(s_service) << iface_name << " = interface" << endl;
}
indent_up();
@ -1870,7 +1912,7 @@ void t_delphi_generator::generate_service_interface(t_service* tservice) {
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_delphi_doc(s_service, *f_iter);
indent(s_service) << function_signature(*f_iter) << endl;
indent(s_service) << function_signature(*f_iter, for_async) << endl;
}
indent_down();
indent(s_service) << "end;" << endl << endl;
@ -1896,20 +1938,15 @@ void t_delphi_generator::generate_service_helpers(t_service* tservice) {
void t_delphi_generator::generate_service_client(t_service* tservice) {
indent_up();
string extends = "";
string extends_client = "";
if (tservice->get_extends() != NULL) {
extends = type_name(tservice->get_extends());
extends_client = extends + ".Client, ";
}
string extends_client = "TInterfacedObject";
string implements = async_ ? "Iface, IAsync" : "Iface";
generate_delphi_doc(s_service, tservice);
if (tservice->get_extends() != NULL) {
extends = type_name(tservice->get_extends(), true, true);
extends_client = extends + ".TClient";
indent(s_service) << "TClient = class(" << extends_client << ", Iface)" << endl;
} else {
indent(s_service) << "TClient = class( TInterfacedObject, Iface)" << endl;
}
indent(s_service) << "TClient = class( " << extends_client << ", " << implements << ")" << endl;
indent(s_service) << "public" << endl;
indent_up();
@ -1945,7 +1982,7 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
indent_up();
indent(s_service) << "iprot_: IProtocol;" << endl;
indent(s_service) << "oprot_: IProtocol;" << endl;
indent(s_service) << "seqid_: Integer;" << endl;
indent(s_service) << "seqid_: System.Integer;" << endl;
indent_down();
indent(s_service) << "public" << endl;
@ -1960,12 +1997,24 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
indent(s_service) << "protected" << endl;
indent_up();
indent(s_service) << "// Iface" << endl;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string funname = (*f_iter)->get_name();
generate_delphi_doc(s_service, *f_iter);
indent(s_service) << function_signature(*f_iter) << endl;
indent(s_service) << function_signature(*f_iter, false) << endl;
}
if( async_) {
indent(s_service) << endl;
indent(s_service) << "// IAsync" << endl;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string funname = (*f_iter)->get_name();
generate_delphi_doc(s_service, *f_iter);
indent(s_service) << function_signature(*f_iter, true) << endl;
}
}
indent_down();
indent(s_service) << "public" << endl;
@ -1976,36 +2025,65 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
string funname = (*f_iter)->get_name();
indent_impl(s_service_impl) << function_signature(*f_iter, full_cls) << endl;
indent_impl(s_service_impl) << "begin" << endl;
indent_up_impl();
indent_impl(s_service_impl) << "send_" << funname << "(";
t_struct* arg_struct = (*f_iter)->get_arglist();
const vector<t_field*>& fields = arg_struct->get_members();
vector<t_field*>::const_iterator fld_iter;
bool first = true;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
if (first) {
first = false;
} else {
s_service_impl << ", ";
}
s_service_impl << normalize_name((*fld_iter)->get_name());
}
s_service_impl << ");" << endl;
t_struct* arg_struct = (*f_iter)->get_arglist();
const vector<t_field*>& fields = arg_struct->get_members();
if (!(*f_iter)->is_oneway()) {
s_service_impl << indent_impl();
if (!(*f_iter)->get_returntype()->is_void()) {
s_service_impl << "Result := ";
}
s_service_impl << "recv_" << funname << "();" << endl;
}
// one for sync only, two for async+sync
int mode = async_ ? 1 : 0;
while( mode >= 0) {
bool for_async = (mode != 0);
mode--;
indent_down_impl();
indent_impl(s_service_impl) << "end;" << endl << endl;
indent_impl(s_service_impl) << function_signature(*f_iter, for_async, full_cls) << endl;
indent_impl(s_service_impl) << "begin" << endl;
indent_up_impl();
t_type* ttype = (*f_iter)->get_returntype();
if( for_async) {
if (is_void(ttype)) {
// Delphi forces us to specify a type with IFuture<T>, so we use Integer=0 for void methods
indent_impl(s_service_impl) << "result := TTask.Future<System.Integer>(function: System.Integer" << endl;
} else {
string rettype = type_name(ttype, false, true, false, true);
indent_impl(s_service_impl) << "result := TTask.Future<" << rettype << ">(function: " << rettype << endl;
}
indent_impl(s_service_impl) << "begin" << endl;
indent_up_impl();
}
indent_impl(s_service_impl) << "send_" << funname << "(";
bool first = true;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
if (first) {
first = false;
} else {
s_service_impl << ", ";
}
s_service_impl << normalize_name((*fld_iter)->get_name());
}
s_service_impl << ");" << endl;
if (!(*f_iter)->is_oneway()) {
s_service_impl << indent_impl();
if (!(*f_iter)->get_returntype()->is_void()) {
s_service_impl << "Result := ";
}
s_service_impl << "recv_" << funname << "();" << endl;
}
if( for_async) {
if (is_void(ttype)) {
indent_impl(s_service_impl) << "Result := 0;" << endl; // no IFuture<void> in Delphi
}
indent_down_impl();
indent_impl(s_service_impl) << "end);" << endl;
}
indent_down_impl();
indent_impl(s_service_impl) << "end;" << endl << endl;
}
t_function send_function(g_type_void,
string("send_") + (*f_iter)->get_name(),
@ -2018,18 +2096,18 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
string argsvar = tmp("_args");
string msgvar = tmp("_msg");
indent(s_service) << function_signature(&send_function) << endl;
indent_impl(s_service_impl) << function_signature(&send_function, full_cls) << endl;
indent(s_service) << function_signature(&send_function, false) << endl;
indent_impl(s_service_impl) << function_signature(&send_function, false, full_cls) << endl;
indent_impl(s_service_impl) << "var" << endl;
indent_up_impl();
indent_impl(s_service_impl) << argsvar << " : " << args_intfnm << ";" << endl;
indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.IMessage;" << endl;
indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << endl;
indent_down_impl();
indent_impl(s_service_impl) << "begin" << endl;
indent_up_impl();
indent_impl(s_service_impl) << "seqid_ := seqid_ + 1;" << endl;
indent_impl(s_service_impl) << msgvar << " := Thrift.Protocol.TMessageImpl.Create('" << funname
indent_impl(s_service_impl) << "Thrift.Protocol.Init( " << msgvar << ", '" << funname
<< "', " << ((*f_iter)->is_oneway() ? "TMessageType.Oneway"
: "TMessageType.Call")
<< ", seqid_);" << endl;
@ -2072,11 +2150,11 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
string appexvar = tmp("_ax");
string retvar = tmp("_ret");
indent(s_service) << function_signature(&recv_function) << endl;
indent_impl(s_service_impl) << function_signature(&recv_function, full_cls) << endl;
indent(s_service) << function_signature(&recv_function, false) << endl;
indent_impl(s_service_impl) << function_signature(&recv_function, false, full_cls) << endl;
indent_impl(s_service_impl) << "var" << endl;
indent_up_impl();
indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.IMessage;" << endl;
indent_impl(s_service_impl) << msgvar << " : Thrift.Protocol.TThriftMessage;" << endl;
if (xceptions.size() > 0) {
indent_impl(s_service_impl) << exceptvar << " : Exception;" << endl;
}
@ -2131,7 +2209,7 @@ void t_delphi_generator::generate_service_client(t_service* tservice) {
if (!(*f_iter)->get_returntype()->is_void()) {
indent_impl(s_service_impl)
<< "raise TApplicationExceptionMissingResult.Create('"
<< "raise TApplicationExceptionMissingResult.Create('"
<< (*f_iter)->get_name() << " failed: unknown result');" << endl;
}
@ -2207,7 +2285,7 @@ void t_delphi_generator::generate_service_server(t_service* tservice) {
indent_up();
indent(s_service) << "type" << endl;
indent_up();
indent(s_service) << "TProcessFunction = reference to procedure( seqid: Integer; const iprot: "
indent(s_service) << "TProcessFunction = reference to procedure( seqid: System.Integer; const iprot: "
"IProtocol; const oprot: IProtocol"
<< (events_ ? "; const events : IRequestEvents" : "") << ");" << endl;
indent_down();
@ -2222,19 +2300,19 @@ void t_delphi_generator::generate_service_server(t_service* tservice) {
indent_up();
if (extends.empty()) {
indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol; const "
"events : IProcessorEvents): Boolean;" << endl;
"events : IProcessorEvents): System.Boolean;" << endl;
} else {
indent(s_service) << "function Process( const iprot: IProtocol; const oprot: IProtocol; const "
"events : IProcessorEvents): Boolean; reintroduce;" << endl;
"events : IProcessorEvents): System.Boolean; reintroduce;" << endl;
}
indent_impl(s_service_impl) << "function " << full_cls << ".Process( const iprot: IProtocol; "
"const oprot: IProtocol; const events "
": IProcessorEvents): Boolean;" << endl;
": IProcessorEvents): System.Boolean;" << endl;
;
indent_impl(s_service_impl) << "var" << endl;
indent_up_impl();
indent_impl(s_service_impl) << "msg : Thrift.Protocol.IMessage;" << endl;
indent_impl(s_service_impl) << "msg : Thrift.Protocol.TThriftMessage;" << endl;
indent_impl(s_service_impl) << "fn : TProcessFunction;" << endl;
indent_impl(s_service_impl) << "x : TApplicationException;" << endl;
if (events_) {
@ -2254,10 +2332,10 @@ void t_delphi_generator::generate_service_server(t_service* tservice) {
indent_impl(s_service_impl) << "TProtocolUtil.Skip(iprot, TType.Struct);" << endl;
indent_impl(s_service_impl) << "iprot.ReadMessageEnd();" << endl;
indent_impl(s_service_impl) << "x := "
"TApplicationExceptionUnknownMethod.Create("
"'Invalid method name: ''' + msg.Name + '''');" << endl;
"TApplicationExceptionUnknownMethod.Create("
"'Invalid method name: ''' + msg.Name + '''');" << endl;
indent_impl(s_service_impl)
<< "msg := Thrift.Protocol.TMessageImpl.Create(msg.Name, TMessageType.Exception, msg.SeqID);"
<< "Thrift.Protocol.Init( msg, msg.Name, TMessageType.Exception, msg.SeqID);"
<< endl;
indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl;
indent_impl(s_service_impl) << "x.Write(oprot);" << endl;
@ -2356,7 +2434,7 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi
string result_intfnm = normalize_clsnm(org_resultname, "I");
indent(s_service) << "procedure " << funcname
<< "_Process( seqid: Integer; const iprot: IProtocol; const oprot: IProtocol"
<< "_Process( seqid: System.Integer; const iprot: IProtocol; const oprot: IProtocol"
<< (events_ ? "; const events : IRequestEvents" : "") << ");" << endl;
if (tfunction->is_oneway()) {
@ -2367,13 +2445,13 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi
indent_impl(s_service_impl)
<< "procedure " << full_cls << "." << funcname
<< "_Process( seqid: Integer; const iprot: IProtocol; const oprot: IProtocol"
<< "_Process( seqid: System.Integer; const iprot: IProtocol; const oprot: IProtocol"
<< (events_ ? "; const events : IRequestEvents" : "") << ");" << endl;
indent_impl(s_service_impl) << "var" << endl;
indent_up_impl();
indent_impl(s_service_impl) << "args: " << args_intfnm << ";" << endl;
if (!tfunction->is_oneway()) {
indent_impl(s_service_impl) << "msg: Thrift.Protocol.IMessage;" << endl;
indent_impl(s_service_impl) << "msg: Thrift.Protocol.TThriftMessage;" << endl;
indent_impl(s_service_impl) << "ret: " << result_intfnm << ";" << endl;
indent_impl(s_service_impl) << "appx : TApplicationException;" << endl;
}
@ -2452,14 +2530,14 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi
indent_impl(s_service_impl) << "if events <> nil then events.UnhandledError(E);" << endl;
}
if (!tfunction->is_oneway()) {
indent_impl(s_service_impl) << "appx := TApplicationExceptionInternalError.Create(E.Message);"
indent_impl(s_service_impl) << "appx := TApplicationExceptionInternalError.Create(E.Message);"
<< endl;
indent_impl(s_service_impl) << "try" << endl;
indent_up_impl();
if(events_) {
indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl;
}
indent_impl(s_service_impl) << "msg := Thrift.Protocol.TMessageImpl.Create('"
indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, '"
<< tfunction->get_name() << "', TMessageType.Exception, seqid);"
<< endl;
indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg);" << endl;
@ -2487,7 +2565,7 @@ void t_delphi_generator::generate_process_function(t_service* tservice, t_functi
if (events_) {
indent_impl(s_service_impl) << "if events <> nil then events.PreWrite;" << endl;
}
indent_impl(s_service_impl) << "msg := Thrift.Protocol.TMessageImpl.Create('"
indent_impl(s_service_impl) << "Thrift.Protocol.Init( msg, '"
<< tfunction->get_name() << "', TMessageType.Reply, seqid); "
<< endl;
indent_impl(s_service_impl) << "oprot.WriteMessageBegin( msg); " << endl;
@ -2541,7 +2619,7 @@ void t_delphi_generator::generate_deserialize_field(ostream& out,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
if (ansistr_binary_) {
out << "ReadAnsiString();";
} else {
@ -2619,15 +2697,15 @@ void t_delphi_generator::generate_deserialize_container(ostream& out,
}
if (ttype->is_map()) {
local_var = obj + ": IMap;";
local_var = obj + ": TThriftMap;";
} else if (ttype->is_set()) {
local_var = obj + ": ISet;";
local_var = obj + ": TThriftSet;";
} else if (ttype->is_list()) {
local_var = obj + ": IList;";
local_var = obj + ": TThriftList;";
}
local_vars << " " << local_var << endl;
counter = tmp("_i");
local_var = counter + ": Integer;";
local_var = counter + ": System.Integer;";
local_vars << " " << local_var << endl;
indent_impl(out) << name << " := " << type_name(ttype, true) << ".Create;" << endl;
@ -2742,7 +2820,7 @@ void t_delphi_generator::generate_serialize_field(ostream& out,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
if (ansistr_binary_) {
out << "WriteAnsiString(";
} else {
@ -2775,7 +2853,7 @@ void t_delphi_generator::generate_serialize_field(ostream& out,
throw "compiler error: no Delphi name for base type " + t_base_type::t_base_name(tbase);
}
} else if (type->is_enum()) {
out << "WriteI32(Integer(" << name << "));";
out << "WriteI32(System.Integer(" << name << "));";
}
out << endl;
} else {
@ -2803,23 +2881,23 @@ void t_delphi_generator::generate_serialize_container(ostream& out,
string obj;
if (ttype->is_map()) {
obj = tmp("map");
local_vars << " " << obj << " : IMap;" << endl;
indent_impl(out) << obj << " := TMapImpl.Create( "
local_vars << " " << obj << " : TThriftMap;" << endl;
indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", "
<< type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix
<< ".Count);" << endl;
indent_impl(out) << "oprot.WriteMapBegin( " << obj << ");" << endl;
} else if (ttype->is_set()) {
obj = tmp("set_");
local_vars << " " << obj << " : ISet;" << endl;
indent_impl(out) << obj << " := TSetImpl.Create("
local_vars << " " << obj << " : TThriftSet;" << endl;
indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", "
<< type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << prefix
<< ".Count);" << endl;
indent_impl(out) << "oprot.WriteSetBegin( " << obj << ");" << endl;
} else if (ttype->is_list()) {
obj = tmp("list_");
local_vars << " " << obj << " : IList;" << endl;
indent_impl(out) << obj << " := TListImpl.Create("
local_vars << " " << obj << " : TThriftList;" << endl;
indent_impl(out) << "Thrift.Protocol.Init( " << obj << ", "
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix
<< ".Count);" << endl;
indent_impl(out) << "oprot.WriteListBegin( " << obj << ");" << endl;
@ -3086,25 +3164,25 @@ string t_delphi_generator::base_type_name(t_base_type* tbase) {
case t_base_type::TYPE_STRING:
if (tbase->is_binary()) {
if (ansistr_binary_) {
return "AnsiString";
return "System.AnsiString";
} else {
return "TBytes";
return "SysUtils.TBytes";
}
} else {
return "string";
return "System.string";
}
case t_base_type::TYPE_BOOL:
return "Boolean";
return "System.Boolean";
case t_base_type::TYPE_I8:
return "ShortInt";
return "System.ShortInt";
case t_base_type::TYPE_I16:
return "SmallInt";
return "System.SmallInt";
case t_base_type::TYPE_I32:
return "Integer";
return "System.Integer";
case t_base_type::TYPE_I64:
return "Int64";
return "System.Int64";
case t_base_type::TYPE_DOUBLE:
return "Double";
return "System.Double";
default:
throw "compiler error: no Delphi name for base type "
+ t_base_type::t_base_name(tbase->get_base());
@ -3126,6 +3204,7 @@ string t_delphi_generator::declare_field(t_field* tfield,
}
string t_delphi_generator::function_signature(t_function* tfunction,
bool for_async,
std::string full_cls,
bool is_xception) {
t_type* ttype = tfunction->get_returntype();
@ -3135,13 +3214,25 @@ string t_delphi_generator::function_signature(t_function* tfunction,
} else {
prefix = full_cls + ".";
}
if (is_void(ttype)) {
return "procedure " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "("
+ argument_list(tfunction->get_arglist()) + ");";
if( for_async) {
if (is_void(ttype)) {
return "function " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "Async("
+ argument_list(tfunction->get_arglist()) + "): IFuture<Integer>;"; // no IFuture<void> in Delphi
} else {
return "function " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "Async("
+ argument_list(tfunction->get_arglist()) + "): IFuture<"
+ type_name(ttype, false, true, is_xception, true) + ">;";
}
} else {
return "function " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "("
+ argument_list(tfunction->get_arglist()) + "): "
+ type_name(ttype, false, true, is_xception, true) + ";";
if (is_void(ttype)) {
return "procedure " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "("
+ argument_list(tfunction->get_arglist()) + ");";
} else {
return "function " + prefix + normalize_name(tfunction->get_name(), true, is_xception) + "("
+ argument_list(tfunction->get_arglist()) + "): "
+ type_name(ttype, false, true, is_xception, true) + ";";
}
}
}
@ -3268,7 +3359,7 @@ string t_delphi_generator::empty_value(t_type* type) {
case t_base_type::TYPE_VOID:
return "0";
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
if (ansistr_binary_) {
return "''";
} else {
@ -3326,7 +3417,7 @@ void t_delphi_generator::generate_delphi_property_reader_definition(ostream& out
void t_delphi_generator::generate_delphi_isset_reader_definition(ostream& out,
t_field* tfield,
bool is_xception) {
indent(out) << "function Get__isset_" << prop_name(tfield, is_xception) << ": Boolean;" << endl;
indent(out) << "function Get__isset_" << prop_name(tfield, is_xception) << ": System.Boolean;" << endl;
}
void t_delphi_generator::generate_delphi_clear_union_value(ostream& out,
@ -3369,7 +3460,7 @@ void t_delphi_generator::generate_delphi_property_writer_impl(ostream& out,
bool is_xception_class,
bool is_union,
bool is_xception_factory,
std::string xception_factroy_name) {
std::string xception_factory_name) {
(void)type;
t_type* ftype = tfield->get_type();
@ -3390,7 +3481,7 @@ void t_delphi_generator::generate_delphi_property_writer_impl(ostream& out,
indent_impl(out) << fieldPrefix << prop_name(tfield, is_xception_class) << " := Value;" << endl;
if (is_xception_class && (!is_xception_factory)) {
indent_impl(out) << "F" << xception_factroy_name << "." << prop_name(tfield, is_xception_class)
indent_impl(out) << xception_factory_name << "." << prop_name(tfield, is_xception_class)
<< " := Value;" << endl;
}
@ -3432,7 +3523,7 @@ void t_delphi_generator::generate_delphi_isset_reader_impl(ostream& out,
string isset_name = "__isset_" + prop_name(tfield, is_xception);
indent_impl(out) << "function " << cls_prefix << name << "."
<< "Get" << isset_name << ": Boolean;" << endl;
<< "Get" << isset_name << ": System.Boolean;" << endl;
indent_impl(out) << "begin" << endl;
indent_up_impl();
indent_impl(out) << "Result := " << fieldPrefix << isset_name << ";" << endl;
@ -3457,7 +3548,7 @@ void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out,
indent_impl(out) << "Result := " << exception_cls_nm << ".Create;" << endl;
string factory_name = normalize_clsnm(tstruct->get_name(), "", true) + "Factory";
indent_impl(out) << "Result." << factory_name << " := Self;" << endl;
indent_impl(out) << "Result.F" << factory_name << " := Self;" << endl;
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -3467,8 +3558,7 @@ void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out,
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
propname = prop_name(*f_iter, is_exception);
if ((*f_iter)->get_req() != t_field::T_REQUIRED) {
indent_impl(out) << "if __isset_" << propname << " then" << endl;
indent_impl(out) << "begin" << endl;
indent_impl(out) << "if __isset_" << propname << " then begin" << endl;
indent_up_impl();
}
indent_impl(out) << "Result." << propname << " := " << propname << ";" << endl;
@ -3504,7 +3594,7 @@ void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out,
// local bools for required fields
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
indent_impl(local_vars) << "_req_isset_" << prop_name(*f_iter, is_exception) << " : Boolean;"
indent_impl(local_vars) << "_req_isset_" << prop_name(*f_iter, is_exception) << " : System.Boolean;"
<< endl;
indent_impl(code_block) << "_req_isset_" << prop_name(*f_iter, is_exception) << " := FALSE;"
<< endl;
@ -3548,7 +3638,7 @@ void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out,
<< ") then begin" << endl;
indent_up_impl();
generate_deserialize_field(code_block, is_exception, *f_iter, "", local_vars);
generate_deserialize_field(code_block, is_exception, *f_iter, "Self.", local_vars);
// required field?
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
@ -3617,8 +3707,8 @@ void t_delphi_generator::generate_delphi_struct_reader_impl(ostream& out,
<< endl;
indent_impl(out) << "var" << endl;
indent_up_impl();
indent_impl(out) << "field_ : IField;" << endl;
indent_impl(out) << "struc : IStruct;" << endl;
indent_impl(out) << "field_ : TThriftField;" << endl;
indent_impl(out) << "struc : TThriftStruct;" << endl;
indent_down_impl();
out << local_vars.str() << endl;
out << code_block.str();
@ -3642,11 +3732,11 @@ void t_delphi_generator::generate_delphi_struct_result_writer_impl(ostream& out,
indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl;
indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << endl;
indent_impl(code_block) << "struc := TStructImpl.Create('" << name << "');" << endl;
indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << endl;
indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << endl;
if (fields.size() > 0) {
indent_impl(code_block) << "field_ := TFieldImpl.Create;" << endl;
indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << endl;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
indent_impl(code_block) << "if (__isset_" << prop_name(*f_iter, is_exception) << ") then"
<< endl;
@ -3657,7 +3747,7 @@ void t_delphi_generator::generate_delphi_struct_result_writer_impl(ostream& out,
<< endl;
indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << endl;
indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << endl;
generate_serialize_field(code_block, is_exception, *f_iter, "", local_vars);
generate_serialize_field(code_block, is_exception, *f_iter, "Self.", local_vars);
indent_impl(code_block) << "oprot.WriteFieldEnd();" << endl;
indent_down_impl();
}
@ -3677,10 +3767,10 @@ void t_delphi_generator::generate_delphi_struct_result_writer_impl(ostream& out,
<< endl;
indent_impl(out) << "var" << endl;
indent_up_impl();
indent_impl(out) << "struc : IStruct;" << endl;
indent_impl(out) << "struc : TThriftStruct;" << endl;
if (fields.size() > 0) {
indent_impl(out) << "field_ : IField;" << endl;
indent_impl(out) << "field_ : TThriftField;" << endl;
}
out << local_vars.str();
@ -3706,11 +3796,11 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out,
indent_impl(local_vars) << "tracker : IProtocolRecursionTracker;" << endl;
indent_impl(code_block) << "tracker := oprot.NextRecursionLevel;" << endl;
indent_impl(code_block) << "struc := TStructImpl.Create('" << name << "');" << endl;
indent_impl(code_block) << "Thrift.Protocol.Init( struc, '" << name << "');" << endl;
indent_impl(code_block) << "oprot.WriteStructBegin(struc);" << endl;
if (fields.size() > 0) {
indent_impl(code_block) << "field_ := TFieldImpl.Create;" << endl;
indent_impl(code_block) << "Thrift.Protocol.Init( field_);" << endl;
}
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -3720,13 +3810,13 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out,
bool has_isset = (!is_required);
if (is_required && null_allowed) {
null_allowed = false;
indent_impl(code_block) << "if (" << fieldname << " = nil)" << endl;
indent_impl(code_block) << "then raise TProtocolExceptionInvalidData.Create("
indent_impl(code_block) << "if (Self." << fieldname << " = nil)" << endl;
indent_impl(code_block) << "then raise TProtocolExceptionInvalidData.Create("
<< "'required field " << fieldname << " not set');"
<< endl;
}
if (null_allowed) {
indent_impl(code_block) << "if (" << fieldname << " <> nil)";
indent_impl(code_block) << "if (Self." << fieldname << " <> nil)";
if (has_isset) {
code_block << " and __isset_" << fieldname;
}
@ -3743,7 +3833,7 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out,
<< endl;
indent_impl(code_block) << "field_.ID := " << (*f_iter)->get_key() << ";" << endl;
indent_impl(code_block) << "oprot.WriteFieldBegin(field_);" << endl;
generate_serialize_field(code_block, is_exception, *f_iter, "", local_vars);
generate_serialize_field(code_block, is_exception, *f_iter, "Self.", local_vars);
indent_impl(code_block) << "oprot.WriteFieldEnd();" << endl;
if (null_allowed || has_isset) {
indent_down_impl();
@ -3765,9 +3855,9 @@ void t_delphi_generator::generate_delphi_struct_writer_impl(ostream& out,
<< endl;
indent_impl(out) << "var" << endl;
indent_up_impl();
indent_impl(out) << "struc : IStruct;" << endl;
indent_impl(out) << "struc : TThriftStruct;" << endl;
if (fields.size() > 0) {
indent_impl(out) << "field_ : IField;" << endl;
indent_impl(out) << "field_ : TThriftField;" << endl;
}
out << local_vars.str();
indent_down_impl();
@ -3802,7 +3892,7 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out,
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
bool is_optional = ((*f_iter)->get_req() != t_field::T_REQUIRED);
if (is_optional) {
indent_impl(out) << tmp_first << " : Boolean;" << endl;
indent_impl(out) << tmp_first << " : System.Boolean;" << endl;
useFirstFlag = true;
}
break;
@ -3825,7 +3915,7 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out,
bool null_allowed = type_can_be_null((*f_iter)->get_type());
bool is_optional = ((*f_iter)->get_req() != t_field::T_REQUIRED);
if (null_allowed) {
indent_impl(out) << "if (" << prop_name((*f_iter), is_exception) << " <> nil)";
indent_impl(out) << "if (Self." << prop_name((*f_iter), is_exception) << " <> nil)";
if (is_optional) {
out << " and __isset_" << prop_name(*f_iter, is_exception);
}
@ -3857,14 +3947,14 @@ void t_delphi_generator::generate_delphi_struct_tostring_impl(ostream& out,
}
if (ttype->is_xception() || ttype->is_struct()) {
indent_impl(out) << "if (" << prop_name((*f_iter), is_exception) << " = nil) then " << tmp_sb
<< ".Append('<null>') else " << tmp_sb << ".Append("
indent_impl(out) << "if (Self." << prop_name((*f_iter), is_exception) << " = nil) then " << tmp_sb
<< ".Append('<null>') else " << tmp_sb << ".Append( Self."
<< prop_name((*f_iter), is_exception) << ".ToString());" << endl;
} else if (ttype->is_enum()) {
indent_impl(out) << tmp_sb << ".Append(Integer(" << prop_name((*f_iter), is_exception)
indent_impl(out) << tmp_sb << ".Append(System.Integer( Self." << prop_name((*f_iter), is_exception)
<< "));" << endl;
} else {
indent_impl(out) << tmp_sb << ".Append(" << prop_name((*f_iter), is_exception) << ");"
indent_impl(out) << tmp_sb << ".Append( Self." << prop_name((*f_iter), is_exception) << ");"
<< endl;
}
@ -3917,4 +4007,5 @@ THRIFT_REGISTER_GENERATOR(
" and container instances by interface or TypeInfo()\n"
" constprefix: Name TConstants classes after IDL to reduce ambiguities\n"
" events: Enable and use processing events in the generated code.\n"
" xmldoc: Enable XMLDoc comments for Help Insight etc.\n")
" xmldoc: Enable XMLDoc comments for Help Insight etc.\n"
" async: Generate IAsync interface to use Parallel Programming Library (XE7+ only).\n")

View file

@ -20,6 +20,7 @@
#include <string>
#include <fstream>
#include <iostream>
#include <limits>
#include <vector>
#include <stdlib.h>
@ -56,6 +57,9 @@ public:
legacy_names_ = false;
maps_ = false;
otp16_ = false;
export_lines_first_ = true;
export_types_lines_first_ = true;
for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
if( iter->first.compare("legacynames") == 0) {
legacy_names_ = true;
@ -117,6 +121,8 @@ public:
void generate_type_metadata(std::string function_name, vector<string> names);
void generate_enum_info(t_enum* tenum);
void generate_enum_metadata();
void generate_const_function(t_const* tconst, ostringstream& exports, ostringstream& functions);
void generate_const_functions();
/**
* Service-level generation functions
@ -135,6 +141,7 @@ public:
std::string erl_imports();
std::string render_includes();
std::string type_name(t_type* ttype);
std::string render_const_list_values(t_type* type, t_const_value* value);
std::string function_signature(t_function* tfunction, std::string prefix = "");
@ -187,7 +194,6 @@ private:
void export_function(t_function* tfunction, std::string prefix = "");
void export_string(std::string name, int num);
void export_types_function(t_function* tfunction, std::string prefix = "");
void export_types_string(std::string name, int num);
/**
@ -214,13 +220,15 @@ private:
std::ostringstream f_info_;
std::ostringstream f_info_ext_;
std::ofstream f_types_file_;
std::ofstream f_types_hrl_file_;
ofstream_with_content_based_conditional_update f_types_file_;
ofstream_with_content_based_conditional_update f_types_hrl_file_;
ofstream_with_content_based_conditional_update f_consts_file_;
ofstream_with_content_based_conditional_update f_consts_hrl_file_;
std::ofstream f_consts_;
std::ostringstream f_service_;
std::ofstream f_service_file_;
std::ofstream f_service_hrl_;
ofstream_with_content_based_conditional_update f_service_file_;
ofstream_with_content_based_conditional_update f_service_hrl_;
/**
* Metadata containers
@ -229,6 +237,7 @@ private:
std::vector<std::string> v_enum_names_;
std::vector<std::string> v_exception_names_;
std::vector<t_enum*> v_enums_;
std::vector<t_const*> v_consts_;
};
/**
@ -245,31 +254,41 @@ void t_erl_generator::init_generator() {
export_lines_first_ = true;
export_types_lines_first_ = true;
string program_module_name = make_safe_for_module_name(program_name_);
// types files
string f_types_name = get_out_dir() + make_safe_for_module_name(program_name_) + "_types.erl";
string f_types_hrl_name = get_out_dir() + make_safe_for_module_name(program_name_) + "_types.hrl";
string f_types_name = get_out_dir() + program_module_name + "_types.erl";
string f_types_hrl_name = get_out_dir() + program_module_name + "_types.hrl";
f_types_file_.open(f_types_name.c_str());
f_types_hrl_file_.open(f_types_hrl_name.c_str());
hrl_header(f_types_hrl_file_, make_safe_for_module_name(program_name_) + "_types");
hrl_header(f_types_hrl_file_, program_module_name + "_types");
f_types_file_ << erl_autogen_comment() << endl << "-module("
<< make_safe_for_module_name(program_name_) << "_types)." << endl << erl_imports()
<< endl;
f_types_file_ << erl_autogen_comment() << endl
<< "-module(" << program_module_name << "_types)." << endl
<< erl_imports() << endl;
f_types_file_ << "-include(\"" << make_safe_for_module_name(program_name_) << "_types.hrl\")."
<< endl << endl;
f_types_file_ << "-include(\"" << program_module_name << "_types.hrl\")." << endl
<< endl;
f_types_hrl_file_ << render_includes() << endl;
// consts file
string f_consts_name = get_out_dir() + make_safe_for_module_name(program_name_)
+ "_constants.hrl";
f_consts_.open(f_consts_name.c_str());
// consts files
string f_consts_name = get_out_dir() + program_module_name + "_constants.erl";
string f_consts_hrl_name = get_out_dir() + program_module_name + "_constants.hrl";
f_consts_ << erl_autogen_comment() << endl << erl_imports() << endl << "-include(\""
<< make_safe_for_module_name(program_name_) << "_types.hrl\")." << endl << endl;
f_consts_file_.open(f_consts_name.c_str());
f_consts_hrl_file_.open(f_consts_hrl_name.c_str());
f_consts_file_ << erl_autogen_comment() << endl
<< "-module(" << program_module_name << "_constants)." << endl
<< erl_imports() << endl
<< "-include(\"" << program_module_name << "_types.hrl\")." << endl
<< endl;
f_consts_hrl_file_ << erl_autogen_comment() << endl << erl_imports() << endl
<< "-include(\"" << program_module_name << "_types.hrl\")." << endl << endl;
}
/**
@ -350,6 +369,8 @@ void t_erl_generator::close_generator() {
f_types_file_ << f_info_ext_.str();
f_types_file_ << "struct_info_ext(_) -> erlang:error(function_clause)." << endl << endl;
generate_const_functions();
generate_type_metadata("struct_names", v_struct_names_);
generate_enum_metadata();
generate_type_metadata("enum_names", v_enum_names_);
@ -359,7 +380,38 @@ void t_erl_generator::close_generator() {
f_types_file_.close();
f_types_hrl_file_.close();
f_consts_.close();
f_consts_file_.close();
f_consts_hrl_file_.close();
}
const std::string emit_double_as_string(const double value) {
std::stringstream double_output_stream;
// sets the maximum precision: http://en.cppreference.com/w/cpp/io/manip/setprecision
// sets the output format to fixed: http://en.cppreference.com/w/cpp/io/manip/fixed (not in scientific notation)
double_output_stream << std::setprecision(std::numeric_limits<double>::digits10 + 1);
#ifdef _MSC_VER
// strtod is broken in MSVC compilers older than 2015, so std::fixed fails to format a double literal.
// more details: https://blogs.msdn.microsoft.com/vcblog/2014/06/18/
// c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
// and
// http://www.exploringbinary.com/visual-c-plus-plus-strtod-still-broken/
#if _MSC_VER >= MSC_2015_VER
double_output_stream << std::fixed;
#else
// note that if this function is called from the erlang generator and the MSVC compiler is older than 2015,
// the double literal must be output in the scientific format. There can be some cases where the
// mantissa of the output does not have fractionals, which is illegal in Erlang.
// example => 10000000000000000.0 being output as 1e+16
double_output_stream << std::scientific;
#endif
#else
double_output_stream << std::fixed;
#endif
double_output_stream << value;
return double_output_stream.str();
}
void t_erl_generator::generate_type_metadata(std::string function_name, vector<string> names) {
@ -392,6 +444,68 @@ void t_erl_generator::generate_typedef(t_typedef* ttypedef) {
(void)ttypedef;
}
void t_erl_generator::generate_const_function(t_const* tconst, ostringstream& exports, ostringstream& functions) {
t_type* type = get_true_type(tconst->get_type());
string name = tconst->get_name();
t_const_value* value = tconst->get_value();
if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
string const_fun_name = lowercase(name);
// Emit const function export.
if (exports.tellp() > 0) { exports << ", "; }
exports << const_fun_name << "/1, " << const_fun_name << "/2";
// Emit const function definition.
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator i, end = value->get_map().end();
// The one-argument form throws an error if the key does not exist in the map.
for (i = value->get_map().begin(); i != end;) {
functions << const_fun_name << "(" << render_const_value(ktype, i->first) << ") -> "
<< render_const_value(vtype, i->second);
++i;
functions << (i != end ? ";\n" : ".\n\n");
}
// The two-argument form returns a default value if the key does not exist in the map.
for (i = value->get_map().begin(); i != end; ++i) {
functions << const_fun_name << "(" << render_const_value(ktype, i->first) << ", _) -> "
<< render_const_value(vtype, i->second) << ";\n";
}
functions << const_fun_name << "(_, Default) -> Default.\n\n";
} else if (type->is_list()) {
string const_fun_name = lowercase(name);
if (exports.tellp() > 0) { exports << ", "; }
exports << const_fun_name << "/1, " << const_fun_name << "/2";
size_t list_size = value->get_list().size();
string rendered_list = render_const_list_values(type, value);
functions << const_fun_name << "(N) when N >= 1, N =< " << list_size << " ->\n"
<< indent_str() << "element(N, {" << rendered_list << "}).\n";
functions << const_fun_name << "(N, _) when N >= 1, N =< " << list_size << " ->\n"
<< indent_str() << "element(N, {" << rendered_list << "});\n"
<< const_fun_name << "(_, Default) -> Default.\n\n";
indent_down();
}
}
void t_erl_generator::generate_const_functions() {
ostringstream exports;
ostringstream functions;
vector<t_const*>::iterator c_iter;
for (c_iter = v_consts_.begin(); c_iter != v_consts_.end(); ++c_iter) {
generate_const_function(*c_iter, exports, functions);
}
if (exports.tellp() > 0) {
f_consts_file_ << "-export([" << exports.str() << "]).\n\n"
<< functions.str();
}
}
/**
* Generates code for an enumerated type. Done using a class to scope
* the values.
@ -458,8 +572,11 @@ void t_erl_generator::generate_const(t_const* tconst) {
string name = tconst->get_name();
t_const_value* value = tconst->get_value();
f_consts_ << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_"
<< constify(name) << ", " << render_const_value(type, value) << ")." << endl << endl;
// Save the tconst so that function can be emitted in generate_const_functions().
v_consts_.push_back(tconst);
f_consts_hrl_file_ << "-define(" << constify(make_safe_for_module_name(program_name_)) << "_"
<< constify(name) << ", " << render_const_value(type, value) << ")." << endl << endl;
}
/**
@ -488,9 +605,9 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
break;
case t_base_type::TYPE_DOUBLE:
if (value->get_type() == t_const_value::CV_INTEGER) {
out << value->get_integer();
out << "float(" << value->get_integer() << ")";
} else {
out << value->get_double();
out << emit_double_as_string(value->get_double());
}
break;
default:
@ -503,8 +620,8 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
out << "#" << type_name(type) << "{";
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
bool first = true;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
@ -539,7 +656,7 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
} else {
out << "dict:from_list([";
}
map<t_const_value*, t_const_value*>::const_iterator i, end = value->get_map().end();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator i, end = value->get_map().end();
for (i = value->get_map().begin(); i != end;) {
out << "{" << render_const_value(ktype, i->first) << ","
<< render_const_value(vtype, i->second) << "}";
@ -560,28 +677,32 @@ string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
}
out << "])";
} else if (type->is_list()) {
t_type* etype;
etype = ((t_list*)type)->get_elem_type();
out << "[";
bool first = true;
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
if (first) {
first = false;
} else {
out << ",";
}
out << render_const_value(etype, *v_iter);
}
out << "]";
out << "[" << render_const_list_values(type, value) << "]";
} else {
throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
}
return out.str();
}
string t_erl_generator::render_const_list_values(t_type* type, t_const_value* value) {
std::ostringstream out;
t_type* etype = ((t_list*)type)->get_elem_type();
bool first = true;
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
if (first) {
first = false;
} else {
out << ",";
}
out << render_const_value(etype, *v_iter);
}
return out.str();
}
string t_erl_generator::render_default_value(t_field* field) {
t_type* type = field->get_type();
if (type->is_struct() || type->is_xception()) {
@ -626,7 +747,7 @@ string t_erl_generator::render_member_type(t_field* field) {
return type_name(type) + "()";
} else if (type->is_map()) {
if (maps_) {
return "#{}";
return "map()";
} else if (otp16_) {
return "dict()";
} else {
@ -719,6 +840,8 @@ void t_erl_generator::generate_erl_struct_member(ostream& out, t_field* tmember)
if (has_default_value(tmember))
out << " = " << render_member_value(tmember);
out << " :: " << render_member_type(tmember);
if (tmember->get_req() != t_field::T_REQUIRED)
out << " | 'undefined'";
}
bool t_erl_generator::has_default_value(t_field* field) {
@ -967,13 +1090,6 @@ void t_erl_generator::export_string(string name, int num) {
export_lines_ << name << "/" << num;
}
void t_erl_generator::export_types_function(t_function* tfunction, string prefix) {
export_types_string(prefix + tfunction->get_name(),
1 // This
+ ((tfunction->get_arglist())->get_members()).size());
}
void t_erl_generator::export_types_string(string name, int num) {
if (export_types_lines_first_) {
export_types_lines_first_ = false;
@ -984,10 +1100,13 @@ void t_erl_generator::export_types_string(string name, int num) {
}
void t_erl_generator::export_function(t_function* tfunction, string prefix) {
t_struct::members_type::size_type num = tfunction->get_arglist()->get_members().size();
if (num > static_cast<t_struct::members_type::size_type>(std::numeric_limits<int>().max())) {
throw "integer overflow in t_erl_generator::export_function, name " + tfunction->get_name();
}
export_string(prefix + tfunction->get_name(),
1 // This
+ ((tfunction->get_arglist())->get_members()).size());
+ static_cast<int>(num));
}
/**
@ -1012,19 +1131,14 @@ string t_erl_generator::argument_list(t_struct* tstruct) {
}
string t_erl_generator::type_name(t_type* ttype) {
string prefix = "";
string erl_namespace = ttype->get_program()->get_namespace("erl");
if (erl_namespace.length() > 0) {
prefix = erl_namespace + ".";
string prefix = ttype->get_program()->get_namespace("erl");
size_t prefix_length = prefix.length();
if (prefix_length > 0 && prefix[prefix_length - 1] != '_') {
prefix += '.';
}
string name = ttype->get_name();
if (ttype->is_struct() || ttype->is_xception() || ttype->is_service()) {
name = ttype->get_name();
}
return atomify(prefix + name);
}

View file

@ -76,6 +76,77 @@ void t_generator::generate_program() {
close_generator();
}
std::set<std::string> t_generator::lang_keywords() const {
std::string keywords[] = { "BEGIN", "END", "__CLASS__", "__DIR__", "__FILE__", "__FUNCTION__",
"__LINE__", "__METHOD__", "__NAMESPACE__", "abstract", "alias", "and", "args", "as",
"assert", "begin", "break", "case", "catch", "class", "clone", "continue", "declare",
"def", "default", "del", "delete", "do", "dynamic", "elif", "else", "elseif", "elsif",
"end", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "ensure",
"except", "exec", "finally", "float", "for", "foreach", "from", "function", "global",
"goto", "if", "implements", "import", "in", "inline", "instanceof", "interface", "is",
"lambda", "module", "native", "new", "next", "nil", "not", "or", "package", "pass",
"public", "print", "private", "protected", "raise", "redo", "rescue", "retry", "register",
"return", "self", "sizeof", "static", "super", "switch", "synchronized", "then", "this",
"throw", "transient", "try", "undef", "unless", "unsigned", "until", "use", "var",
"virtual", "volatile", "when", "while", "with", "xor", "yield" };
return std::set<std::string>(keywords, keywords + sizeof(keywords)/sizeof(keywords[0]) );
}
void t_generator::validate_input() const {
validate(program_->get_enums());
validate(program_->get_typedefs());
validate(program_->get_objects());
validate(program_->get_consts());
validate(program_->get_services());
}
template <typename T>
void t_generator::validate(const vector<T>& list) const{
typename vector<T>::const_iterator it;
for(it=list.begin(); it != list.end(); ++it) {
validate(*it);
}
}
void t_generator::validate(t_function const* f) const {
validate_id(f->get_name());
validate(f->get_arglist());
validate(f->get_xceptions());
}
void t_generator::validate(t_service const* s) const {
validate_id(s->get_name());
validate(s->get_functions());
}
void t_generator::validate(t_enum const* en) const {
validate_id(en->get_name());
validate(en->get_constants());
}
void t_generator::validate(t_struct const* s) const {
validate_id(s->get_name());
validate(s->get_members());
}
void t_generator::validate(t_enum_value const* en_val) const {
validate_id(en_val->get_name());
}
void t_generator::validate(t_typedef const* td) const {
validate_id(td->get_name());
}
void t_generator::validate(t_const const* c) const {
validate_id(c->get_name());
}
void t_generator::validate(t_field const* f) const {
validate_id(f->get_name());
}
void t_generator::validate_id(const string& id) const {
if (keywords_.find(id) != keywords_.end()) {
failure("Cannot use reserved language keyword: \"%s\"", id.c_str());
}
}
string t_generator::escape_string(const string& in) const {
string result = "";
for (string::const_iterator it = in.begin(); it < in.end(); it++) {
@ -101,21 +172,22 @@ void t_generator::generate_docstring_comment(ostream& out,
const string& line_prefix,
const string& contents,
const string& comment_end) {
if (comment_start != "")
if (!comment_start.empty())
indent(out) << comment_start;
stringstream docs(contents, ios_base::in);
while (!(docs.eof() || docs.fail())) {
char line[1024];
docs.getline(line, 1024);
// Just prnt a newline when the line & prefix are empty.
if (strlen(line) == 0 && line_prefix == "" && !docs.eof()) {
out << std::endl;
} else if (strlen(line) > 0 || !docs.eof()) { // skip the empty last line
if (strlen(line) > 0) {
indent(out) << line_prefix << line << std::endl;
} else if (line_prefix.empty()){
out << std::endl;
} else if(!docs.eof()) {
indent(out) << line_prefix << std::endl;
}
}
if (comment_end != "")
if (!comment_end.empty())
indent(out) << comment_end;
}

View file

@ -19,12 +19,17 @@
#ifndef T_GENERATOR_H
#define T_GENERATOR_H
#define MSC_2015_VER 1900
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <limits>
#include <sstream>
#include "thrift/common.h"
#include "thrift/logging.h"
#include "thrift/version.h"
#include "thrift/generate/t_generator_registry.h"
#include "thrift/parse/t_program.h"
@ -37,7 +42,8 @@
*/
class t_generator {
public:
t_generator(t_program* program) {
t_generator(t_program* program)
: keywords_(lang_keywords()){
tmp_ = 0;
indent_ = 0;
program_ = program;
@ -91,9 +97,35 @@ public:
return escape_string(constval->get_string());
}
protected:
/**
* Optional methods that may be imlemented by subclasses to take necessary
* Check if all identifiers are valid for the target language
*/
virtual void validate_input() const;
protected:
virtual std::set<std::string> lang_keywords() const;
/**
* A list of reserved words that cannot be used as identifiers.
*/
const std::set<std::string> keywords_;
virtual void validate_id(const std::string& id) const;
virtual void validate(t_enum const* en) const;
virtual void validate(t_enum_value const* en_val) const;
virtual void validate(t_typedef const* td) const;
virtual void validate(t_const const* c) const;
virtual void validate(t_service const* s) const;
virtual void validate(t_struct const* c) const;
virtual void validate(t_field const* f) const;
virtual void validate(t_function const* f) const;
template <typename T>
void validate(const std::vector<T>& list) const;
/**
* Optional methods that may be implemented by subclasses to take necessary
* steps at the beginning or end of code generation.
*/
@ -172,6 +204,17 @@ protected:
void indent_down() { --indent_; }
/**
* Indentation validation helper
*/
int indent_count() { return indent_; }
void indent_validate( int expected, const char * func_name) {
if (indent_ != expected) {
pverbose("Wrong indent count in %s: difference = %i \n", func_name, (expected - indent_));
}
}
/**
* Indentation print function
*/
@ -212,6 +255,7 @@ protected:
}
return in;
}
/**
* Transforms a camel case string to an equivalent one separated by underscores
* e.g. aMultiWord -> a_multi_word
@ -230,6 +274,7 @@ protected:
}
return in;
}
/**
* Transforms a string with words separated by underscores to a camel case equivalent
* e.g. a_multi_word -> aMultiWord
@ -256,6 +301,30 @@ protected:
return out.str();
}
const std::string emit_double_as_string(const double value) {
std::stringstream double_output_stream;
// sets the maximum precision: http://en.cppreference.com/w/cpp/io/manip/setprecision
// sets the output format to fixed: http://en.cppreference.com/w/cpp/io/manip/fixed (not in scientific notation)
double_output_stream << std::setprecision(std::numeric_limits<double>::digits10 + 1);
#ifdef _MSC_VER
// strtod is broken in MSVC compilers older than 2015, so std::fixed fails to format a double literal.
// more details: https://blogs.msdn.microsoft.com/vcblog/2014/06/18/
// c-runtime-crt-features-fixes-and-breaking-changes-in-visual-studio-14-ctp1/
// and
// http://www.exploringbinary.com/visual-c-plus-plus-strtod-still-broken/
#if _MSC_VER >= MSC_2015_VER
double_output_stream << std::fixed;
#endif
#else
double_output_stream << std::fixed;
#endif
double_output_stream << value;
return double_output_stream.str();
}
public:
/**
* Get the true type behind a series of typedefs.
@ -307,4 +376,77 @@ private:
int tmp_;
};
template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
class template_ofstream_with_content_based_conditional_update : public std::ostringstream {
public:
template_ofstream_with_content_based_conditional_update(): contents_written(false) {}
template_ofstream_with_content_based_conditional_update(std::string const& output_file_path_)
: output_file_path(output_file_path_), contents_written(false) {}
~template_ofstream_with_content_based_conditional_update() {
if (!contents_written) {
close();
}
}
void open(std::string const& output_file_path_) {
output_file_path = output_file_path_;
clear_buf();
contents_written = false;
}
void close() {
if (contents_written || output_file_path == "")
return;
if (!is_readable(output_file_path)) {
dump();
return;
}
std::ifstream old_file;
old_file.exceptions(old_file.exceptions() | std::ifstream::badbit | std::ifstream::failbit);
old_file.open(output_file_path.c_str(), std::ios::in);
if (old_file) {
std::string const old_file_contents(static_cast<std::ostringstream const&>(std::ostringstream() << old_file.rdbuf()).str());
old_file.close();
if (old_file_contents != str()) {
dump();
}
}
}
protected:
void dump() {
std::ofstream out_file;
out_file.exceptions(out_file.exceptions() | std::ofstream::badbit | std::ofstream::failbit);
try {
out_file.open(output_file_path.c_str(), std::ios::out);
}
catch (const std::ios_base::failure& e) {
::failure("failed to write the output to the file '%s', details: '%s'", output_file_path.c_str(), e.what());
}
out_file << str();
out_file.close();
clear_buf();
contents_written = true;
}
void clear_buf() {
str(std::string());
}
static bool is_readable(std::string const& file_name) {
return static_cast<bool>(std::ifstream(file_name.c_str()));
}
private:
std::string output_file_path;
bool contents_written;
};
typedef template_ofstream_with_content_based_conditional_update<char> ofstream_with_content_based_conditional_update;
#endif

File diff suppressed because it is too large Load diff

View file

@ -87,7 +87,7 @@ protected:
void print_const_value(t_type* type, t_const_value* tvalue);
private:
std::ofstream f_out_;
ofstream_with_content_based_conditional_update f_out_;
std::list<string> edges;
bool exception_arrows;
};
@ -225,7 +225,7 @@ void t_gv_generator::print_type(t_type* ttype, string struct_field_ref) {
f_out_ << "\\>";
}
} else if (ttype->is_base_type()) {
f_out_ << (((t_base_type*)ttype)->is_binary() ? "binary" : ttype->get_name());
f_out_ << (ttype->is_binary() ? "binary" : ttype->get_name());
} else {
f_out_ << ttype->get_name();
edges.push_back(struct_field_ref + " -> " + ttype->get_name());
@ -249,8 +249,8 @@ void t_gv_generator::print_const_value(t_type* type, t_const_value* tvalue) {
break;
case t_const_value::CV_MAP: {
f_out_ << "\\{ ";
map<t_const_value*, t_const_value*> map_elems = tvalue->get_map();
map<t_const_value*, t_const_value*>::iterator map_iter;
map<t_const_value*, t_const_value*, t_const_value::value_compare> map_elems = tvalue->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::iterator map_iter;
for (map_iter = map_elems.begin(); map_iter != map_elems.end(); map_iter++) {
if (!first) {
f_out_ << ", ";

View file

@ -31,7 +31,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -89,13 +89,13 @@ public:
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
void print_const_value(std::ofstream& out,
void print_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value,
bool in_static,
bool defval = false);
std::string render_const_value(ofstream& out,
std::string render_const_value(ostream& out,
std::string name,
t_type* type,
t_const_value* value);
@ -106,18 +106,18 @@ public:
void generate_haxe_struct(t_struct* tstruct, bool is_exception, bool is_result = false);
void generate_haxe_struct_definition(std::ofstream& out,
void generate_haxe_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool is_result = false);
// removed -- equality,compare_to
void generate_haxe_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_haxe_validator(std::ofstream& out, t_struct* tstruct);
void generate_haxe_struct_result_writer(std::ofstream& out, t_struct* tstruct);
void generate_haxe_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_haxe_struct_tostring(std::ofstream& out, t_struct* tstruct);
void generate_haxe_meta_data_map(std::ofstream& out, t_struct* tstruct);
void generate_field_value_meta_data(std::ofstream& out, t_type* type);
void generate_haxe_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_haxe_validator(std::ostream& out, t_struct* tstruct);
void generate_haxe_struct_result_writer(std::ostream& out, t_struct* tstruct);
void generate_haxe_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_haxe_struct_tostring(std::ostream& out, t_struct* tstruct);
void generate_haxe_meta_data_map(std::ostream& out, t_struct* tstruct);
void generate_field_value_meta_data(std::ostream& out, t_type* type);
std::string get_haxe_type_string(t_type* type);
void generate_reflection_setters(std::ostringstream& out,
t_type* type,
@ -127,15 +127,15 @@ public:
t_type* type,
std::string field_name,
std::string cap_name);
void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
void generate_property_getters_setters(std::ofstream& out, t_struct* tstruct);
void generate_generic_field_getters_setters(std::ostream& out, t_struct* tstruct);
void generate_generic_isset_method(std::ostream& out, t_struct* tstruct);
void generate_property_getters_setters(std::ostream& out, t_struct* tstruct);
void generate_function_helpers(t_function* tfunction);
std::string get_cap_name(std::string name);
std::string generate_isset_check(t_field* field);
std::string generate_isset_check(std::string field);
void generate_isset_set(ofstream& out, t_field* field);
void generate_isset_set(ostream& out, t_field* field);
// removed std::string isset_field_id(t_field* field);
void generate_service_interface(t_service* tservice);
@ -149,30 +149,30 @@ public:
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string iter,
std::string map);
void generate_haxe_doc(std::ofstream& out, t_doc* tdoc);
void generate_haxe_doc(std::ofstream& out, t_function* tdoc);
void generate_haxe_doc(std::ostream& out, t_doc* tdoc);
void generate_haxe_doc(std::ostream& out, t_function* tdoc);
void generate_rtti_decoration(std::ofstream& out);
void generate_macro_decoration(std::ofstream& out);
void generate_rtti_decoration(std::ostream& out);
void generate_macro_decoration(std::ostream& out);
/**
* Helper rendering functions
@ -229,7 +229,7 @@ private:
*/
std::string package_name_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_service_;
std::string package_dir_;
};
@ -386,7 +386,7 @@ void t_haxe_generator::generate_typedef(t_typedef* ttypedef) {
void t_haxe_generator::generate_enum(t_enum* tenum) {
// Make output file
string f_enum_name = package_dir_ + "/" + get_cap_name(tenum->get_name()) + ".hx";
ofstream f_enum;
ofstream_with_content_based_conditional_update f_enum;
f_enum.open(f_enum_name.c_str());
// Comment and package it
@ -448,7 +448,7 @@ void t_haxe_generator::generate_consts(std::vector<t_const*> consts) {
}
string f_consts_name = package_dir_ + "/" + get_cap_name(program_name_) + "Constants.hx";
ofstream f_consts;
ofstream_with_content_based_conditional_update f_consts;
f_consts.open(f_consts_name.c_str());
// Print header
@ -475,7 +475,7 @@ void t_haxe_generator::generate_consts(std::vector<t_const*> consts) {
f_consts.close();
}
void t_haxe_generator::print_const_value(std::ofstream& out,
void t_haxe_generator::print_const_value(std::ostream& out,
string name,
t_type* type,
t_const_value* value,
@ -503,8 +503,8 @@ void t_haxe_generator::print_const_value(std::ofstream& out,
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();"
<< endl;
if (!in_static) {
@ -548,8 +548,8 @@ void t_haxe_generator::print_const_value(std::ofstream& out,
}
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
@ -599,7 +599,7 @@ void t_haxe_generator::print_const_value(std::ofstream& out,
}
}
string t_haxe_generator::render_const_value(ofstream& out,
string t_haxe_generator::render_const_value(ostream& out,
string name,
t_type* type,
t_const_value* value) {
@ -676,7 +676,7 @@ void t_haxe_generator::generate_xception(t_struct* txception) {
void t_haxe_generator::generate_haxe_struct(t_struct* tstruct, bool is_exception, bool is_result) {
// Make output file
string f_struct_name = package_dir_ + "/" + get_cap_name(tstruct->get_name()) + ".hx";
ofstream f_struct;
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
f_struct << autogen_comment() << haxe_package() << ";" << endl;
@ -703,7 +703,7 @@ void t_haxe_generator::generate_haxe_struct(t_struct* tstruct, bool is_exception
* @param in_class If inside a class, needs to be static class
* @param is_result If this is a result it needs a different writer
*/
void t_haxe_generator::generate_haxe_struct_definition(ofstream& out,
void t_haxe_generator::generate_haxe_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception,
bool is_result) {
@ -817,7 +817,7 @@ void t_haxe_generator::generate_haxe_struct_definition(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_reader(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_haxe_struct_reader(ostream& out, t_struct* tstruct) {
out << indent() << "public function read( iprot : TProtocol) : Void {" << endl;
indent_up();
@ -910,7 +910,7 @@ void t_haxe_generator::generate_haxe_struct_reader(ofstream& out, t_struct* tstr
// generates haxe method to perform various checks
// (e.g. check that all required fields are set)
void t_haxe_generator::generate_haxe_validator(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_haxe_validator(ostream& out, t_struct* tstruct) {
indent(out) << "public function validate() : Void {" << endl;
indent_up();
@ -961,7 +961,7 @@ void t_haxe_generator::generate_haxe_validator(ofstream& out, t_struct* tstruct)
*
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_writer(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_haxe_struct_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public function write(oprot:TProtocol) : Void {" << endl;
indent_up();
@ -1031,7 +1031,7 @@ void t_haxe_generator::generate_haxe_struct_writer(ofstream& out, t_struct* tstr
*
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_result_writer(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_haxe_struct_result_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public function write(oprot:TProtocol) : Void {" << endl;
indent_up();
@ -1116,7 +1116,7 @@ void t_haxe_generator::generate_reflection_setters(ostringstream& out,
indent_down();
}
void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out,
void t_haxe_generator::generate_generic_field_getters_setters(std::ostream& out,
t_struct* tstruct) {
std::ostringstream getter_stream;
@ -1174,7 +1174,7 @@ void t_haxe_generator::generate_generic_field_getters_setters(std::ofstream& out
}
// Creates a generic isSet method that takes the field number as argument
void t_haxe_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_generic_isset_method(std::ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -1210,7 +1210,7 @@ void t_haxe_generator::generate_generic_isset_method(std::ofstream& out, t_struc
*
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_property_getters_setters(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_property_getters_setters(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -1272,7 +1272,7 @@ void t_haxe_generator::generate_property_getters_setters(ofstream& out, t_struct
*
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_haxe_struct_tostring(ostream& out, t_struct* tstruct) {
out << indent() << "public "
<< "function toString() : String {" << endl;
indent_up();
@ -1304,7 +1304,7 @@ void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out, t_struct* ts
indent_up();
}
if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
if (field->get_type()->is_binary()) {
indent(out) << " ret += \"BINARY\";" << endl;
} else if (field->get_type()->is_enum()) {
indent(out) << "var " << field->get_name()
@ -1346,7 +1346,7 @@ void t_haxe_generator::generate_haxe_struct_tostring(ofstream& out, t_struct* ts
*
* @param tstruct The struct definition
*/
void t_haxe_generator::generate_haxe_meta_data_map(ofstream& out, t_struct* tstruct) {
void t_haxe_generator::generate_haxe_meta_data_map(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -1434,7 +1434,7 @@ std::string t_haxe_generator::get_haxe_type_string(t_type* type) {
}
}
void t_haxe_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
void t_haxe_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
out << endl;
indent_up();
indent_up();
@ -2176,7 +2176,7 @@ void t_haxe_generator::generate_process_function(t_service* tservice, t_function
* @param tfield The field
* @param prefix The variable name or container for this field
*/
void t_haxe_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_haxe_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
if (type->is_void()) {
@ -2200,7 +2200,7 @@ void t_haxe_generator::generate_deserialize_field(ofstream& out, t_field* tfield
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "readBinary();";
} else {
out << "readString();";
@ -2241,7 +2241,7 @@ void t_haxe_generator::generate_deserialize_field(ofstream& out, t_field* tfield
/**
* Generates an unserializer for a struct, invokes read()
*/
void t_haxe_generator::generate_deserialize_struct(ofstream& out,
void t_haxe_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
out << indent() << prefix << " = new " << get_cap_name(type_name(tstruct)) << "();" << endl
@ -2251,7 +2251,7 @@ void t_haxe_generator::generate_deserialize_struct(ofstream& out,
/**
* Deserializes a container by reading its size and then iterating
*/
void t_haxe_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_haxe_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
string obj;
@ -2309,7 +2309,7 @@ void t_haxe_generator::generate_deserialize_container(ofstream& out, t_type* tty
/**
* Generates code to deserialize a map
*/
void t_haxe_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
void t_haxe_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) {
string key = tmp("_key");
string val = tmp("_val");
t_field fkey(tmap->get_key_type(), key);
@ -2327,7 +2327,7 @@ void t_haxe_generator::generate_deserialize_map_element(ofstream& out, t_map* tm
/**
* Deserializes a set element
*/
void t_haxe_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
void t_haxe_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
@ -2341,7 +2341,7 @@ void t_haxe_generator::generate_deserialize_set_element(ofstream& out, t_set* ts
/**
* Deserializes a list element
*/
void t_haxe_generator::generate_deserialize_list_element(ofstream& out,
void t_haxe_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
string elem = tmp("_elem");
@ -2360,7 +2360,7 @@ void t_haxe_generator::generate_deserialize_list_element(ofstream& out,
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_haxe_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_haxe_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
// Do nothing for void types
@ -2384,7 +2384,7 @@ void t_haxe_generator::generate_serialize_field(ofstream& out, t_field* tfield,
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "writeBinary(" << name << ");";
} else {
out << "writeString(" << name << ");";
@ -2429,7 +2429,7 @@ void t_haxe_generator::generate_serialize_field(ofstream& out, t_field* tfield,
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_haxe_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_haxe_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
out << indent() << prefix << ".write(oprot);" << endl;
}
@ -2440,7 +2440,7 @@ void t_haxe_generator::generate_serialize_struct(ofstream& out, t_struct* tstruc
* @param ttype The type of container
* @param prefix String prefix for fields
*/
void t_haxe_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_haxe_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
if (ttype->is_map()) {
@ -2498,7 +2498,7 @@ void t_haxe_generator::generate_serialize_container(ofstream& out, t_type* ttype
/**
* Serializes the members of a map.
*/
void t_haxe_generator::generate_serialize_map_element(ofstream& out,
void t_haxe_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string iter,
string map) {
@ -2511,7 +2511,7 @@ void t_haxe_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_haxe_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_haxe_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2519,7 +2519,7 @@ void t_haxe_generator::generate_serialize_set_element(ofstream& out, t_set* tset
/**
* Serializes the members of a list.
*/
void t_haxe_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
void t_haxe_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2553,9 +2553,10 @@ string t_haxe_generator::type_name(t_type* ttype, bool in_container, bool in_ini
t_base_type::t_base tbase = ((t_base_type*)tkey)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
if (!(((t_base_type*)tkey)->is_binary())) {
if (!(tkey->is_binary())) {
return "StringMap< " + type_name(tval) + ">";
}
break; // default to ObjectMap<>
case t_base_type::TYPE_I8:
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
@ -2573,14 +2574,15 @@ string t_haxe_generator::type_name(t_type* ttype, bool in_container, bool in_ini
}
if (ttype->is_set()) {
t_type* tkey = get_true_type(((t_list*)ttype)->get_elem_type());
t_type* tkey = get_true_type(((t_set*)ttype)->get_elem_type());
if (tkey->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)tkey)->get_base();
switch (tbase) {
case t_base_type::TYPE_STRING:
if (!(((t_base_type*)tkey)->is_binary())) {
if (!(tkey->is_binary())) {
return "StringSet";
}
break; // default to ObjectSet
case t_base_type::TYPE_I8:
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
@ -2659,7 +2661,7 @@ string t_haxe_generator::declare_field(t_field* tfield, bool init) {
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
if (ttype->is_base_type() && tfield->get_value() != NULL) {
ofstream dummy;
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
@ -2902,7 +2904,7 @@ string t_haxe_generator::constant_name(string name) {
/**
* Enables RTTI for a class or interface
*/
void t_haxe_generator::generate_rtti_decoration(ofstream& out) {
void t_haxe_generator::generate_rtti_decoration(ostream& out) {
if (rtti_) {
out << "@:rtti" << endl;
}
@ -2911,7 +2913,7 @@ void t_haxe_generator::generate_rtti_decoration(ofstream& out) {
/**
* Adds build macros to a class or interface
*/
void t_haxe_generator::generate_macro_decoration(ofstream& out) {
void t_haxe_generator::generate_macro_decoration(ostream& out) {
if (!buildmacro_.empty()) {
out << "#if ! macro" << endl;
out << "@:build( " << buildmacro_ << ")" << endl; // current class/interface
@ -2923,7 +2925,7 @@ void t_haxe_generator::generate_macro_decoration(ofstream& out) {
/**
* Emits a haxeDoc comment if the provided object has a doc in Thrift
*/
void t_haxe_generator::generate_haxe_doc(ofstream& out, t_doc* tdoc) {
void t_haxe_generator::generate_haxe_doc(ostream& out, t_doc* tdoc) {
if (tdoc->has_doc()) {
generate_docstring_comment(out, "/**\n", " * ", tdoc->get_doc(), " */\n");
}
@ -2932,7 +2934,7 @@ void t_haxe_generator::generate_haxe_doc(ofstream& out, t_doc* tdoc) {
/**
* Emits a haxeDoc comment if the provided function object has a doc in Thrift
*/
void t_haxe_generator::generate_haxe_doc(ofstream& out, t_function* tfunction) {
void t_haxe_generator::generate_haxe_doc(ostream& out, t_function* tfunction) {
if (tfunction->has_doc()) {
stringstream ss;
ss << tfunction->get_doc();
@ -2957,7 +2959,7 @@ std::string t_haxe_generator::generate_isset_check(std::string field_name) {
return "is" + get_cap_name("set") + get_cap_name(field_name) + "()";
}
void t_haxe_generator::generate_isset_set(ofstream& out, t_field* field) {
void t_haxe_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
indent(out) << "this.__isset_" << field->get_name() << " = true;" << endl;
}

View file

@ -33,7 +33,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -87,22 +87,22 @@ public:
void generate_hs_struct(t_struct* tstruct, bool is_exception);
void generate_hs_struct_definition(ofstream& out,
void generate_hs_struct_definition(ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool helper = false);
void generate_hs_struct_reader(ofstream& out, t_struct* tstruct);
void generate_hs_struct_reader(ostream& out, t_struct* tstruct);
void generate_hs_struct_writer(ofstream& out, t_struct* tstruct);
void generate_hs_struct_writer(ostream& out, t_struct* tstruct);
void generate_hs_struct_arbitrary(ofstream& out, t_struct* tstruct);
void generate_hs_struct_arbitrary(ostream& out, t_struct* tstruct);
void generate_hs_function_helpers(t_function* tfunction);
void generate_hs_typemap(ofstream& out, t_struct* tstruct);
void generate_hs_typemap(ostream& out, t_struct* tstruct);
void generate_hs_default(ofstream& out, t_struct* tstruct);
void generate_hs_default(ostream& out, t_struct* tstruct);
/**
* Service-level generation functions
@ -118,29 +118,29 @@ public:
* Serialization constructs
*/
void generate_deserialize_field(ofstream& out, t_field* tfield, string prefix);
void generate_deserialize_field(ostream& out, t_field* tfield, string prefix);
void generate_deserialize_struct(ofstream& out, t_struct* tstruct, string name = "");
void generate_deserialize_struct(ostream& out, t_struct* tstruct, string name = "");
void generate_deserialize_container(ofstream& out, t_type* ttype, string arg = "");
void generate_deserialize_container(ostream& out, t_type* ttype, string arg = "");
void generate_deserialize_set_element(ofstream& out, t_set* tset);
void generate_deserialize_set_element(ostream& out, t_set* tset);
void generate_deserialize_list_element(ofstream& out, t_list* tlist, string prefix = "");
void generate_deserialize_list_element(ostream& out, t_list* tlist, string prefix = "");
void generate_deserialize_type(ofstream& out, t_type* type, string arg = "");
void generate_deserialize_type(ostream& out, t_type* type, string arg = "");
void generate_serialize_type(ofstream& out, t_type* type, string name = "");
void generate_serialize_type(ostream& out, t_type* type, string name = "");
void generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix = "");
void generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix = "");
void generate_serialize_container(ofstream& out, t_type* ttype, string prefix = "");
void generate_serialize_container(ostream& out, t_type* ttype, string prefix = "");
void generate_serialize_map_element(ofstream& out, t_map* tmap, string kiter, string viter);
void generate_serialize_map_element(ostream& out, t_map* tmap, string kiter, string viter);
void generate_serialize_set_element(ofstream& out, t_set* tmap, string iter);
void generate_serialize_set_element(ostream& out, t_set* tmap, string iter);
void generate_serialize_list_element(ofstream& out, t_list* tlist, string iter);
void generate_serialize_list_element(ostream& out, t_list* tlist, string iter);
/**
* Helper rendering functions
@ -170,11 +170,11 @@ public:
string render_hs_type_for_function_name(t_type* type);
private:
ofstream f_types_;
ofstream f_consts_;
ofstream f_service_;
ofstream f_iface_;
ofstream f_client_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_consts_;
ofstream_with_content_based_conditional_update f_service_;
ofstream_with_content_based_conditional_update f_iface_;
ofstream_with_content_based_conditional_update f_client_;
};
/**
@ -424,10 +424,10 @@ string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
out << "default_" << cname << "{";
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
const map<t_const_value*, t_const_value*>& val = value->get_map();
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
bool first = true;
for (map<t_const_value*, t_const_value*>::const_iterator v_iter = val.begin();
for (map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter = val.begin();
v_iter != val.end();
++v_iter) {
t_field* field = NULL;
@ -458,8 +458,8 @@ string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
out << "(Map.fromList [";
@ -530,7 +530,7 @@ void t_hs_generator::generate_hs_struct(t_struct* tstruct, bool is_exception) {
*
* @param tstruct The struct definition
*/
void t_hs_generator::generate_hs_struct_definition(ofstream& out,
void t_hs_generator::generate_hs_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception,
bool helper) {
@ -586,7 +586,7 @@ void t_hs_generator::generate_hs_struct_definition(ofstream& out,
generate_hs_default(out, tstruct);
}
void t_hs_generator::generate_hs_struct_arbitrary(ofstream& out, t_struct* tstruct) {
void t_hs_generator::generate_hs_struct_arbitrary(ostream& out, t_struct* tstruct) {
string tname = type_name(tstruct);
string name = tstruct->get_name();
const vector<t_field*>& members = tstruct->get_members();
@ -652,7 +652,7 @@ void t_hs_generator::generate_hs_struct_arbitrary(ofstream& out, t_struct* tstru
/**
* Generates the read method for a struct
*/
void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct) {
void t_hs_generator::generate_hs_struct_reader(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -711,18 +711,18 @@ void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct)
string tmap = type_name(tstruct, "typemap_");
indent(out) << "to_" << sname << " _ = P.error \"not a struct\"" << endl;
indent(out) << "read_" << sname << " :: (T.Transport t, T.Protocol p) => p t -> P.IO " << sname
indent(out) << "read_" << sname << " :: T.Protocol p => p -> P.IO " << sname
<< endl;
indent(out) << "read_" << sname << " iprot = to_" << sname;
out << " <$> T.readVal iprot (T.T_STRUCT " << tmap << ")" << endl;
indent(out) << "decode_" << sname
<< " :: (T.Protocol p, T.Transport t) => p t -> LBS.ByteString -> " << sname << endl;
<< " :: T.StatelessProtocol p => p -> LBS.ByteString -> " << sname << endl;
indent(out) << "decode_" << sname << " iprot bs = to_" << sname << " $ ";
out << "T.deserializeVal iprot (T.T_STRUCT " << tmap << ") bs" << endl;
}
void t_hs_generator::generate_hs_struct_writer(ofstream& out, t_struct* tstruct) {
void t_hs_generator::generate_hs_struct_writer(ostream& out, t_struct* tstruct) {
string name = type_name(tstruct);
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
@ -818,13 +818,13 @@ void t_hs_generator::generate_hs_struct_writer(ofstream& out, t_struct* tstruct)
indent_down();
// write
indent(out) << "write_" << name << " :: (T.Protocol p, T.Transport t) => p t -> " << name
indent(out) << "write_" << name << " :: T.Protocol p => p -> " << name
<< " -> P.IO ()" << endl;
indent(out) << "write_" << name << " oprot record = T.writeVal oprot $ from_";
out << name << " record" << endl;
// encode
indent(out) << "encode_" << name << " :: (T.Protocol p, T.Transport t) => p t -> " << name
indent(out) << "encode_" << name << " :: T.StatelessProtocol p => p -> " << name
<< " -> LBS.ByteString" << endl;
indent(out) << "encode_" << name << " oprot record = T.serializeVal oprot $ ";
out << "from_" << name << " record" << endl;
@ -906,7 +906,7 @@ void t_hs_generator::generate_hs_function_helpers(t_function* tfunction) {
* Generate the map from field names to (type, id)
* @param tstruct the Struct
*/
void t_hs_generator::generate_hs_typemap(ofstream& out, t_struct* tstruct) {
void t_hs_generator::generate_hs_typemap(ostream& out, t_struct* tstruct) {
string name = type_name(tstruct);
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
@ -932,7 +932,7 @@ void t_hs_generator::generate_hs_typemap(ofstream& out, t_struct* tstruct) {
* generate the struct with default values filled in
* @param tstruct the Struct
*/
void t_hs_generator::generate_hs_default(ofstream& out, t_struct* tstruct) {
void t_hs_generator::generate_hs_default(ostream& out, t_struct* tstruct) {
string name = type_name(tstruct);
string fname = type_name(tstruct, "default_");
const vector<t_field*>& fields = tstruct->get_sorted_members();
@ -1085,8 +1085,9 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
// Serialize the request header
string fname = (*f_iter)->get_name();
string msgType = (*f_iter)->is_oneway() ? "T.M_ONEWAY" : "T.M_CALL";
indent(f_client_) << "T.writeMessageBegin op (\"" << fname << "\", " << msgType << ", seqn)"
indent(f_client_) << "T.writeMessage op (\"" << fname << "\", " << msgType << ", seqn) $"
<< endl;
indent_up();
indent(f_client_) << "write_" << argsname << " op (" << argsname << "{";
bool first = true;
@ -1102,10 +1103,7 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
first = false;
}
f_client_ << "})" << endl;
indent(f_client_) << "T.writeMessageEnd op" << endl;
// Write to the stream
indent(f_client_) << "T.tFlush (T.getTransport op)" << endl;
indent_down();
indent_down();
if (!(*f_iter)->is_oneway()) {
@ -1119,12 +1117,12 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
indent(f_client_) << funname << " ip = do" << endl;
indent_up();
indent(f_client_) << "(fname, mtype, rseqid) <- T.readMessageBegin ip" << endl;
indent(f_client_) << "T.readMessage ip $ \\(fname, mtype, rseqid) -> do" << endl;
indent_up();
indent(f_client_) << "M.when (mtype == T.M_EXCEPTION) $ do { exn <- T.readAppExn ip ; "
"T.readMessageEnd ip ; X.throw exn }" << endl;
"X.throw exn }" << endl;
indent(f_client_) << "res <- read_" << resultname << " ip" << endl;
indent(f_client_) << "T.readMessageEnd ip" << endl;
t_struct* xs = (*f_iter)->get_xceptions();
const vector<t_field*>& xceptions = xs->get_members();
@ -1142,6 +1140,7 @@ void t_hs_generator::generate_service_client(t_service* tservice) {
// Close function
indent_down();
indent_down();
}
}
@ -1180,11 +1179,11 @@ void t_hs_generator::generate_service_server(t_service* tservice) {
f_service_ << "do" << endl;
indent_up();
indent(f_service_) << "_ <- T.readVal iprot (T.T_STRUCT Map.empty)" << endl;
indent(f_service_) << "T.writeMessageBegin oprot (name,T.M_EXCEPTION,seqid)" << endl;
indent(f_service_) << "T.writeMessage oprot (name,T.M_EXCEPTION,seqid) $" << endl;
indent_up();
indent(f_service_) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN_METHOD (\"Unknown function "
"\" ++ LT.unpack name))" << endl;
indent(f_service_) << "T.writeMessageEnd oprot" << endl;
indent(f_service_) << "T.tFlush (T.getTransport oprot)" << endl;
indent_down();
indent_down();
}
@ -1194,9 +1193,8 @@ void t_hs_generator::generate_service_server(t_service* tservice) {
indent(f_service_) << "process handler (iprot, oprot) = do" << endl;
indent_up();
indent(f_service_) << "(name, typ, seqid) <- T.readMessageBegin iprot" << endl;
indent(f_service_) << "proc_ handler (iprot,oprot) (name,typ,seqid)" << endl;
indent(f_service_) << "T.readMessageEnd iprot" << endl;
indent(f_service_) << "T.readMessage iprot (" << endl;
indent(f_service_) << " proc_ handler (iprot,oprot))" << endl;
indent(f_service_) << "P.return P.True" << endl;
indent_down();
}
@ -1286,11 +1284,11 @@ void t_hs_generator::generate_process_function(t_service* tservice, t_function*
if (tfunction->is_oneway()) {
indent(f_service_) << "P.return ()";
} else {
indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name()
<< "\", T.M_REPLY, seqid)" << endl;
indent(f_service_) << "write_" << resultname << " oprot res" << endl;
indent(f_service_) << "T.writeMessageEnd oprot" << endl;
indent(f_service_) << "T.tFlush (T.getTransport oprot)";
indent(f_service_) << "T.writeMessage oprot (\"" << tfunction->get_name()
<< "\", T.M_REPLY, seqid) $" << endl;
indent_up();
indent(f_service_) << "write_" << resultname << " oprot res";
indent_down();
}
if (n > 0) {
f_service_ << ")";
@ -1307,11 +1305,11 @@ void t_hs_generator::generate_process_function(t_service* tservice, t_function*
indent(f_service_) << "let res = default_" << resultname << "{"
<< field_name(resultname, (*x_iter)->get_name()) << " = P.Just e}"
<< endl;
indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name()
<< "\", T.M_REPLY, seqid)" << endl;
indent(f_service_) << "write_" << resultname << " oprot res" << endl;
indent(f_service_) << "T.writeMessageEnd oprot" << endl;
indent(f_service_) << "T.tFlush (T.getTransport oprot)";
indent(f_service_) << "T.writeMessage oprot (\"" << tfunction->get_name()
<< "\", T.M_REPLY, seqid) $" << endl;
indent_up();
indent(f_service_) << "write_" << resultname << " oprot res";
indent_down();
} else {
indent(f_service_) << "P.return ()";
}
@ -1324,11 +1322,11 @@ void t_hs_generator::generate_process_function(t_service* tservice, t_function*
indent_up();
if (!tfunction->is_oneway()) {
indent(f_service_) << "T.writeMessageBegin oprot (\"" << tfunction->get_name()
<< "\", T.M_EXCEPTION, seqid)" << endl;
indent(f_service_) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN \"\")" << endl;
indent(f_service_) << "T.writeMessageEnd oprot" << endl;
indent(f_service_) << "T.tFlush (T.getTransport oprot)";
indent(f_service_) << "T.writeMessage oprot (\"" << tfunction->get_name()
<< "\", T.M_EXCEPTION, seqid) $" << endl;
indent_up();
indent(f_service_) << "T.writeAppExn oprot (T.AppExn T.AE_UNKNOWN \"\")";
indent_down();
} else {
indent(f_service_) << "P.return ()";
}
@ -1344,7 +1342,7 @@ void t_hs_generator::generate_process_function(t_service* tservice, t_function*
/**
* Deserializes a field of any type.
*/
void t_hs_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_hs_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
(void)prefix;
t_type* type = tfield->get_type();
generate_deserialize_type(out, type, prefix);
@ -1353,7 +1351,7 @@ void t_hs_generator::generate_deserialize_field(ofstream& out, t_field* tfield,
/**
* Deserializes a field of any type.
*/
void t_hs_generator::generate_deserialize_type(ofstream& out, t_type* type, string arg) {
void t_hs_generator::generate_deserialize_type(ostream& out, t_type* type, string arg) {
type = get_true_type(type);
string val = tmp("_val");
out << "(case " << arg << " of {" << type_to_constructor(type) << " " << val << " -> ";
@ -1369,11 +1367,11 @@ void t_hs_generator::generate_deserialize_type(ofstream& out, t_type* type, stri
} else if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
if (tbase == t_base_type::TYPE_STRING && !((t_base_type*)type)->is_binary()) {
if (tbase == t_base_type::TYPE_STRING && !type->is_binary()) {
out << "E.decodeUtf8 ";
}
out << val;
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
// Since wire type of binary is the same as string, we actually receive T.TString not
// T.TBinary
out << "; T.TString " << val << " -> " << val;
@ -1390,7 +1388,7 @@ void t_hs_generator::generate_deserialize_type(ofstream& out, t_type* type, stri
/**
* Generates an unserializer for a struct, calling read()
*/
void t_hs_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, string name) {
void t_hs_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct, string name) {
out << "(" << type_name(tstruct, "to_") << " (T.TStruct " << name << "))";
}
@ -1399,7 +1397,7 @@ void t_hs_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruc
* Serialize a container by writing out the header followed by
* data and then a footer.
*/
void t_hs_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string arg) {
void t_hs_generator::generate_deserialize_container(ostream& out, t_type* ttype, string arg) {
string val = tmp("_v");
// Declare variables, read header
@ -1415,12 +1413,12 @@ void t_hs_generator::generate_deserialize_container(ofstream& out, t_type* ttype
} else if (ttype->is_set()) {
out << "(Set.fromList $ P.map (\\" << val << " -> ";
generate_deserialize_type(out, ((t_map*)ttype)->get_key_type(), val);
generate_deserialize_type(out, ((t_set*)ttype)->get_elem_type(), val);
out << ") " << arg << ")";
} else if (ttype->is_list()) {
out << "(Vector.fromList $ P.map (\\" << val << " -> ";
generate_deserialize_type(out, ((t_map*)ttype)->get_key_type(), val);
generate_deserialize_type(out, ((t_list*)ttype)->get_elem_type(), val);
out << ") " << arg << ")";
}
}
@ -1431,7 +1429,7 @@ void t_hs_generator::generate_deserialize_container(ofstream& out, t_type* ttype
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_hs_generator::generate_serialize_type(ofstream& out, t_type* type, string name) {
void t_hs_generator::generate_serialize_type(ostream& out, t_type* type, string name) {
type = get_true_type(type);
// Do nothing for void types
@ -1448,7 +1446,7 @@ void t_hs_generator::generate_serialize_type(ofstream& out, t_type* type, string
if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
out << type_to_constructor(type) << " ";
if (tbase == t_base_type::TYPE_STRING && !((t_base_type*)type)->is_binary()) {
if (tbase == t_base_type::TYPE_STRING && !type->is_binary()) {
out << "$ E.encodeUtf8 ";
}
out << name;
@ -1469,11 +1467,11 @@ void t_hs_generator::generate_serialize_type(ofstream& out, t_type* type, string
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_hs_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_hs_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
out << type_name(tstruct, "from_") << " " << prefix;
}
void t_hs_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_hs_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
string k = tmp("_k");
string v = tmp("_v");
@ -1488,9 +1486,9 @@ void t_hs_generator::generate_serialize_container(ofstream& out, t_type* ttype,
out << ")) $ Map.toList " << prefix;
} else if (ttype->is_set()) {
out << "T.TSet " << type_to_enum(((t_list*)ttype)->get_elem_type());
out << "T.TSet " << type_to_enum(((t_set*)ttype)->get_elem_type());
out << " $ P.map (\\" << v << " -> ";
generate_serialize_type(out, ((t_list*)ttype)->get_elem_type(), v);
generate_serialize_type(out, ((t_set*)ttype)->get_elem_type(), v);
out << ") $ Set.toList " << prefix;
} else if (ttype->is_list()) {
@ -1550,7 +1548,7 @@ string t_hs_generator::type_to_enum(t_type* type) {
case t_base_type::TYPE_VOID:
return "T.T_VOID";
case t_base_type::TYPE_STRING:
return ((t_base_type*)type)->is_binary() ? "T.T_BINARY" : "T.T_STRING";
return type->is_binary() ? "T.T_BINARY" : "T.T_STRING";
case t_base_type::TYPE_BOOL:
return "T.T_BOOL";
case t_base_type::TYPE_I8:
@ -1577,7 +1575,7 @@ string t_hs_generator::type_to_enum(t_type* type) {
return "(T.T_MAP " + ktype + " " + vtype + ")";
} else if (type->is_set()) {
return "(T.T_SET " + type_to_enum(((t_list*)type)->get_elem_type()) + ")";
return "(T.T_SET " + type_to_enum(((t_set*)type)->get_elem_type()) + ")";
} else if (type->is_list()) {
return "(T.T_LIST " + type_to_enum(((t_list*)type)->get_elem_type()) + ")";
@ -1645,7 +1643,7 @@ string t_hs_generator::render_hs_type(t_type* type, bool needs_parens) {
case t_base_type::TYPE_VOID:
return "()";
case t_base_type::TYPE_STRING:
return (((t_base_type*)type)->is_binary() ? "LBS.ByteString" : "LT.Text");
return (type->is_binary() ? "LBS.ByteString" : "LT.Text");
case t_base_type::TYPE_BOOL:
return "P.Bool";
case t_base_type::TYPE_I8:
@ -1698,7 +1696,7 @@ string t_hs_generator::type_to_constructor(t_type* type) {
case t_base_type::TYPE_VOID:
throw "invalid type: T_VOID";
case t_base_type::TYPE_STRING:
return ((t_base_type*)type)->is_binary() ? "T.TBinary" : "T.TString";
return type->is_binary() ? "T.TBinary" : "T.TString";
case t_base_type::TYPE_BOOL:
return "T.TBool";
case t_base_type::TYPE_I8:

View file

@ -90,7 +90,7 @@ public:
std::string escape_html(std::string const& str);
std::string escape_html_tags(std::string const& str);
void generate_css();
void generate_css_content(std::ofstream& f_target);
void generate_css_content(std::ostream& f_target);
void generate_style_tag();
std::string make_file_link(std::string name);
bool is_utf8_sequence(std::string const& str, size_t firstpos);
@ -114,7 +114,7 @@ public:
void print_fn_args_doc(t_function* tfunction);
private:
std::ofstream f_out_;
ofstream_with_content_based_conditional_update f_out_;
std::string current_file_;
input_type input_type_;
std::map<std::string, int> allowed_markup;
@ -359,7 +359,7 @@ void t_html_generator::generate_css() {
}
}
void t_html_generator::generate_css_content(std::ofstream& f_target) {
void t_html_generator::generate_css_content(std::ostream& f_target) {
f_target << BOOTSTRAP_CSS() << endl;
f_target << "/* Auto-generated CSS for generated Thrift docs */" << endl;
f_target << "h3, h4 { margin-bottom: 6px; }" << endl;
@ -405,7 +405,7 @@ void t_html_generator::print_doc(t_doc* tdoc) {
if (unsafe_) {
f_out_ << tdoc->get_doc() << "<br/>";
} else {
f_out_ << escape_html(tdoc->get_doc()) << "<br/>";
f_out_ << "<pre>" << escape_html(tdoc->get_doc()) << "</pre><br/>";
}
}
}
@ -691,14 +691,14 @@ int t_html_generator::print_type(t_type* ttype) {
f_out_ << "&gt;";
}
} else if (ttype->is_base_type()) {
f_out_ << (((t_base_type*)ttype)->is_binary() ? "binary" : ttype->get_name());
f_out_ << (ttype->is_binary() ? "binary" : ttype->get_name());
len = ttype->get_name().size();
} else {
string prog_name = ttype->get_program()->get_name();
string type_name = ttype->get_name();
f_out_ << "<a href=\"" << make_file_link(prog_name + ".html") << "#";
if (ttype->is_typedef()) {
f_out_ << "Typedef_";
f_out_ << "Struct_";
} else if (ttype->is_struct() || ttype->is_xception()) {
f_out_ << "Struct_";
} else if (ttype->is_enum()) {
@ -777,8 +777,8 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
f_out_ << "{ ";
const vector<t_field*>& fields = ((t_struct*)truetype)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = tvalue->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = tvalue->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -800,8 +800,8 @@ void t_html_generator::print_const_value(t_type* type, t_const_value* tvalue) {
f_out_ << " }";
} else if (truetype->is_map()) {
f_out_ << "{ ";
map<t_const_value*, t_const_value*> map_elems = tvalue->get_map();
map<t_const_value*, t_const_value*>::iterator map_iter;
map<t_const_value*, t_const_value*, t_const_value::value_compare> map_elems = tvalue->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::iterator map_iter;
for (map_iter = map_elems.begin(); map_iter != map_elems.end(); map_iter++) {
if (!first) {
f_out_ << ", ";

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -81,13 +81,13 @@ public:
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
void print_const_value(std::ofstream& out,
void print_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value,
bool in_static,
bool defval = false);
std::string render_const_value(std::ofstream& out,
std::string render_const_value(std::ostream& out,
std::string name,
t_type* type,
t_const_value* value);
@ -98,20 +98,20 @@ public:
void generate_java_struct(t_struct* tstruct, bool is_exception);
void generate_java_struct_definition(std::ofstream& out,
void generate_java_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false,
bool in_class = false,
bool is_result = false);
void generate_java_struct_equality(std::ofstream& out, t_struct* tstruct);
void generate_java_struct_compare_to(std::ofstream& out, t_struct* tstruct);
void generate_java_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_java_validator(std::ofstream& out, t_struct* tstruct);
void generate_java_struct_result_writer(std::ofstream& out, t_struct* tstruct);
void generate_java_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_java_struct_tostring(std::ofstream& out, t_struct* tstruct);
void generate_java_struct_clear(std::ofstream& out, t_struct* tstruct);
void generate_field_value_meta_data(std::ofstream& out, t_type* type);
void generate_java_struct_equality(std::ostream& out, t_struct* tstruct);
void generate_java_struct_compare_to(std::ostream& out, t_struct* tstruct);
void generate_java_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_java_validator(std::ostream& out, t_struct* tstruct);
void generate_java_struct_result_writer(std::ostream& out, t_struct* tstruct);
void generate_java_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_java_struct_tostring(std::ostream& out, t_struct* tstruct);
void generate_java_struct_clear(std::ostream& out, t_struct* tstruct);
void generate_field_value_meta_data(std::ostream& out, t_type* type);
std::string get_java_type_string(t_type* type);
void generate_reflection_setters(std::ostringstream& out,
t_type* type,
@ -121,14 +121,14 @@ public:
t_type* type,
std::string field_name,
std::string cap_name);
void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
void generate_java_bean_boilerplate(std::ofstream& out, t_struct* tstruct);
void generate_generic_field_getters_setters(std::ostream& out, t_struct* tstruct);
void generate_java_bean_boilerplate(std::ostream& out, t_struct* tstruct);
void generate_function_helpers(t_function* tfunction);
std::string get_cap_name(std::string name);
std::string generate_isset_check(t_field* field);
std::string generate_isset_check(std::string field);
void generate_isset_set(ofstream& out, t_field* field);
void generate_isset_set(ostream& out, t_field* field);
std::string isset_field_id(t_field* field);
void generate_primitive_service_interface(t_service* tservice);
@ -139,66 +139,66 @@ public:
void generate_process_function(t_service* tservice, t_function* tfunction);
void generate_java_union(t_struct* tstruct);
void generate_union_constructor(ofstream& out, t_struct* tstruct);
void generate_union_getters_and_setters(ofstream& out, t_struct* tstruct);
void generate_union_abstract_methods(ofstream& out, t_struct* tstruct);
void generate_check_type(ofstream& out, t_struct* tstruct);
void generate_read_value(ofstream& out, t_struct* tstruct);
void generate_write_value(ofstream& out, t_struct* tstruct);
void generate_get_field_desc(ofstream& out, t_struct* tstruct);
void generate_get_struct_desc(ofstream& out, t_struct* tstruct);
void generate_get_field_name(ofstream& out, t_struct* tstruct);
void generate_union_constructor(ostream& out, t_struct* tstruct);
void generate_union_getters_and_setters(ostream& out, t_struct* tstruct);
void generate_union_abstract_methods(ostream& out, t_struct* tstruct);
void generate_check_type(ostream& out, t_struct* tstruct);
void generate_read_value(ostream& out, t_struct* tstruct);
void generate_write_value(ostream& out, t_struct* tstruct);
void generate_get_field_desc(ostream& out, t_struct* tstruct);
void generate_get_struct_desc(ostream& out, t_struct* tstruct);
void generate_get_field_name(ostream& out, t_struct* tstruct);
void generate_union_comparisons(ofstream& out, t_struct* tstruct);
void generate_union_hashcode(ofstream& out, t_struct* tstruct);
void generate_union_comparisons(ostream& out, t_struct* tstruct);
void generate_union_hashcode(ostream& out, t_struct* tstruct);
/**
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string iter,
std::string map);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
void generate_java_doc(std::ofstream& out, t_field* field);
void generate_java_doc(std::ostream& out, t_field* field);
void generate_java_doc(std::ofstream& out, t_doc* tdoc);
void generate_java_doc(std::ostream& out, t_doc* tdoc);
void generate_java_doc(std::ofstream& out, t_function* tdoc);
void generate_java_doc(std::ostream& out, t_function* tdoc);
void generate_java_docstring_comment(std::ofstream& out, string contents);
void generate_java_docstring_comment(std::ostream& out, string contents);
void generate_deep_copy_container(std::ofstream& out,
void generate_deep_copy_container(std::ostream& out,
std::string source_name_p1,
std::string source_name_p2,
std::string result_name,
t_type* type);
void generate_deep_copy_non_container(std::ofstream& out,
void generate_deep_copy_non_container(std::ostream& out,
std::string source_name,
std::string dest_name,
t_type* type);
@ -222,8 +222,8 @@ public:
std::string argument_list(t_struct* tstruct, bool include_types = true);
std::string type_to_enum(t_type* ttype);
std::string get_enum_class_name(t_type* type);
void generate_struct_desc(ofstream& out, t_struct* tstruct);
void generate_field_descs(ofstream& out, t_struct* tstruct);
void generate_struct_desc(ostream& out, t_struct* tstruct);
void generate_field_descs(ostream& out, t_struct* tstruct);
std::string box_type(t_type* type, string value);
bool type_can_be_null(t_type* ttype) {
@ -241,7 +241,7 @@ private:
*/
std::string package_name_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_service_;
std::string package_dir_;
};
@ -329,7 +329,7 @@ void t_javame_generator::generate_typedef(t_typedef* ttypedef) {
void t_javame_generator::generate_enum(t_enum* tenum) {
// Make output file
string f_enum_name = package_dir_ + "/" + (tenum->get_name()) + ".java";
ofstream f_enum;
ofstream_with_content_based_conditional_update f_enum;
f_enum.open(f_enum_name.c_str());
// Comment and package it
@ -408,7 +408,7 @@ void t_javame_generator::generate_consts(std::vector<t_const*> consts) {
}
string f_consts_name = package_dir_ + "/" + program_name_ + "Constants.java";
ofstream f_consts;
ofstream_with_content_based_conditional_update f_consts;
f_consts.open(f_consts_name.c_str());
// Print header
@ -434,7 +434,7 @@ void t_javame_generator::generate_consts(std::vector<t_const*> consts) {
* is NOT performed in this function as it is always run beforehand using the
* validate_types method in main.cc
*/
void t_javame_generator::print_const_value(std::ofstream& out,
void t_javame_generator::print_const_value(std::ostream& out,
string name,
t_type* type,
t_const_value* value,
@ -454,8 +454,8 @@ void t_javame_generator::print_const_value(std::ofstream& out,
} else if (type->is_struct() || type->is_xception()) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
out << name << " = new " << type_name(type, false, true) << "();" << endl;
if (!in_static) {
indent(out) << "static {" << endl;
@ -489,8 +489,8 @@ void t_javame_generator::print_const_value(std::ofstream& out,
}
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
string key = render_const_value(out, name, ktype, v_iter->first);
string val = render_const_value(out, name, vtype, v_iter->second);
@ -535,7 +535,7 @@ void t_javame_generator::print_const_value(std::ofstream& out,
}
}
string t_javame_generator::render_const_value(ofstream& out,
string t_javame_generator::render_const_value(ostream& out,
string name,
t_type* type,
t_const_value* value) {
@ -638,7 +638,7 @@ void t_javame_generator::generate_xception(t_struct* txception) {
void t_javame_generator::generate_java_struct(t_struct* tstruct, bool is_exception) {
// Make output file
string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".java";
ofstream f_struct;
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
f_struct << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
@ -655,7 +655,7 @@ void t_javame_generator::generate_java_struct(t_struct* tstruct, bool is_excepti
void t_javame_generator::generate_java_union(t_struct* tstruct) {
// Make output file
string f_struct_name = package_dir_ + "/" + (tstruct->get_name()) + ".java";
ofstream f_struct;
ofstream_with_content_based_conditional_update f_struct;
f_struct.open(f_struct_name.c_str());
f_struct << autogen_comment() << java_package() << java_type_imports() << java_thrift_imports();
@ -699,7 +699,7 @@ void t_javame_generator::generate_java_union(t_struct* tstruct) {
f_struct.close();
}
void t_javame_generator::generate_union_constructor(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_union_constructor(ostream& out, t_struct* tstruct) {
indent(out) << "public " << type_name(tstruct) << "() {" << endl;
indent(out) << " super();" << endl;
indent(out) << "}" << endl << endl;
@ -730,7 +730,7 @@ void t_javame_generator::generate_union_constructor(ofstream& out, t_struct* tst
}
}
void t_javame_generator::generate_union_getters_and_setters(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_union_getters_and_setters(ostream& out, t_struct* tstruct) {
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
@ -772,7 +772,7 @@ void t_javame_generator::generate_union_getters_and_setters(ofstream& out, t_str
}
}
void t_javame_generator::generate_union_abstract_methods(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_union_abstract_methods(ostream& out, t_struct* tstruct) {
generate_check_type(out, tstruct);
out << endl;
generate_read_value(out, tstruct);
@ -785,7 +785,7 @@ void t_javame_generator::generate_union_abstract_methods(ofstream& out, t_struct
out << endl;
}
void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_check_type(ostream& out, t_struct* tstruct) {
indent(out)
<< "protected void checkType(_Fields setField, Object value) throws ClassCastException {"
<< endl;
@ -821,7 +821,7 @@ void t_javame_generator::generate_check_type(ofstream& out, t_struct* tstruct) {
indent(out) << "}" << endl;
}
void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_read_value(ostream& out, t_struct* tstruct) {
indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {"
<< endl;
@ -875,7 +875,7 @@ void t_javame_generator::generate_read_value(ofstream& out, t_struct* tstruct) {
indent(out) << "}" << endl;
}
void t_javame_generator::generate_write_value(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_write_value(ostream& out, t_struct* tstruct) {
indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << endl;
indent_up();
@ -910,7 +910,7 @@ void t_javame_generator::generate_write_value(ofstream& out, t_struct* tstruct)
indent(out) << "}" << endl;
}
void t_javame_generator::generate_get_field_desc(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_get_field_desc(ostream& out, t_struct* tstruct) {
indent(out) << "protected TField getFieldDesc(_Fields setField) {" << endl;
indent_up();
@ -936,14 +936,14 @@ void t_javame_generator::generate_get_field_desc(ofstream& out, t_struct* tstruc
indent(out) << "}" << endl;
}
void t_javame_generator::generate_get_struct_desc(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_get_struct_desc(ostream& out, t_struct* tstruct) {
(void)tstruct;
indent(out) << "protected TStruct getStructDesc() {" << endl;
indent(out) << " return STRUCT_DESC;" << endl;
indent(out) << "}" << endl;
}
void t_javame_generator::generate_union_comparisons(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_union_comparisons(ostream& out, t_struct* tstruct) {
// equality
indent(out) << "public boolean equals(Object other) {" << endl;
indent(out) << " if (other instanceof " << tstruct->get_name() << ") {" << endl;
@ -973,7 +973,7 @@ void t_javame_generator::generate_union_comparisons(ofstream& out, t_struct* tst
out << endl;
}
void t_javame_generator::generate_union_hashcode(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_union_hashcode(ostream& out, t_struct* tstruct) {
(void)tstruct;
indent(out) << "/**" << endl;
indent(out)
@ -995,7 +995,7 @@ void t_javame_generator::generate_union_hashcode(ofstream& out, t_struct* tstruc
* @param in_class If inside a class, needs to be static class
* @param is_result If this is a result it needs a different writer
*/
void t_javame_generator::generate_java_struct_definition(ofstream& out,
void t_javame_generator::generate_java_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception,
bool in_class,
@ -1177,7 +1177,7 @@ void t_javame_generator::generate_java_struct_definition(ofstream& out,
*
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_equality(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_equality(ostream& out, t_struct* tstruct) {
out << indent() << "public boolean equals(Object that) {" << endl;
indent_up();
out << indent() << "if (that == null)" << endl << indent() << " return false;" << endl
@ -1222,7 +1222,7 @@ void t_javame_generator::generate_java_struct_equality(ofstream& out, t_struct*
<< "this_present_" << name << " && that_present_" << name << "))" << endl << indent()
<< " return false;" << endl;
if (t->is_base_type() && ((t_base_type*)t)->is_binary()) {
if (t->is_binary()) {
unequal = "TBaseHelper.compareTo(this." + name + ", that." + name + ") != 0";
} else if (can_be_null) {
unequal = "!this." + name + ".equals(that." + name + ")";
@ -1246,7 +1246,7 @@ void t_javame_generator::generate_java_struct_equality(ofstream& out, t_struct*
indent(out) << "}" << endl << endl;
}
void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_compare_to(ostream& out, t_struct* tstruct) {
indent(out) << "public int compareTo(Object otherObject) {" << endl;
// indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
indent_up();
@ -1297,7 +1297,7 @@ void t_javame_generator::generate_java_struct_compare_to(ofstream& out, t_struct
*
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_reader(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_reader(ostream& out, t_struct* tstruct) {
out << indent() << "public void read(TProtocol iprot) throws TException {" << endl;
indent_up();
@ -1365,7 +1365,7 @@ void t_javame_generator::generate_java_struct_reader(ofstream& out, t_struct* ts
// generates java method to perform various checks
// (e.g. check that all required fields are set)
void t_javame_generator::generate_java_validator(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_validator(ostream& out, t_struct* tstruct) {
indent(out) << "public void validate() throws TException {" << endl;
indent_up();
@ -1390,7 +1390,7 @@ void t_javame_generator::generate_java_validator(ofstream& out, t_struct* tstruc
*
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
indent_up();
@ -1449,7 +1449,7 @@ void t_javame_generator::generate_java_struct_writer(ofstream& out, t_struct* ts
*
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_result_writer(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_result_writer(ostream& out, t_struct* tstruct) {
out << indent() << "public void write(TProtocol oprot) throws TException {" << endl;
indent_up();
@ -1527,7 +1527,7 @@ void t_javame_generator::generate_reflection_setters(ostringstream& out,
indent_down();
}
void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& out,
void t_javame_generator::generate_generic_field_getters_setters(std::ostream& out,
t_struct* tstruct) {
(void)out;
std::ostringstream getter_stream;
@ -1555,7 +1555,7 @@ void t_javame_generator::generate_generic_field_getters_setters(std::ofstream& o
*
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_bean_boilerplate(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -1708,7 +1708,7 @@ void t_javame_generator::generate_java_bean_boilerplate(ofstream& out, t_struct*
*
* @param tstruct The struct definition
*/
void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_tostring(ostream& out, t_struct* tstruct) {
out << indent() << "public String toString() {" << endl;
indent_up();
@ -1740,7 +1740,7 @@ void t_javame_generator::generate_java_struct_tostring(ofstream& out, t_struct*
indent_up();
}
if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
if (field->get_type()->is_binary()) {
indent(out) << "TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl;
} else {
indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << endl;
@ -1819,7 +1819,7 @@ std::string t_javame_generator::get_java_type_string(t_type* type) {
}
}
void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type) {
void t_javame_generator::generate_field_value_meta_data(std::ostream& out, t_type* type) {
out << endl;
indent_up();
indent_up();
@ -1894,7 +1894,7 @@ void t_javame_generator::generate_primitive_service_interface(t_service* tservic
<< endl << endl;
string f_interface_name = package_dir_ + "/" + service_name_ + "Iface.java";
std::ofstream f_iface;
ofstream_with_content_based_conditional_update f_iface;
f_iface.open(f_interface_name.c_str());
string extends_iface = "";
@ -2391,7 +2391,7 @@ void t_javame_generator::generate_process_function(t_service* tservice, t_functi
* @param tfield The field
* @param prefix The variable name or container for this field
*/
void t_javame_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_javame_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
if (type->is_void()) {
@ -2413,7 +2413,7 @@ void t_javame_generator::generate_deserialize_field(ofstream& out, t_field* tfie
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (!((t_base_type*)type)->is_binary()) {
if (!type->is_binary()) {
out << "readString();";
} else {
out << "readBinary();";
@ -2455,7 +2455,7 @@ void t_javame_generator::generate_deserialize_field(ofstream& out, t_field* tfie
/**
* Generates an unserializer for a struct, invokes read()
*/
void t_javame_generator::generate_deserialize_struct(ofstream& out,
void t_javame_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
out << indent() << prefix << " = new " << type_name(tstruct) << "();" << endl << indent()
@ -2465,7 +2465,7 @@ void t_javame_generator::generate_deserialize_struct(ofstream& out,
/**
* Deserializes a container by reading its size and then iterating
*/
void t_javame_generator::generate_deserialize_container(ofstream& out,
void t_javame_generator::generate_deserialize_container(ostream& out,
t_type* ttype,
string prefix) {
scope_up(out);
@ -2527,7 +2527,7 @@ void t_javame_generator::generate_deserialize_container(ofstream& out,
/**
* Generates code to deserialize a map
*/
void t_javame_generator::generate_deserialize_map_element(ofstream& out,
void t_javame_generator::generate_deserialize_map_element(ostream& out,
t_map* tmap,
string prefix) {
string key = tmp("_key");
@ -2548,7 +2548,7 @@ void t_javame_generator::generate_deserialize_map_element(ofstream& out,
/**
* Deserializes a set element
*/
void t_javame_generator::generate_deserialize_set_element(ofstream& out,
void t_javame_generator::generate_deserialize_set_element(ostream& out,
t_set* tset,
string prefix) {
string elem = tmp("_elem");
@ -2565,7 +2565,7 @@ void t_javame_generator::generate_deserialize_set_element(ofstream& out,
/**
* Deserializes a list element
*/
void t_javame_generator::generate_deserialize_list_element(ofstream& out,
void t_javame_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
string elem = tmp("_elem");
@ -2584,7 +2584,7 @@ void t_javame_generator::generate_deserialize_list_element(ofstream& out,
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_javame_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_javame_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
// Do nothing for void types
@ -2609,7 +2609,7 @@ void t_javame_generator::generate_serialize_field(ofstream& out, t_field* tfield
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "writeBinary(" << name << ");";
} else {
out << "writeString(" << name << ");";
@ -2654,7 +2654,7 @@ void t_javame_generator::generate_serialize_field(ofstream& out, t_field* tfield
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_javame_generator::generate_serialize_struct(ofstream& out,
void t_javame_generator::generate_serialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
(void)tstruct;
@ -2667,7 +2667,7 @@ void t_javame_generator::generate_serialize_struct(ofstream& out,
* @param ttype The type of container
* @param prefix String prefix for fields
*/
void t_javame_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_javame_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
if (ttype->is_map()) {
@ -2733,7 +2733,7 @@ void t_javame_generator::generate_serialize_container(ofstream& out, t_type* tty
/**
* Serializes the members of a map.
*/
void t_javame_generator::generate_serialize_map_element(ofstream& out,
void t_javame_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string iter,
string map) {
@ -2747,7 +2747,7 @@ void t_javame_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_javame_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_javame_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
@ -2755,7 +2755,7 @@ void t_javame_generator::generate_serialize_set_element(ofstream& out, t_set* ts
/**
* Serializes the members of a list.
*/
void t_javame_generator::generate_serialize_list_element(ofstream& out,
void t_javame_generator::generate_serialize_list_element(ostream& out,
t_list* tlist,
string iter) {
t_field efield(tlist->get_elem_type(), iter);
@ -2847,7 +2847,7 @@ string t_javame_generator::declare_field(t_field* tfield, bool init) {
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
if (ttype->is_base_type() && tfield->get_value() != NULL) {
ofstream dummy;
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
@ -2997,11 +2997,11 @@ string t_javame_generator::constant_name(string name) {
return constant_name;
}
void t_javame_generator::generate_java_docstring_comment(ofstream& out, string contents) {
void t_javame_generator::generate_java_docstring_comment(ostream& out, string contents) {
generate_docstring_comment(out, "/**\n", " * ", contents, " */\n");
}
void t_javame_generator::generate_java_doc(ofstream& out, t_field* field) {
void t_javame_generator::generate_java_doc(ostream& out, t_field* field) {
if (field->get_type()->is_enum()) {
string combined_message = field->get_doc() + "\n@see " + get_enum_class_name(field->get_type());
generate_java_docstring_comment(out, combined_message);
@ -3013,7 +3013,7 @@ void t_javame_generator::generate_java_doc(ofstream& out, t_field* field) {
/**
* Emits a JavaDoc comment if the provided object has a doc in Thrift
*/
void t_javame_generator::generate_java_doc(ofstream& out, t_doc* tdoc) {
void t_javame_generator::generate_java_doc(ostream& out, t_doc* tdoc) {
if (tdoc->has_doc()) {
generate_java_docstring_comment(out, tdoc->get_doc());
}
@ -3022,7 +3022,7 @@ void t_javame_generator::generate_java_doc(ofstream& out, t_doc* tdoc) {
/**
* Emits a JavaDoc comment if the provided function object has a doc in Thrift
*/
void t_javame_generator::generate_java_doc(ofstream& out, t_function* tfunction) {
void t_javame_generator::generate_java_doc(ostream& out, t_function* tfunction) {
if (tfunction->has_doc()) {
stringstream ss;
ss << tfunction->get_doc();
@ -3039,7 +3039,7 @@ void t_javame_generator::generate_java_doc(ofstream& out, t_function* tfunction)
}
}
void t_javame_generator::generate_deep_copy_container(ofstream& out,
void t_javame_generator::generate_deep_copy_container(ostream& out,
std::string source_name_p1,
std::string source_name_p2,
std::string result_name,
@ -3144,7 +3144,7 @@ void t_javame_generator::generate_deep_copy_container(ofstream& out,
}
} else {
// iterative copy
if (((t_base_type*)elem_type)->is_binary()) {
if (elem_type->is_binary()) {
indent(out) << type_name(elem_type, true, false) << " temp_binary_element = ";
generate_deep_copy_non_container(out,
iterator_element_name,
@ -3169,13 +3169,13 @@ void t_javame_generator::generate_deep_copy_container(ofstream& out,
}
}
void t_javame_generator::generate_deep_copy_non_container(ofstream& out,
void t_javame_generator::generate_deep_copy_non_container(ostream& out,
std::string source_name,
std::string dest_name,
t_type* type) {
if (type->is_base_type() || type->is_enum() || type->is_typedef()) {
// binary fields need to be copied with System.arraycopy
if (((t_base_type*)type)->is_binary()) {
if (type->is_binary()) {
out << "new byte[" << source_name << ".length];" << endl;
indent(out) << "System.arraycopy(" << source_name << ", 0, " << dest_name << ", 0, "
<< source_name << ".length)";
@ -3200,7 +3200,7 @@ std::string t_javame_generator::generate_isset_check(std::string field_name) {
return "is" + get_cap_name("set") + get_cap_name(field_name) + "()";
}
void t_javame_generator::generate_isset_set(ofstream& out, t_field* field) {
void t_javame_generator::generate_isset_set(ostream& out, t_field* field) {
if (!type_can_be_null(field->get_type())) {
indent(out) << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") << "(true);"
<< endl;
@ -3216,12 +3216,12 @@ std::string t_javame_generator::get_enum_class_name(t_type* type) {
return package + type->get_name();
}
void t_javame_generator::generate_struct_desc(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_struct_desc(ostream& out, t_struct* tstruct) {
indent(out) << "private static final TStruct STRUCT_DESC = new TStruct(\"" << tstruct->get_name()
<< "\");" << endl;
}
void t_javame_generator::generate_field_descs(ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_field_descs(ostream& out, t_struct* tstruct) {
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
@ -3245,7 +3245,7 @@ bool t_javame_generator::has_bit_vector(t_struct* tstruct) {
return false;
}
void t_javame_generator::generate_java_struct_clear(std::ofstream& out, t_struct* tstruct) {
void t_javame_generator::generate_java_struct_clear(std::ostream& out, t_struct* tstruct) {
indent(out) << "public void clear() {" << endl;
const vector<t_field*>& members = tstruct->get_members();

File diff suppressed because it is too large Load diff

View file

@ -89,7 +89,7 @@ public:
private:
bool should_merge_includes_;
std::ofstream f_json_;
ofstream_with_content_based_conditional_update f_json_;
std::stack<bool> comma_needed_;
template <typename T>
@ -264,6 +264,15 @@ void t_json_generator::write_type_spec(t_type* ttype) {
write_string(get_type_name(ttype));
if (ttype->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = ttype->annotations_.begin(); it != ttype->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
if (ttype->is_struct() || ttype->is_xception()) {
write_key_and_string("class", get_qualified_name(ttype));
} else if (ttype->is_map()) {
@ -273,10 +282,14 @@ void t_json_generator::write_type_spec(t_type* ttype) {
write_key_and_string("valueTypeId", get_type_name(vtype));
write_type_spec_object("keyType", ktype);
write_type_spec_object("valueType", vtype);
} else if (ttype->is_list() || ttype->is_set()) {
} else if (ttype->is_list()) {
t_type* etype = ((t_list*)ttype)->get_elem_type();
write_key_and_string("elemTypeId", get_type_name(etype));
write_type_spec_object("elemType", etype);
} else if (ttype->is_set()) {
t_type* etype = ((t_set*)ttype)->get_elem_type();
write_key_and_string("elemTypeId", get_type_name(etype));
write_type_spec_object("elemType", etype);
}
}
@ -441,6 +454,14 @@ void t_json_generator::generate_typedef(t_typedef* ttypedef) {
if (ttypedef->has_doc()) {
write_key_and_string("doc", ttypedef->get_doc());
}
if (ttypedef->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = ttypedef->annotations_.begin(); it != ttypedef->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
end_object();
}
@ -489,8 +510,8 @@ void t_json_generator::write_const_value(t_const_value* value, bool should_force
case t_const_value::CV_MAP: {
start_object(NO_INDENT);
std::map<t_const_value*, t_const_value*> map = value->get_map();
std::map<t_const_value*, t_const_value*>::iterator mit;
std::map<t_const_value*, t_const_value*, t_const_value::value_compare> map = value->get_map();
std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::iterator mit;
for (mit = map.begin(); mit != map.end(); ++mit) {
write_comma_if_needed();
f_json_ << indent();
@ -540,6 +561,15 @@ void t_json_generator::generate_enum(t_enum* tenum) {
write_key_and_string("doc", tenum->get_doc());
}
if (tenum->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = tenum->annotations_.begin(); it != tenum->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
write_key_and("members");
start_array();
vector<t_enum_value*> values = tenum->get_constants();
@ -570,6 +600,15 @@ void t_json_generator::generate_struct(t_struct* tstruct) {
write_key_and_string("doc", tstruct->get_doc());
}
if (tstruct->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = tstruct->annotations_.begin(); it != tstruct->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
write_key_and_bool("isException", tstruct->is_xception());
write_key_and_bool("isUnion", tstruct->is_union());
@ -601,6 +640,15 @@ void t_json_generator::generate_service(t_service* tservice) {
write_key_and_string("doc", tservice->get_doc());
}
if (tservice->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = tservice->annotations_.begin(); it != tservice->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
write_key_and("functions");
start_array();
vector<t_function*> functions = tservice->get_functions();
@ -629,6 +677,15 @@ void t_json_generator::generate_function(t_function* tfunc) {
write_key_and_string("doc", tfunc->get_doc());
}
if (tfunc->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = tfunc->annotations_.begin(); it != tfunc->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
write_key_and("arguments");
start_array();
vector<t_field*> members = tfunc->get_arglist()->get_members();
@ -666,6 +723,15 @@ void t_json_generator::generate_field(t_field* field) {
write_key_and_string("doc", field->get_doc());
}
if (field->annotations_.size() > 0) {
write_key_and("annotations");
start_object();
for (map<string, string>::iterator it = field->annotations_.begin(); it != field->annotations_.end(); ++it) {
write_key_and_string(it->first, it->second);
}
end_object();
}
write_key_and("required");
switch (field->get_req()) {
case t_field::T_REQUIRED:

View file

@ -21,7 +21,7 @@
#include "thrift/platform.h"
#include "thrift/generate/t_oop_generator.h"
using std::ofstream;
using std::ostream;
using std::string;
using std::vector;
using std::map;
@ -80,65 +80,65 @@ private:
/**
* Struct-level generation functions
*/
void generate_lua_struct_definition(std::ofstream& out,
void generate_lua_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false);
void generate_lua_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_lua_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_lua_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_lua_struct_writer(std::ostream& out, t_struct* tstruct);
/**
* Service-level generation functions
*/
void generate_service_client(std::ofstream& out, t_service* tservice);
void generate_service_interface(std::ofstream& out, t_service* tservice);
void generate_service_processor(std::ofstream& out, t_service* tservice);
void generate_process_function(std::ofstream& out, t_service* tservice, t_function* tfunction);
void generate_service_helpers(ofstream& out, t_service* tservice);
void generate_function_helpers(ofstream& out, t_function* tfunction);
void generate_service_client(std::ostream& out, t_service* tservice);
void generate_service_interface(std::ostream& out, t_service* tservice);
void generate_service_processor(std::ostream& out, t_service* tservice);
void generate_process_function(std::ostream& out, t_service* tservice, t_function* tfunction);
void generate_service_helpers(ostream& out, t_service* tservice);
void generate_function_helpers(ostream& out, t_function* tfunction);
/**
* Deserialization (Read)
*/
void generate_deserialize_field(std::ofstream& out,
void generate_deserialize_field(std::ostream& out,
t_field* tfield,
bool local,
std::string prefix = "");
void generate_deserialize_struct(std::ofstream& out,
void generate_deserialize_struct(std::ostream& out,
t_struct* tstruct,
bool local,
std::string prefix = "");
void generate_deserialize_container(std::ofstream& out,
void generate_deserialize_container(std::ostream& out,
t_type* ttype,
bool local,
std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
/**
* Serialization (Write)
*/
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string kiter,
std::string viter);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
/**
* Helper rendering functions
@ -159,9 +159,9 @@ private:
/**
* File streams
*/
std::ofstream f_types_;
std::ofstream f_consts_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_consts_;
ofstream_with_content_based_conditional_update f_service_;
};
/**
@ -276,8 +276,8 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end();) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -308,8 +308,8 @@ string t_lua_generator::render_const_value(t_type* type, t_const_value* value) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end();) {
indent(out) << "[" << render_const_value(ktype, v_iter->first)
<< "] = " << render_const_value(vtype, v_iter->second);
@ -366,7 +366,7 @@ void t_lua_generator::generate_xception(t_struct* txception) {
/**
* Generate a thrift struct or exception (lua table)
*/
void t_lua_generator::generate_lua_struct_definition(ofstream& out,
void t_lua_generator::generate_lua_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception) {
vector<t_field*>::const_iterator m_iter;
@ -402,7 +402,7 @@ void t_lua_generator::generate_lua_struct_definition(ofstream& out,
/**
* Generate a struct/exception reader
*/
void t_lua_generator::generate_lua_struct_reader(ofstream& out, t_struct* tstruct) {
void t_lua_generator::generate_lua_struct_reader(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -459,7 +459,7 @@ void t_lua_generator::generate_lua_struct_reader(ofstream& out, t_struct* tstruc
/**
* Generate a struct/exception writer
*/
void t_lua_generator::generate_lua_struct_writer(ofstream& out, t_struct* tstruct) {
void t_lua_generator::generate_lua_struct_writer(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -527,7 +527,7 @@ void t_lua_generator::generate_service(t_service* tservice) {
f_service_.close();
}
void t_lua_generator::generate_service_interface(ofstream& out, t_service* tservice) {
void t_lua_generator::generate_service_interface(ostream& out, t_service* tservice) {
string classname = tservice->get_name() + "Iface";
t_service* extends_s = tservice->get_extends();
@ -541,7 +541,7 @@ void t_lua_generator::generate_service_interface(ofstream& out, t_service* tserv
out << " __type = '" << classname << "'" << endl << "}" << endl << endl;
}
void t_lua_generator::generate_service_client(ofstream& out, t_service* tservice) {
void t_lua_generator::generate_service_client(ostream& out, t_service* tservice) {
string classname = tservice->get_name() + "Client";
t_service* extends_s = tservice->get_extends();
@ -637,14 +637,14 @@ void t_lua_generator::generate_service_client(ofstream& out, t_service* tservice
}
}
void t_lua_generator::generate_service_processor(ofstream& out, t_service* tservice) {
void t_lua_generator::generate_service_processor(ostream& out, t_service* tservice) {
string classname = tservice->get_name() + "Processor";
t_service* extends_s = tservice->get_extends();
// Define processor table
out << endl << classname << " = __TObject.new(";
if (extends_s != NULL) {
out << extends_s << "Processor" << endl;
out << extends_s->get_name() << "Processor" << endl;
} else {
out << "__TProcessor" << endl;
}
@ -680,7 +680,7 @@ void t_lua_generator::generate_service_processor(ofstream& out, t_service* tserv
}
}
void t_lua_generator::generate_process_function(ofstream& out,
void t_lua_generator::generate_process_function(ostream& out,
t_service* tservice,
t_function* tfunction) {
string classname = tservice->get_name() + "Processor";
@ -731,7 +731,7 @@ void t_lua_generator::generate_process_function(ofstream& out,
}
// Service helpers
void t_lua_generator::generate_service_helpers(ofstream& out, t_service* tservice) {
void t_lua_generator::generate_service_helpers(ostream& out, t_service* tservice) {
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
@ -743,7 +743,7 @@ void t_lua_generator::generate_service_helpers(ofstream& out, t_service* tservic
}
}
void t_lua_generator::generate_function_helpers(ofstream& out, t_function* tfunction) {
void t_lua_generator::generate_function_helpers(ostream& out, t_function* tfunction) {
if (!tfunction->is_oneway()) {
t_struct result(program_, tfunction->get_name() + "_result");
t_field success(tfunction->get_returntype(), "success", 0);
@ -764,7 +764,7 @@ void t_lua_generator::generate_function_helpers(ofstream& out, t_function* tfunc
/**
* Deserialize (Read)
*/
void t_lua_generator::generate_deserialize_field(ofstream& out,
void t_lua_generator::generate_deserialize_field(ostream& out,
t_field* tfield,
bool local,
string prefix) {
@ -825,7 +825,7 @@ void t_lua_generator::generate_deserialize_field(ofstream& out,
}
}
void t_lua_generator::generate_deserialize_struct(ofstream& out,
void t_lua_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
bool local,
string prefix) {
@ -833,7 +833,7 @@ void t_lua_generator::generate_deserialize_struct(ofstream& out,
<< endl << indent() << prefix << ":read(iprot)" << endl;
}
void t_lua_generator::generate_deserialize_container(ofstream& out,
void t_lua_generator::generate_deserialize_container(ostream& out,
t_type* ttype,
bool local,
string prefix) {
@ -883,7 +883,7 @@ void t_lua_generator::generate_deserialize_container(ofstream& out,
}
}
void t_lua_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
void t_lua_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) {
// A map is represented by a table indexable by any lua type
string key = tmp("_key");
string val = tmp("_val");
@ -896,7 +896,7 @@ void t_lua_generator::generate_deserialize_map_element(ofstream& out, t_map* tma
indent(out) << prefix << "[" << key << "] = " << val << endl;
}
void t_lua_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
void t_lua_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
// A set is represented by a table indexed by the value
string elem = tmp("_elem");
t_field felem(tset->get_elem_type(), elem);
@ -906,7 +906,7 @@ void t_lua_generator::generate_deserialize_set_element(ofstream& out, t_set* tse
indent(out) << prefix << "[" << elem << "] = " << elem << endl;
}
void t_lua_generator::generate_deserialize_list_element(ofstream& out,
void t_lua_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
// A list is represented by a table indexed by integer values
@ -922,7 +922,7 @@ void t_lua_generator::generate_deserialize_list_element(ofstream& out,
/**
* Serialize (Write)
*/
void t_lua_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_lua_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
string name = prefix + tfield->get_name();
@ -979,12 +979,12 @@ void t_lua_generator::generate_serialize_field(ofstream& out, t_field* tfield, s
}
}
void t_lua_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_lua_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
indent(out) << prefix << ":write(oprot)" << endl;
}
void t_lua_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_lua_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
// Begin writing
if (ttype->is_map()) {
indent(out) << "oprot:writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
@ -1034,7 +1034,7 @@ void t_lua_generator::generate_serialize_container(ofstream& out, t_type* ttype,
}
}
void t_lua_generator::generate_serialize_map_element(ofstream& out,
void t_lua_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string kiter,
string viter) {
@ -1045,12 +1045,12 @@ void t_lua_generator::generate_serialize_map_element(ofstream& out,
generate_serialize_field(out, &vfield, "");
}
void t_lua_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_lua_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}
void t_lua_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
void t_lua_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield, "");
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,137 @@
#include <cassert>
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <cctype>
#include <stdlib.h>
#include <sys/stat.h>
#include <sstream>
#include "thrift/platform.h"
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
using std::vector;
static const string endl = "\n"; // avoid ostream << std::endl flushes
class t_netcore_generator : public t_oop_generator
{
struct member_mapping_scope
{
public:
member_mapping_scope() : scope_member(0) { }
void* scope_member;
map<string, string> mapping_table;
};
public:
t_netcore_generator(t_program* program, const map<string, string>& parsed_options, const string& option_string);
bool is_wcf_enabled() const;
bool is_nullable_enabled() const;
bool is_hashcode_enabled() const;
bool is_serialize_enabled() const;
bool is_union_enabled() const;
map<string, int> get_keywords_list() const;
// overrides
void init_generator();
void close_generator();
void generate_consts(vector<t_const*> consts);
void generate_consts(ostream& out, vector<t_const*> consts);
void generate_typedef(t_typedef* ttypedef);
void generate_enum(t_enum* tenum);
void generate_enum(ostream& out, t_enum* tenum);
void generate_struct(t_struct* tstruct);
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
void generate_property(ostream& out, t_field* tfield, bool isPublic, bool generateIsset);
void generate_netcore_property(ostream& out, t_field* tfield, bool isPublic, bool includeIsset = true, string fieldPrefix = "");
bool print_const_value(ostream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval = false, bool needtype = false);
string render_const_value(ostream& out, string name, t_type* type, t_const_value* value);
void print_const_constructor(ostream& out, vector<t_const*> consts);
void print_const_def_value(ostream& out, string name, t_type* type, t_const_value* value);
void generate_netcore_struct(t_struct* tstruct, bool is_exception);
void generate_netcore_union(t_struct* tunion);
void generate_netcore_struct_definition(ostream& out, t_struct* tstruct, bool is_xception = false, bool in_class = false, bool is_result = false);
void generate_netcore_union_definition(ostream& out, t_struct* tunion);
void generate_netcore_union_class(ostream& out, t_struct* tunion, t_field* tfield);
void generate_netcore_wcffault(ostream& out, t_struct* tstruct);
void generate_netcore_struct_reader(ostream& out, t_struct* tstruct);
void generate_netcore_struct_result_writer(ostream& out, t_struct* tstruct);
void generate_netcore_struct_writer(ostream& out, t_struct* tstruct);
void generate_netcore_struct_tostring(ostream& out, t_struct* tstruct);
void generate_netcore_struct_equals(ostream& out, t_struct* tstruct);
void generate_netcore_struct_hashcode(ostream& out, t_struct* tstruct);
void generate_netcore_union_reader(ostream& out, t_struct* tunion);
void generate_function_helpers(ostream& out, t_function* tfunction);
void generate_service_interface(ostream& out, t_service* tservice);
void generate_service_helpers(ostream& out, t_service* tservice);
void generate_service_client(ostream& out, t_service* tservice);
void generate_service_server(ostream& out, t_service* tservice);
void generate_process_function_async(ostream& out, t_service* tservice, t_function* function);
void generate_deserialize_field(ostream& out, t_field* tfield, string prefix = "", bool is_propertyless = false);
void generate_deserialize_struct(ostream& out, t_struct* tstruct, string prefix = "");
void generate_deserialize_container(ostream& out, t_type* ttype, string prefix = "");
void generate_deserialize_set_element(ostream& out, t_set* tset, string prefix = "");
void generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix = "");
void generate_deserialize_list_element(ostream& out, t_list* list, string prefix = "");
void generate_serialize_field(ostream& out, t_field* tfield, string prefix = "", bool is_element = false, bool is_propertyless = false);
void generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix = "");
void generate_serialize_container(ostream& out, t_type* ttype, string prefix = "");
void generate_serialize_map_element(ostream& out, t_map* tmap, string iter, string map);
void generate_serialize_set_element(ostream& out, t_set* tmap, string iter);
void generate_serialize_list_element(ostream& out, t_list* tlist, string iter);
void generate_netcore_doc(ostream& out, t_field* field);
void generate_netcore_doc(ostream& out, t_doc* tdoc);
void generate_netcore_doc(ostream& out, t_function* tdoc);
void generate_netcore_docstring_comment(ostream& out, string contents);
void docstring_comment(ostream& out, const string& comment_start, const string& line_prefix, const string& contents, const string& comment_end);
void start_netcore_namespace(ostream& out);
void end_netcore_namespace(ostream& out);
string netcore_type_usings() const;
string netcore_thrift_usings() const;
string type_name(t_type* ttype, bool in_countainer = false, bool in_init = false, bool in_param = false, bool is_required = false);
string base_type_name(t_base_type* tbase, bool in_container = false, bool in_param = false, bool is_required = false);
string declare_field(t_field* tfield, bool init = false, string prefix = "");
string function_signature_async(t_function* tfunction, string prefix = "");
string function_signature(t_function* tfunction, string prefix = "");
string argument_list(t_struct* tstruct);
string type_to_enum(t_type* ttype);
string prop_name(t_field* tfield, bool suppress_mapping = false);
string get_enum_class_name(t_type* type);
private:
string namespace_name_;
string namespace_dir_;
bool nullable_;
bool union_;
bool hashcode_;
bool serialize_;
bool wcf_;
string wcf_namespace_;
map<string, int> netcore_keywords;
vector<member_mapping_scope> member_mapping_scopes;
void init_keywords();
string normalize_name(string name);
string make_valid_csharp_identifier(string const& fromName);
void prepare_member_name_mapping(t_struct* tstruct);
void prepare_member_name_mapping(void* scope, const vector<t_field*>& members, const string& structname);
void cleanup_member_name_mapping(void* scope);
string get_mapped_member_name(string oldname);
};

View file

@ -32,7 +32,7 @@
using std::ios;
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -90,16 +90,16 @@ public:
*/
void generate_ocaml_struct(t_struct* tstruct, bool is_exception);
void generate_ocaml_struct_definition(std::ofstream& out,
void generate_ocaml_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false);
void generate_ocaml_struct_member(std::ofstream& out, string tname, t_field* tmember);
void generate_ocaml_struct_sig(std::ofstream& out, t_struct* tstruct, bool is_exception);
void generate_ocaml_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_ocaml_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_ocaml_struct_member(std::ostream& out, string tname, t_field* tmember);
void generate_ocaml_struct_sig(std::ostream& out, t_struct* tstruct, bool is_exception);
void generate_ocaml_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_ocaml_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_ocaml_function_helpers(t_function* tfunction);
void generate_ocaml_method_copy(std::ofstream& out, const vector<t_field*>& members);
void generate_ocaml_member_copy(std::ofstream& out, t_field* member);
void generate_ocaml_method_copy(std::ostream& out, const vector<t_field*>& members);
void generate_ocaml_member_copy(std::ostream& out, t_field* member);
/**
* Service-level generation functions
@ -115,33 +115,33 @@ public:
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out, t_field* tfield, std::string prefix);
void generate_deserialize_field(std::ostream& out, t_field* tfield, std::string prefix);
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct);
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct);
void generate_deserialize_container(std::ofstream& out, t_type* ttype);
void generate_deserialize_container(std::ostream& out, t_type* ttype);
void generate_deserialize_set_element(std::ofstream& out, t_set* tset);
void generate_deserialize_set_element(std::ostream& out, t_set* tset);
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_deserialize_type(std::ofstream& out, t_type* type);
void generate_deserialize_type(std::ostream& out, t_type* type);
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string name = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string name = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string kiter,
std::string viter);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
/**
* Helper rendering functions
@ -161,12 +161,12 @@ private:
* File streams
*/
std::ofstream f_types_;
std::ofstream f_consts_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_consts_;
ofstream_with_content_based_conditional_update f_service_;
std::ofstream f_types_i_;
std::ofstream f_service_i_;
ofstream_with_content_based_conditional_update f_types_i_;
ofstream_with_content_based_conditional_update f_service_i_;
};
/*
@ -401,8 +401,8 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value)
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -425,8 +425,8 @@ string t_ocaml_generator::render_const_value(t_type* type, t_const_value* value)
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
string hm = tmp("_hm");
out << endl;
indent_up();
@ -499,7 +499,7 @@ void t_ocaml_generator::generate_ocaml_struct(t_struct* tstruct, bool is_excepti
generate_ocaml_struct_sig(f_types_i_, tstruct, is_exception);
}
void t_ocaml_generator::generate_ocaml_method_copy(ofstream& out, const vector<t_field*>& members) {
void t_ocaml_generator::generate_ocaml_method_copy(ostream& out, const vector<t_field*>& members) {
vector<t_field*>::const_iterator m_iter;
/* Create a copy of the current object */
@ -555,7 +555,7 @@ string t_ocaml_generator::struct_member_copy_of(t_type* type, string what) {
return what;
}
void t_ocaml_generator::generate_ocaml_member_copy(ofstream& out, t_field* tmember) {
void t_ocaml_generator::generate_ocaml_member_copy(ostream& out, t_field* tmember) {
string mname = decapitalize(tmember->get_name());
t_type* type = get_true_type(tmember->get_type());
@ -576,7 +576,7 @@ void t_ocaml_generator::generate_ocaml_member_copy(ofstream& out, t_field* tmemb
*
* @param tstruct The struct definition
*/
void t_ocaml_generator::generate_ocaml_struct_definition(ofstream& out,
void t_ocaml_generator::generate_ocaml_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception) {
const vector<t_field*>& members = tstruct->get_members();
@ -611,7 +611,7 @@ void t_ocaml_generator::generate_ocaml_struct_definition(ofstream& out,
* @param tname Name of the parent structure for the member
* @param tmember Member definition
*/
void t_ocaml_generator::generate_ocaml_struct_member(ofstream& out,
void t_ocaml_generator::generate_ocaml_struct_member(ostream& out,
string tname,
t_field* tmember) {
string x = tmp("_x");
@ -713,7 +713,7 @@ bool t_ocaml_generator::struct_member_default_cheaply_comparable(t_field* tmembe
*
* @param tstruct The struct definition
*/
void t_ocaml_generator::generate_ocaml_struct_sig(ofstream& out,
void t_ocaml_generator::generate_ocaml_struct_sig(ostream& out,
t_struct* tstruct,
bool is_exception) {
const vector<t_field*>& members = tstruct->get_members();
@ -752,7 +752,7 @@ void t_ocaml_generator::generate_ocaml_struct_sig(ofstream& out,
/**
* Generates the read method for a struct
*/
void t_ocaml_generator::generate_ocaml_struct_reader(ofstream& out, t_struct* tstruct) {
void t_ocaml_generator::generate_ocaml_struct_reader(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
string sname = type_name(tstruct);
@ -812,7 +812,7 @@ void t_ocaml_generator::generate_ocaml_struct_reader(ofstream& out, t_struct* ts
indent_down();
}
void t_ocaml_generator::generate_ocaml_struct_writer(ofstream& out, t_struct* tstruct) {
void t_ocaml_generator::generate_ocaml_struct_writer(ostream& out, t_struct* tstruct) {
string name = tstruct->get_name();
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
@ -1309,7 +1309,7 @@ void t_ocaml_generator::generate_process_function(t_service* tservice, t_functio
/**
* Deserializes a field of any type.
*/
void t_ocaml_generator::generate_deserialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_ocaml_generator::generate_deserialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = tfield->get_type();
string name = decapitalize(tfield->get_name());
@ -1321,7 +1321,7 @@ void t_ocaml_generator::generate_deserialize_field(ofstream& out, t_field* tfiel
/**
* Deserializes a field of any type.
*/
void t_ocaml_generator::generate_deserialize_type(ofstream& out, t_type* type) {
void t_ocaml_generator::generate_deserialize_type(ostream& out, t_type* type) {
type = get_true_type(type);
if (type->is_void()) {
@ -1374,7 +1374,7 @@ void t_ocaml_generator::generate_deserialize_type(ofstream& out, t_type* type) {
/**
* Generates an unserializer for a struct, calling read()
*/
void t_ocaml_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct) {
void t_ocaml_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct) {
string prefix = "";
t_program* program = tstruct->get_program();
if (program != NULL && program != program_) {
@ -1388,7 +1388,7 @@ void t_ocaml_generator::generate_deserialize_struct(ofstream& out, t_struct* tst
* Serialize a container by writing out the header followed by
* data and then a footer.
*/
void t_ocaml_generator::generate_deserialize_container(ofstream& out, t_type* ttype) {
void t_ocaml_generator::generate_deserialize_container(ostream& out, t_type* ttype) {
string size = tmp("_size");
string ktype = tmp("_ktype");
string vtype = tmp("_vtype");
@ -1454,7 +1454,7 @@ void t_ocaml_generator::generate_deserialize_container(ofstream& out, t_type* tt
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_ocaml_generator::generate_serialize_field(ofstream& out, t_field* tfield, string name) {
void t_ocaml_generator::generate_serialize_field(ostream& out, t_field* tfield, string name) {
t_type* type = get_true_type(tfield->get_type());
// Do nothing for void types
@ -1523,12 +1523,12 @@ void t_ocaml_generator::generate_serialize_field(ofstream& out, t_field* tfield,
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_ocaml_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_ocaml_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
indent(out) << prefix << "#write(oprot)";
}
void t_ocaml_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_ocaml_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
if (ttype->is_map()) {
indent(out) << "oprot#writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ",";
out << type_to_enum(((t_map*)ttype)->get_val_type()) << ",";
@ -1579,7 +1579,7 @@ void t_ocaml_generator::generate_serialize_container(ofstream& out, t_type* ttyp
* Serializes the members of a map.
*
*/
void t_ocaml_generator::generate_serialize_map_element(ofstream& out,
void t_ocaml_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string kiter,
string viter) {
@ -1593,7 +1593,7 @@ void t_ocaml_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_ocaml_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_ocaml_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield);
}
@ -1601,7 +1601,7 @@ void t_ocaml_generator::generate_serialize_set_element(ofstream& out, t_set* tse
/**
* Serializes the members of a list.
*/
void t_ocaml_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
void t_ocaml_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield);
}

View file

@ -65,11 +65,11 @@ public:
return package + type->get_name();
}
virtual void generate_java_docstring_comment(std::ofstream& out, std::string contents) {
virtual void generate_java_docstring_comment(std::ostream& out, std::string contents) {
generate_docstring_comment(out, "/**\n", " * ", contents, " */\n");
}
virtual void generate_java_doc(std::ofstream& out, t_field* field) {
virtual void generate_java_doc(std::ostream& out, t_field* field) {
if (field->get_type()->is_enum()) {
std::string combined_message = field->get_doc() + "\n@see "
+ get_enum_class_name(field->get_type());
@ -82,7 +82,7 @@ public:
/**
* Emits a JavaDoc comment if the provided object has a doc in Thrift
*/
virtual void generate_java_doc(std::ofstream& out, t_doc* tdoc) {
virtual void generate_java_doc(std::ostream& out, t_doc* tdoc) {
if (tdoc->has_doc()) {
generate_java_docstring_comment(out, tdoc->get_doc());
}
@ -91,7 +91,7 @@ public:
/**
* Emits a JavaDoc comment if the provided function object has a doc in Thrift
*/
virtual void generate_java_doc(std::ofstream& out, t_function* tfunction) {
virtual void generate_java_doc(std::ostream& out, t_function* tfunction) {
if (tfunction->has_doc()) {
std::stringstream ss;
ss << tfunction->get_doc();

View file

@ -31,7 +31,7 @@
#include "thrift/generate/t_oop_generator.h"
using std::map;
using std::ofstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::stringstream;
@ -48,7 +48,7 @@ public:
t_perl_generator(t_program* program,
const std::map<std::string, std::string>& parsed_options,
const std::string& option_string)
: t_oop_generator(program) {
: t_oop_generator(program), f_types_use_includes_emitted_(false) {
(void)option_string;
std::map<std::string, std::string>::const_iterator iter;
@ -87,11 +87,11 @@ public:
*/
void generate_perl_struct(t_struct* tstruct, bool is_exception);
void generate_perl_struct_definition(std::ofstream& out,
void generate_perl_struct_definition(std::ostream& out,
t_struct* tstruct,
bool is_xception = false);
void generate_perl_struct_reader(std::ofstream& out, t_struct* tstruct);
void generate_perl_struct_writer(std::ofstream& out, t_struct* tstruct);
void generate_perl_struct_reader(std::ostream& out, t_struct* tstruct);
void generate_perl_struct_writer(std::ostream& out, t_struct* tstruct);
void generate_perl_function_helpers(t_function* tfunction);
/**
@ -104,42 +104,43 @@ public:
void generate_service_client(t_service* tservice);
void generate_service_processor(t_service* tservice);
void generate_process_function(t_service* tservice, t_function* tfunction);
void generate_use_includes(std::ostream& os, bool& done, t_type *type, bool selfish);
/**
* Serialization constructs
*/
void generate_deserialize_field(std::ofstream& out,
void generate_deserialize_field(std::ostream& out,
t_field* tfield,
std::string prefix = "",
bool inclass = false);
void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_deserialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_set_element(std::ostream& out, t_set* tset, std::string prefix = "");
void generate_deserialize_map_element(std::ofstream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_map_element(std::ostream& out, t_map* tmap, std::string prefix = "");
void generate_deserialize_list_element(std::ofstream& out,
void generate_deserialize_list_element(std::ostream& out,
t_list* tlist,
std::string prefix = "");
void generate_serialize_field(std::ofstream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_field(std::ostream& out, t_field* tfield, std::string prefix = "");
void generate_serialize_struct(std::ofstream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_struct(std::ostream& out, t_struct* tstruct, std::string prefix = "");
void generate_serialize_container(std::ofstream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_container(std::ostream& out, t_type* ttype, std::string prefix = "");
void generate_serialize_map_element(std::ofstream& out,
void generate_serialize_map_element(std::ostream& out,
t_map* tmap,
std::string kiter,
std::string viter);
void generate_serialize_set_element(std::ofstream& out, t_set* tmap, std::string iter);
void generate_serialize_set_element(std::ostream& out, t_set* tmap, std::string iter);
void generate_serialize_list_element(std::ofstream& out, t_list* tlist, std::string iter);
void generate_serialize_list_element(std::ostream& out, t_list* tlist, std::string iter);
/**
* Helper rendering functions
@ -207,10 +208,12 @@ private:
/**
* File streams
*/
std::ofstream f_types_;
std::ofstream f_consts_;
std::ofstream f_helpers_;
std::ofstream f_service_;
ofstream_with_content_based_conditional_update f_types_;
ofstream_with_content_based_conditional_update f_consts_;
ofstream_with_content_based_conditional_update f_helpers_;
ofstream_with_content_based_conditional_update f_service_;
bool f_types_use_includes_emitted_;
};
/**
@ -252,10 +255,12 @@ void t_perl_generator::init_generator() {
string t_perl_generator::perl_includes() {
string inc;
inc = "require 5.6.0;\n";
inc = "use 5.10.0;\n";
inc += "use strict;\n";
inc += "use warnings;\n";
inc += "use Thrift;\n\n";
inc += "use Thrift::Exception;\n";
inc += "use Thrift::MessageType;\n";
inc += "use Thrift::Type;\n\n";
return inc;
}
@ -349,12 +354,13 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value)
} else if (type->is_enum()) {
out << value->get_integer();
} else if (type->is_struct() || type->is_xception()) {
out << "new " << perl_namespace(type->get_program()) << type->get_name() << "({" << endl;
out << perl_namespace(type->get_program()) << type->get_name() << "->new({" << endl;
indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -365,29 +371,30 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value)
if (field_type == NULL) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
out << render_const_value(g_type_string, v_iter->first);
indent(out) << render_const_value(g_type_string, v_iter->first);
out << " => ";
out << render_const_value(field_type, v_iter->second);
out << ",";
out << endl;
}
out << "})";
indent_down();
indent(out) << "})";
} else if (type->is_map()) {
t_type* ktype = ((t_map*)type)->get_key_type();
t_type* vtype = ((t_map*)type)->get_val_type();
out << "{" << endl;
indent_up();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << render_const_value(ktype, v_iter->first);
indent(out) << render_const_value(ktype, v_iter->first);
out << " => ";
out << render_const_value(vtype, v_iter->second);
out << "," << endl;
}
out << "}";
indent_down();
indent(out) << "}";
} else if (type->is_list() || type->is_set()) {
t_type* etype;
if (type->is_list()) {
@ -396,17 +403,20 @@ string t_perl_generator::render_const_value(t_type* type, t_const_value* value)
etype = ((t_set*)type)->get_elem_type();
}
out << "[" << endl;
indent_up();
const vector<t_const_value*>& val = value->get_list();
vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << render_const_value(etype, *v_iter);
indent(out) << render_const_value(etype, *v_iter);
if (type->is_set()) {
out << " => 1";
}
out << "," << endl;
}
out << "]";
indent_down();
indent(out) << "]";
}
return out.str();
}
@ -432,6 +442,7 @@ void t_perl_generator::generate_xception(t_struct* txception) {
* Structs can be normal or exceptions.
*/
void t_perl_generator::generate_perl_struct(t_struct* tstruct, bool is_exception) {
generate_use_includes(f_types_, f_types_use_includes_emitted_, tstruct, false);
generate_perl_struct_definition(f_types_, tstruct, is_exception);
}
@ -442,7 +453,7 @@ void t_perl_generator::generate_perl_struct(t_struct* tstruct, bool is_exception
*
* @param tstruct The struct definition
*/
void t_perl_generator::generate_perl_struct_definition(ofstream& out,
void t_perl_generator::generate_perl_struct_definition(ostream& out,
t_struct* tstruct,
bool is_exception) {
const vector<t_field*>& members = tstruct->get_members();
@ -520,7 +531,7 @@ void t_perl_generator::generate_perl_struct_definition(ofstream& out,
/**
* Generates the read() method for a struct
*/
void t_perl_generator::generate_perl_struct_reader(ofstream& out, t_struct* tstruct) {
void t_perl_generator::generate_perl_struct_reader(ostream& out, t_struct* tstruct) {
const vector<t_field*>& fields = tstruct->get_members();
vector<t_field*>::const_iterator f_iter;
@ -535,14 +546,14 @@ void t_perl_generator::generate_perl_struct_reader(ofstream& out, t_struct* tstr
indent(out) << "$xfer += $input->readStructBegin(\\$fname);" << endl;
// Loop over reading in fields
indent(out) << "while (1) " << endl;
indent(out) << "while (1)" << endl;
scope_up(out);
indent(out) << "$xfer += $input->readFieldBegin(\\$fname, \\$ftype, \\$fid);" << endl;
// Check for field STOP marker and break
indent(out) << "if ($ftype == TType::STOP) {" << endl;
indent(out) << "if ($ftype == Thrift::TType::STOP) {" << endl;
indent_up();
indent(out) << "last;" << endl;
indent_down();
@ -590,7 +601,7 @@ void t_perl_generator::generate_perl_struct_reader(ofstream& out, t_struct* tstr
/**
* Generates the write() method for a struct
*/
void t_perl_generator::generate_perl_struct_writer(ofstream& out, t_struct* tstruct) {
void t_perl_generator::generate_perl_struct_writer(ostream& out, t_struct* tstruct) {
string name = tstruct->get_name();
const vector<t_field*>& fields = tstruct->get_sorted_members();
vector<t_field*>::const_iterator f_iter;
@ -629,6 +640,31 @@ void t_perl_generator::generate_perl_struct_writer(ofstream& out, t_struct* tstr
out << indent() << "}" << endl << endl;
}
/**
* Generates use clauses for included entities
*
* @param os The output stream
* @param done A flag reference to debounce the action
* @param type The type being processed
* @param selfish Flag to indicate if the current namespace types should be "use"d as well.
*/
void t_perl_generator::generate_use_includes(std::ostream& os, bool& done, t_type *type, bool selfish) {
t_program *current = type->get_program();
if (current && !done) {
std::vector<t_program*>& currInc = current->get_includes();
std::vector<t_program*>::size_type numInc = currInc.size();
if (selfish) {
os << "use " << perl_namespace(current) << "Types;" << endl;
}
for (std::vector<t_program*>::size_type i = 0; i < numInc; ++i) {
t_program* incProgram = currInc.at(i);
os << "use " << perl_namespace(incProgram) << "Types;" << endl;
}
os << endl;
done = true;
}
}
/**
* Generates a thrift service.
*
@ -638,11 +674,10 @@ void t_perl_generator::generate_service(t_service* tservice) {
string f_service_name = get_namespace_out_dir() + service_name_ + ".pm";
f_service_.open(f_service_name.c_str());
f_service_ <<
/// "package "<<service_name_<<";"<<endl<<
autogen_comment() << perl_includes();
f_service_ << autogen_comment() << perl_includes();
f_service_ << "use " << perl_namespace(tservice->get_program()) << "Types;" << endl;
bool done = false;
generate_use_includes(f_service_, done, tservice, true);
t_service* extends_s = tservice->get_extends();
if (extends_s != NULL) {
@ -721,11 +756,11 @@ void t_perl_generator::generate_service_processor(t_service* tservice) {
<< "if (!$self->can($methodname)) {" << endl;
indent_up();
f_service_ << indent() << "$input->skip(TType::STRUCT);" << endl << indent()
f_service_ << indent() << "$input->skip(Thrift::TType::STRUCT);" << endl << indent()
<< "$input->readMessageEnd();" << endl << indent()
<< "my $x = new TApplicationException('Function '.$fname.' not implemented.', "
"TApplicationException::UNKNOWN_METHOD);" << endl << indent()
<< "$output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid);" << endl
<< "my $x = Thrift::TApplicationException->new('Function '.$fname.' not implemented.', "
"Thrift::TApplicationException::UNKNOWN_METHOD);" << endl << indent()
<< "$output->writeMessageBegin($fname, Thrift::TMessageType::EXCEPTION, $rseqid);" << endl
<< indent() << "$x->write($output);" << endl << indent()
<< "$output->writeMessageEnd();" << endl << indent()
<< "$output->getTransport()->flush();" << endl << indent() << "return;" << endl;
@ -763,7 +798,7 @@ void t_perl_generator::generate_process_function(t_service* tservice, t_function
string resultname = perl_namespace(tservice->get_program()) + service_name_ + "_"
+ tfunction->get_name() + "_result";
f_service_ << indent() << "my $args = new " << argsname << "();" << endl << indent()
f_service_ << indent() << "my $args = " << argsname << "->new();" << endl << indent()
<< "$args->read($input);" << endl;
f_service_ << indent() << "$input->readMessageEnd();" << endl;
@ -774,7 +809,7 @@ void t_perl_generator::generate_process_function(t_service* tservice, t_function
// Declare result for non oneway function
if (!tfunction->is_oneway()) {
f_service_ << indent() << "my $result = new " << resultname << "();" << endl;
f_service_ << indent() << "my $result = " << resultname << "->new();" << endl;
}
// Try block for a function with exceptions
@ -823,8 +858,8 @@ void t_perl_generator::generate_process_function(t_service* tservice, t_function
f_service_ << indent() << "if ($@) {" << endl;
indent_up();
f_service_ << indent() << "$@ =~ s/^\\s+|\\s+$//g;" << endl
<< indent() << "my $err = new TApplicationException(\"Unexpected Exception: \" . $@, TApplicationException::INTERNAL_ERROR);" << endl
<< indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', TMessageType::EXCEPTION, $seqid);" << endl
<< indent() << "my $err = Thrift::TApplicationException->new(\"Unexpected Exception: \" . $@, Thrift::TApplicationException::INTERNAL_ERROR);" << endl
<< indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::EXCEPTION, $seqid);" << endl
<< indent() << "$err->write($output);" << endl
<< indent() << "$output->writeMessageEnd();" << endl
<< indent() << "$output->getTransport()->flush();" << endl
@ -843,7 +878,7 @@ void t_perl_generator::generate_process_function(t_service* tservice, t_function
}
// Serialize the reply
f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', TMessageType::REPLY, $seqid);" << endl
f_service_ << indent() << "$output->writeMessageBegin('" << tfunction->get_name() << "', Thrift::TMessageType::REPLY, $seqid);" << endl
<< indent() << "$result->write($output);" << endl
<< indent() << "$output->writeMessageEnd();" << endl
<< indent() << "$output->getTransport()->flush();" << endl;
@ -1068,10 +1103,10 @@ void t_perl_generator::generate_service_client(t_service* tservice) {
// Serialize the request header
f_service_ << indent() << "$self->{output}->writeMessageBegin('" << (*f_iter)->get_name()
<< "', " << ((*f_iter)->is_oneway() ? "TMessageType::ONEWAY" : "TMessageType::CALL")
<< "', " << ((*f_iter)->is_oneway() ? "Thrift::TMessageType::ONEWAY" : "Thrift::TMessageType::CALL")
<< ", $self->{seqid});" << endl;
f_service_ << indent() << "my $args = new " << argsname << "();" << endl;
f_service_ << indent() << "my $args = " << argsname << "->new();" << endl;
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
f_service_ << indent() << "$args->{" << (*fld_iter)->get_name() << "} = $"
@ -1104,13 +1139,13 @@ void t_perl_generator::generate_service_client(t_service* tservice) {
<< indent() << "my $mtype = 0;" << endl << endl;
f_service_ << indent() << "$self->{input}->readMessageBegin(\\$fname, \\$mtype, \\$rseqid);"
<< endl << indent() << "if ($mtype == TMessageType::EXCEPTION) {" << endl
<< indent() << " my $x = new TApplicationException();" << endl << indent()
<< endl << indent() << "if ($mtype == Thrift::TMessageType::EXCEPTION) {" << endl
<< indent() << " my $x = Thrift::TApplicationException->new();" << endl << indent()
<< " $x->read($self->{input});" << endl << indent()
<< " $self->{input}->readMessageEnd();" << endl << indent() << " die $x;" << endl
<< indent() << "}" << endl;
f_service_ << indent() << "my $result = new " << resultname << "();" << endl << indent()
f_service_ << indent() << "my $result = " << resultname << "->new();" << endl << indent()
<< "$result->read($self->{input});" << endl;
f_service_ << indent() << "$self->{input}->readMessageEnd();" << endl << endl;
@ -1148,7 +1183,7 @@ void t_perl_generator::generate_service_client(t_service* tservice) {
/**
* Deserializes a field of any type.
*/
void t_perl_generator::generate_deserialize_field(ofstream& out,
void t_perl_generator::generate_deserialize_field(ostream& out,
t_field* tfield,
string prefix,
bool inclass) {
@ -1221,15 +1256,15 @@ void t_perl_generator::generate_deserialize_field(ofstream& out,
* buffer for deserialization, and that there is a variable protocol which
* is a reference to a TProtocol serialization object.
*/
void t_perl_generator::generate_deserialize_struct(ofstream& out,
void t_perl_generator::generate_deserialize_struct(ostream& out,
t_struct* tstruct,
string prefix) {
out << indent() << "$" << prefix << " = new " << perl_namespace(tstruct->get_program())
<< tstruct->get_name() << "();" << endl << indent() << "$xfer += $" << prefix
out << indent() << "$" << prefix << " = " << perl_namespace(tstruct->get_program())
<< tstruct->get_name() << "->new();" << endl << indent() << "$xfer += $" << prefix
<< "->read($input);" << endl;
}
void t_perl_generator::generate_deserialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_perl_generator::generate_deserialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
string size = tmp("_size");
@ -1297,7 +1332,7 @@ void t_perl_generator::generate_deserialize_container(ofstream& out, t_type* tty
/**
* Generates code to deserialize a map
*/
void t_perl_generator::generate_deserialize_map_element(ofstream& out, t_map* tmap, string prefix) {
void t_perl_generator::generate_deserialize_map_element(ostream& out, t_map* tmap, string prefix) {
string key = tmp("key");
string val = tmp("val");
t_field fkey(tmap->get_key_type(), key);
@ -1312,7 +1347,7 @@ void t_perl_generator::generate_deserialize_map_element(ofstream& out, t_map* tm
indent(out) << "$" << prefix << "->{$" << key << "} = $" << val << ";" << endl;
}
void t_perl_generator::generate_deserialize_set_element(ofstream& out, t_set* tset, string prefix) {
void t_perl_generator::generate_deserialize_set_element(ostream& out, t_set* tset, string prefix) {
string elem = tmp("elem");
t_field felem(tset->get_elem_type(), elem);
@ -1323,7 +1358,7 @@ void t_perl_generator::generate_deserialize_set_element(ofstream& out, t_set* ts
indent(out) << "$" << prefix << "->{$" << elem << "} = 1;" << endl;
}
void t_perl_generator::generate_deserialize_list_element(ofstream& out,
void t_perl_generator::generate_deserialize_list_element(ostream& out,
t_list* tlist,
string prefix) {
string elem = tmp("elem");
@ -1342,7 +1377,7 @@ void t_perl_generator::generate_deserialize_list_element(ofstream& out,
* @param tfield The field to serialize
* @param prefix Name to prepend to field name
*/
void t_perl_generator::generate_serialize_field(ofstream& out, t_field* tfield, string prefix) {
void t_perl_generator::generate_serialize_field(ostream& out, t_field* tfield, string prefix) {
t_type* type = get_true_type(tfield->get_type());
// Do nothing for void types
@ -1413,7 +1448,7 @@ void t_perl_generator::generate_serialize_field(ofstream& out, t_field* tfield,
* @param tstruct The struct to serialize
* @param prefix String prefix to attach to all fields
*/
void t_perl_generator::generate_serialize_struct(ofstream& out, t_struct* tstruct, string prefix) {
void t_perl_generator::generate_serialize_struct(ostream& out, t_struct* tstruct, string prefix) {
(void)tstruct;
indent(out) << "$xfer += $" << prefix << "->write($output);" << endl;
}
@ -1421,7 +1456,7 @@ void t_perl_generator::generate_serialize_struct(ofstream& out, t_struct* tstruc
/**
* Writes out a container
*/
void t_perl_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
void t_perl_generator::generate_serialize_container(ostream& out, t_type* ttype, string prefix) {
scope_up(out);
if (ttype->is_map()) {
@ -1485,7 +1520,7 @@ void t_perl_generator::generate_serialize_container(ofstream& out, t_type* ttype
* Serializes the members of a map.
*
*/
void t_perl_generator::generate_serialize_map_element(ofstream& out,
void t_perl_generator::generate_serialize_map_element(ostream& out,
t_map* tmap,
string kiter,
string viter) {
@ -1499,7 +1534,7 @@ void t_perl_generator::generate_serialize_map_element(ofstream& out,
/**
* Serializes the members of a set.
*/
void t_perl_generator::generate_serialize_set_element(ofstream& out, t_set* tset, string iter) {
void t_perl_generator::generate_serialize_set_element(ostream& out, t_set* tset, string iter) {
t_field efield(tset->get_elem_type(), iter);
generate_serialize_field(out, &efield);
}
@ -1507,7 +1542,7 @@ void t_perl_generator::generate_serialize_set_element(ofstream& out, t_set* tset
/**
* Serializes the members of a list.
*/
void t_perl_generator::generate_serialize_list_element(ofstream& out, t_list* tlist, string iter) {
void t_perl_generator::generate_serialize_list_element(ostream& out, t_list* tlist, string iter) {
t_field efield(tlist->get_elem_type(), iter);
generate_serialize_field(out, &efield);
}
@ -1551,7 +1586,7 @@ string t_perl_generator::declare_field(t_field* tfield, bool init, bool obj) {
result += " = []";
} else if (type->is_struct() || type->is_xception()) {
if (obj) {
result += " = new " + perl_namespace(type->get_program()) + type->get_name() + "()";
result += " = " + perl_namespace(type->get_program()) + type->get_name() + "->new()";
} else {
result += " = undef";
}
@ -1616,30 +1651,30 @@ string t_perl_generator::type_to_enum(t_type* type) {
case t_base_type::TYPE_VOID:
throw "NO T_VOID CONSTRUCT";
case t_base_type::TYPE_STRING:
return "TType::STRING";
return "Thrift::TType::STRING";
case t_base_type::TYPE_BOOL:
return "TType::BOOL";
return "Thrift::TType::BOOL";
case t_base_type::TYPE_I8:
return "TType::BYTE";
return "Thrift::TType::BYTE";
case t_base_type::TYPE_I16:
return "TType::I16";
return "Thrift::TType::I16";
case t_base_type::TYPE_I32:
return "TType::I32";
return "Thrift::TType::I32";
case t_base_type::TYPE_I64:
return "TType::I64";
return "Thrift::TType::I64";
case t_base_type::TYPE_DOUBLE:
return "TType::DOUBLE";
return "Thrift::TType::DOUBLE";
}
} else if (type->is_enum()) {
return "TType::I32";
return "Thrift::TType::I32";
} else if (type->is_struct() || type->is_xception()) {
return "TType::STRUCT";
return "Thrift::TType::STRUCT";
} else if (type->is_map()) {
return "TType::MAP";
return "Thrift::TType::MAP";
} else if (type->is_set()) {
return "TType::SET";
return "Thrift::TType::SET";
} else if (type->is_list()) {
return "TType::LIST";
return "Thrift::TType::LIST";
}
throw "INVALID TYPE IN type_to_enum: " + type->get_name();

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -113,6 +113,7 @@ public:
void generate_enum(t_enum* tenum);
void generate_const(t_const* tconst);
void generate_struct(t_struct* tstruct);
void generate_forward_declaration(t_struct* tstruct);
void generate_union(t_struct* tunion);
void generate_xception(t_struct* txception);
void generate_service(t_service* tservice);
@ -123,6 +124,7 @@ public:
* Struct generation code
*/
void generate_rb_struct_declaration(t_rb_ofstream& out, t_struct* tstruct, bool is_exception);
void generate_rb_struct(t_rb_ofstream& out, t_struct* tstruct, bool is_exception);
void generate_rb_struct_required_validator(t_rb_ofstream& out, t_struct* tstruct);
void generate_rb_union(t_rb_ofstream& out, t_struct* tstruct, bool is_exception);
@ -455,8 +457,8 @@ t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out,
out.indent_up();
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@ -478,8 +480,8 @@ t_rb_ofstream& t_rb_generator::render_const_value(t_rb_ofstream& out,
t_type* vtype = ((t_map*)type)->get_val_type();
out << "{" << endl;
out.indent_up();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out.indent();
render_const_value(out, ktype, v_iter->first) << " => ";
@ -529,6 +531,29 @@ void t_rb_generator::generate_struct(t_struct* tstruct) {
}
}
/**
* Generates the "forward declarations" for ruby structs.
* These are simply a declaration of each class with proper inheritance.
* The rest of the struct is still generated in generate_struct as has
* always been the case. These declarations allow thrift to generate valid
* ruby in cases where thrift structs rely on recursive definitions.
*/
void t_rb_generator::generate_forward_declaration(t_struct* tstruct) {
generate_rb_struct_declaration(f_types_, tstruct, tstruct->is_xception());
}
void t_rb_generator::generate_rb_struct_declaration(t_rb_ofstream& out, t_struct* tstruct, bool is_exception) {
out.indent() << "class " << type_name(tstruct);
if (tstruct->is_union()) {
out << " < ::Thrift::Union";
}
if (is_exception) {
out << " < ::Thrift::Exception";
}
out << "; end" << endl << endl;
}
/**
* Generates a struct definition for a thrift exception. Basically the same
* as a struct but extends the Exception class.

File diff suppressed because it is too large Load diff

View file

@ -56,6 +56,7 @@ public:
const std::string& option_string)
: t_oop_generator(program) {
(void)option_string;
temporary_var = 0;
std::map<std::string, std::string>::const_iterator iter;
/* no options yet */
@ -92,8 +93,8 @@ public:
* Struct generation code
*/
void generate_st_struct(std::ofstream& out, t_struct* tstruct, bool is_exception);
void generate_accessors(std::ofstream& out, t_struct* tstruct);
void generate_st_struct(std::ostream& out, t_struct* tstruct, bool is_exception);
void generate_accessors(std::ostream& out, t_struct* tstruct);
/**
* Service-level generation functions
@ -123,15 +124,15 @@ public:
std::string st_autogen_comment();
void st_class_def(std::ofstream& out, std::string name);
void st_method(std::ofstream& out, std::string cls, std::string name);
void st_method(std::ofstream& out, std::string cls, std::string name, std::string category);
void st_close_method(std::ofstream& out);
void st_class_method(std::ofstream& out, std::string cls, std::string name);
void st_class_method(std::ofstream& out, std::string cls, std::string name, std::string category);
void st_setter(std::ofstream& out, std::string cls, std::string name, std::string type);
void st_getter(std::ofstream& out, std::string cls, std::string name);
void st_accessors(std::ofstream& out, std::string cls, std::string name, std::string type);
void st_class_def(std::ostream& out, std::string name);
void st_method(std::ostream& out, std::string cls, std::string name);
void st_method(std::ostream& out, std::string cls, std::string name, std::string category);
void st_close_method(std::ostream& out);
void st_class_method(std::ostream& out, std::string cls, std::string name);
void st_class_method(std::ostream& out, std::string cls, std::string name, std::string category);
void st_setter(std::ostream& out, std::string cls, std::string name, std::string type);
void st_getter(std::ostream& out, std::string cls, std::string name);
void st_accessors(std::ostream& out, std::string cls, std::string name, std::string type);
std::string class_name();
static bool is_valid_namespace(const std::string& sub_namespace);
@ -155,7 +156,7 @@ private:
* File streams
*/
int temporary_var;
std::ofstream f_;
ofstream_with_content_based_conditional_update f_;
};
/**
@ -249,7 +250,7 @@ void t_st_generator::generate_typedef(t_typedef* ttypedef) {
(void)ttypedef;
}
void t_st_generator::st_class_def(std::ofstream& out, string name) {
void t_st_generator::st_class_def(std::ostream& out, string name) {
out << "Object subclass: #" << prefix(name) << endl;
indent_up();
out << indent() << "instanceVariableNames: ''" << endl << indent() << "classVariableNames: ''"
@ -257,19 +258,19 @@ void t_st_generator::st_class_def(std::ofstream& out, string name) {
<< generated_category() << "'!" << endl << endl;
}
void t_st_generator::st_method(std::ofstream& out, string cls, string name) {
void t_st_generator::st_method(std::ostream& out, string cls, string name) {
st_method(out, cls, name, "as yet uncategorized");
}
void t_st_generator::st_class_method(std::ofstream& out, string cls, string name) {
void t_st_generator::st_class_method(std::ostream& out, string cls, string name) {
st_method(out, cls + " class", name);
}
void t_st_generator::st_class_method(std::ofstream& out, string cls, string name, string category) {
void t_st_generator::st_class_method(std::ostream& out, string cls, string name, string category) {
st_method(out, cls, name, category);
}
void t_st_generator::st_method(std::ofstream& out, string cls, string name, string category) {
void t_st_generator::st_method(std::ostream& out, string cls, string name, string category) {
char timestr[50];
time_t rawtime;
struct tm* tinfo;
@ -285,12 +286,12 @@ void t_st_generator::st_method(std::ofstream& out, string cls, string name, stri
out << indent();
}
void t_st_generator::st_close_method(std::ofstream& out) {
void t_st_generator::st_close_method(std::ostream& out) {
out << "! !" << endl << endl;
indent_down();
}
void t_st_generator::st_setter(std::ofstream& out,
void t_st_generator::st_setter(std::ostream& out,
string cls,
string name,
string type = "anObject") {
@ -299,13 +300,13 @@ void t_st_generator::st_setter(std::ofstream& out,
st_close_method(out);
}
void t_st_generator::st_getter(std::ofstream& out, string cls, string name) {
void t_st_generator::st_getter(std::ostream& out, string cls, string name) {
st_method(out, cls, name + "");
out << "^ " << name;
st_close_method(out);
}
void t_st_generator::st_accessors(std::ofstream& out,
void t_st_generator::st_accessors(std::ostream& out,
string cls,
string name,
string type = "anObject") {
@ -401,8 +402,8 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
t_type* field_type = NULL;
@ -427,8 +428,8 @@ string t_st_generator::render_const_value(t_type* type, t_const_value* value) {
out << "(Dictionary new" << endl;
indent_up();
indent_up();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
out << indent() << indent();
out << "at: " << render_const_value(ktype, v_iter->first);
@ -489,7 +490,7 @@ void t_st_generator::generate_xception(t_struct* txception) {
/**
* Generates a smalltalk class to represent a struct
*/
void t_st_generator::generate_st_struct(std::ofstream& out,
void t_st_generator::generate_st_struct(std::ostream& out,
t_struct* tstruct,
bool is_exception = false) {
const vector<t_field*>& members = tstruct->get_members();
@ -541,7 +542,7 @@ string t_st_generator::a_type(t_type* type) {
return prefix + capitalize(type_name(type));
}
void t_st_generator::generate_accessors(std::ofstream& out, t_struct* tstruct) {
void t_st_generator::generate_accessors(std::ostream& out, t_struct* tstruct) {
const vector<t_field*>& members = tstruct->get_members();
vector<t_field*>::const_iterator m_iter;
string type;

File diff suppressed because it is too large Load diff

View file

@ -101,7 +101,7 @@ private:
bool should_use_default_ns_;
bool should_use_namespaces_;
std::ofstream f_xml_;
ofstream_with_content_based_conditional_update f_xml_;
std::set<string> programs_;
std::stack<string> elements_;
@ -391,11 +391,16 @@ void t_xml_generator::write_type(t_type* ttype) {
if (type == "id") {
write_attribute("type-module", ttype->get_program()->get_name());
write_attribute("type-id", ttype->get_name());
} else if (type == "list" || type == "set") {
} else if (type == "list") {
t_type* etype = ((t_list*)ttype)->get_elem_type();
write_element_start("elemType");
write_type(etype);
write_element_end();
} else if (type == "set") {
t_type* etype = ((t_set*)ttype)->get_elem_type();
write_element_start("elemType");
write_type(etype);
write_element_end();
} else if (type == "map") {
t_type* ktype = ((t_map*)ttype)->get_key_type();
write_element_start("keyType");
@ -478,8 +483,8 @@ void t_xml_generator::write_const_value(t_const_value* value) {
case t_const_value::CV_MAP: {
write_element_start("map");
std::map<t_const_value*, t_const_value*> map = value->get_map();
std::map<t_const_value*, t_const_value*>::iterator mit;
std::map<t_const_value*, t_const_value*, t_const_value::value_compare> map = value->get_map();
std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::iterator mit;
for (mit = map.begin(); mit != map.end(); ++mit) {
write_element_start("entry");
write_element_start("key");

View file

@ -103,8 +103,8 @@ private:
/**
* Output xsd/php file
*/
std::ofstream f_xsd_;
std::ofstream f_php_;
ofstream_with_content_based_conditional_update f_xsd_;
ofstream_with_content_based_conditional_update f_php_;
/**
* Output string stream

View file

@ -805,8 +805,8 @@ void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
if (v_iter->first->get_type() != t_const_value::CV_STRING) {
throw "type error: " + name + " struct key must be string";
@ -826,8 +826,8 @@ void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
} else if (type->is_map()) {
t_type* k_type = ((t_map*)type)->get_key_type();
t_type* v_type = ((t_map*)type)->get_val_type();
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
validate_const_rec(name + "<key>", k_type, v_iter->first);
validate_const_rec(name + "<val>", v_type, v_iter->second);
@ -1028,6 +1028,7 @@ void generate(t_program* program, const vector<string>& generator_strings) {
g_generator_failure = true;
#endif
} else if (generator) {
generator->validate_input();
pverbose("Generating \"%s\"\n", iter->c_str());
generator->generate_program();
delete generator;

View file

@ -57,15 +57,15 @@ public:
void set_string_list(bool val) { string_list_ = val; }
bool is_string_list() const { return (base_ == TYPE_STRING) && string_list_; }
bool is_string_list() const { return string_list_ && (base_ == TYPE_STRING); }
void set_binary(bool val) { binary_ = val; }
bool is_binary() const { return (base_ == TYPE_STRING) && binary_; }
bool is_binary() const { return binary_ && (base_ == TYPE_STRING); }
void set_string_enum(bool val) { string_enum_ = val; }
bool is_string_enum() const { return base_ == TYPE_STRING && string_enum_; }
bool is_string_enum() const { return string_enum_ && base_ == TYPE_STRING; }
void add_string_enum_val(std::string val) { string_enum_vals_.push_back(val); }

View file

@ -38,13 +38,24 @@ void convert(From*, To&);
*/
class t_const_value {
public:
enum t_const_value_type { CV_INTEGER, CV_DOUBLE, CV_STRING, CV_MAP, CV_LIST, CV_IDENTIFIER };
/**
* Comparator to sort fields in ascending order by key.
* Make this a functor instead of a function to help GCC inline it.
*/
struct value_compare {
public:
bool operator()(t_const_value const* const& left, t_const_value const* const& right) const {
return *left < *right;
}
};
t_const_value() {}
enum t_const_value_type { CV_INTEGER, CV_DOUBLE, CV_STRING, CV_MAP, CV_LIST, CV_IDENTIFIER, CV_UNKNOWN };
t_const_value(int64_t val) { set_integer(val); }
t_const_value() : intVal_(0), doubleVal_(0.0f), enum_((t_enum*)0), valType_(CV_UNKNOWN) {}
t_const_value(std::string val) { set_string(val); }
t_const_value(int64_t val) : doubleVal_(0.0f), enum_((t_enum*)0), valType_(CV_UNKNOWN) { set_integer(val); }
t_const_value(std::string val) : intVal_(0), doubleVal_(0.0f), enum_((t_enum*)0), valType_(CV_UNKNOWN) { set_string(val); }
void set_string(std::string val) {
valType_ = CV_STRING;
@ -90,7 +101,7 @@ public:
void add_map(t_const_value* key, t_const_value* val) { mapVal_[key] = val; }
const std::map<t_const_value*, t_const_value*>& get_map() const { return mapVal_; }
const std::map<t_const_value*, t_const_value*, t_const_value::value_compare>& get_map() const { return mapVal_; }
void set_list() { valType_ = CV_LIST; }
@ -134,10 +145,57 @@ public:
void set_enum(t_enum* tenum) { enum_ = tenum; }
t_const_value_type get_type() const { return valType_; }
t_const_value_type get_type() const { if (valType_ == CV_UNKNOWN) { throw std::string("unknown t_const_value"); } return valType_; }
/**
* Comparator to sort map fields in ascending order by key and then value.
* This is used for map comparison in lexicographic order.
*/
struct map_entry_compare {
private:
typedef std::pair<t_const_value*, t_const_value*> ConstPair;
public:
bool operator()(ConstPair left, ConstPair right) const {
if (*(left.first) < *(right.first)) {
return true;
} else {
if (*(right.first) < *(left.first)) {
return false;
} else {
return *(left.second) < *(right.second);
}
}
}
};
bool operator < (const t_const_value& that) const {
::t_const_value::t_const_value_type t1 = get_type();
::t_const_value::t_const_value_type t2 = that.get_type();
if (t1 != t2)
return t1 < t2;
switch (t1) {
case ::t_const_value::CV_INTEGER:
return intVal_ < that.intVal_;
case ::t_const_value::CV_DOUBLE:
return doubleVal_ < that.doubleVal_;
case ::t_const_value::CV_STRING:
return stringVal_ < that.stringVal_;
case ::t_const_value::CV_IDENTIFIER:
return identifierVal_ < that.identifierVal_;
case ::t_const_value::CV_MAP:
return std::lexicographical_compare(
mapVal_.begin(), mapVal_.end(), that.mapVal_.begin(), that.mapVal_.end(), map_entry_compare());
case ::t_const_value::CV_LIST:
return std::lexicographical_compare(
listVal_.begin(), listVal_.end(), that.listVal_.begin(), that.listVal_.end(), value_compare());
case ::t_const_value::CV_UNKNOWN:
default:
throw "unknown value type";
}
}
private:
std::map<t_const_value*, t_const_value*> mapVal_;
std::map<t_const_value*, t_const_value*, value_compare> mapVal_;
std::vector<t_const_value*> listVal_;
std::string stringVal_;
int64_t intVal_;

View file

@ -34,8 +34,12 @@
class t_function : public t_doc {
public:
t_function(t_type* returntype, std::string name, t_struct* arglist, bool oneway = false)
: returntype_(returntype), name_(name), arglist_(arglist), oneway_(oneway) {
xceptions_ = new t_struct(NULL);
: returntype_(returntype),
name_(name),
arglist_(arglist),
xceptions_(new t_struct(NULL)),
own_xceptions_(true),
oneway_(oneway) {
if (oneway_ && (!returntype_->is_void())) {
pwarning(1, "Oneway methods should return void.\n");
}
@ -50,6 +54,7 @@ public:
name_(name),
arglist_(arglist),
xceptions_(xceptions),
own_xceptions_(false),
oneway_(oneway) {
if (oneway_ && !xceptions_->get_members().empty()) {
throw std::string("Oneway methods can't throw exceptions.");
@ -59,7 +64,10 @@ public:
}
}
~t_function() {}
~t_function() {
if (own_xceptions_)
delete xceptions_;
}
t_type* get_returntype() const { return returntype_; }
@ -78,6 +86,7 @@ private:
std::string name_;
t_struct* arglist_;
t_struct* xceptions_;
bool own_xceptions_;
bool oneway_;
};

View file

@ -31,6 +31,7 @@
#include "thrift/parse/t_base_type.h"
#include "thrift/parse/t_map.h"
#include "thrift/parse/t_list.h"
#include "thrift/parse/t_set.h"
namespace plugin_output {
template <typename From, typename To>
@ -75,22 +76,28 @@ public:
void resolve_const_value(t_const_value* const_val, t_type* ttype) {
if (ttype->is_map()) {
const std::map<t_const_value*, t_const_value*>& map = const_val->get_map();
std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
const std::map<t_const_value*, t_const_value*, t_const_value::value_compare>& map = const_val->get_map();
std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
resolve_const_value(v_iter->first, ((t_map*)ttype)->get_key_type());
resolve_const_value(v_iter->second, ((t_map*)ttype)->get_val_type());
}
} else if (ttype->is_list() || ttype->is_set()) {
} else if (ttype->is_list()) {
const std::vector<t_const_value*>& val = const_val->get_list();
std::vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
resolve_const_value((*v_iter), ((t_list*)ttype)->get_elem_type());
}
} else if (ttype->is_set()) {
const std::vector<t_const_value*>& val = const_val->get_list();
std::vector<t_const_value*>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
resolve_const_value((*v_iter), ((t_set*)ttype)->get_elem_type());
}
} else if (ttype->is_struct()) {
t_struct* tstruct = (t_struct*)ttype;
const std::map<t_const_value*, t_const_value*>& map = const_val->get_map();
std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
const std::map<t_const_value*, t_const_value*, t_const_value::value_compare>& map = const_val->get_map();
std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {
t_field* field = tstruct->get_field_by_name(v_iter->first->get_string());
if (field == NULL) {
@ -130,8 +137,8 @@ public:
throw "Constants cannot be of type VOID";
}
} else if (const_type->is_map()) {
const std::map<t_const_value*, t_const_value*>& map = constant->get_value()->get_map();
std::map<t_const_value*, t_const_value*>::const_iterator v_iter;
const std::map<t_const_value*, t_const_value*, t_const_value::value_compare>& map = constant->get_value()->get_map();
std::map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
const_val->set_map();
for (v_iter = map.begin(); v_iter != map.end(); ++v_iter) {

Some files were not shown because too many files have changed in this diff Show more