Skip to content

Commit 07e4bb3

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 9ceae15 + b2d550f commit 07e4bb3

File tree

20 files changed

+295
-91
lines changed

20 files changed

+295
-91
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
1717

1818
include(ExternalProject)
19+
include(CheckLibraryExists)
1920

2021
enable_testing()
2122

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ Then build and test with CMake __in the build subdirectory created by the gradle
125125
C# Build
126126
--------
127127

128-
See [readme.md](https://github.com/real-logic/simple-binary-encoding/tree/master/vs2013) in vs2013 directory
128+
See [README.md](https://github.com/real-logic/simple-binary-encoding/tree/master/vs2013) in vs2013 directory
129+
130+
131+
Python Support
132+
--------------
133+
134+
See [README.md](https://github.com/real-logic/simple-binary-encoding/tree/master/examples/python) in python directory.
129135

130136

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
2828
defaultTasks 'clean', 'build', 'shadowJar', 'install'
2929

3030
group = 'uk.co.real-logic'
31-
version = '1.1.1-RC2-SNAPSHOT'
31+
version = '1.1.2-RC2-SNAPSHOT'
3232
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
3333

3434
ext {
@@ -78,7 +78,7 @@ sourceSets {
7878
dependencies {
7979
checkstyle "com.github.sevntu.checkstyle:sevntu-checks:1.13.4"
8080

81-
compile 'uk.co.real-logic:Agrona:0.4'
81+
compile 'uk.co.real-logic:Agrona:0.4.1'
8282

8383
testCompile 'org.hamcrest:hamcrest-all:1.3',
8484
'junit:junit:4.12',

examples/cpp98/SbeOtfDecoder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
#include <stdlib.h>
2121
#include <stdint.h>
2222
#else
23+
#define __STDC_LIMIT_MACROS 1
24+
#include <stdint.h>
2325
#include <sys/types.h>
2426
#include <sys/uio.h>
2527
#include <unistd.h>
2628
#include <sys/stat.h>
2729
#include <stdio.h>
2830
#include <stdlib.h>
29-
#include <stdint.h>
3031
#endif /* WIN32 */
3132

3233
#include <iostream>

examples/python/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
baseline/*
2+
car.bin

examples/python/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Simple test programs demonstrating encoding and decoding with python
2+
3+
based on work originally by Mark McIlroy (https://github.com/mmcilroy/sbe_tests)
4+
5+
First build SBE as usual \(see [README.md](https://github.com/real-logic/simple-binary-encoding)\)
6+
```
7+
# SBE Jar file will be in simple-binary-encoding/build/libs
8+
#
9+
SBE_JAR=some/path/to/sbe.jar
10+
SCHEMA_XML=../resources/example-schema.xml
11+
12+
# generate python code
13+
java -Dsbe.target.language=python -jar ${SBE_JAR} ${SCHEMA_XML}
14+
echo "" > baseline/__init__.py
15+
16+
# encode car using python
17+
python encode_example.py
18+
19+
# decode car using python
20+
python decode_example.py
21+
22+
```

examples/python/decode_example.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import io
2+
from baseline.Car import Car
3+
4+
length = 129
5+
inp = io.open('car.bin', 'rb')
6+
buffer = inp.read(length)
7+
8+
# start decoding
9+
car = Car()
10+
car.wrapForDecode(buffer, 0, car.sbeBlockLength(), car.sbeSchemaVersion(), length)
11+
12+
# single fixed fields
13+
print('serialNumber: '+str(car.getSerialNumber()))
14+
print('modelYear: '+str(car.getModelYear()))
15+
print('available: '+str(car.getAvailable()))
16+
print('code: '+str(car.getCode()))
17+
18+
# fixed arrays
19+
for i in range(0,car.someNumbersLength()):
20+
print('someNumber'+str(i)+': '+str(car.getSomeNumbers(i)))
21+
22+
for i in range(0,car.vehicleCodeLength()):
23+
print('vehicleCode'+str(i)+': '+str(car.getVehicleCode(i)))
24+
25+
# bitsets
26+
print('cruiseControl: '+str(car.extras().getCruiseControl()))
27+
print('sportsPack: '+str(car.extras().getSportsPack()))
28+
print('sunRoof: '+str(car.extras().getSunRoof()))
29+
30+
# composites
31+
print('capacity: '+str(car.engine().getCapacity()))
32+
print('numCylinders: '+str(car.engine().getNumCylinders()))
33+
print('maxRpm: '+str(car.engine().maxRpm()))
34+
35+
for i in range(0,car.engine().manufacturerCodeLength()):
36+
print('manufacturerCode'+str(i)+': '+str(car.engine().getManufacturerCode(i)))
37+
38+
# groups
39+
figures = car.fuelFigures()
40+
while figures.hasNext():
41+
figures.next()
42+
print('speed: '+str(figures.getSpeed()))
43+
print('mpg: '+str(figures.getMpg()))
44+
45+
figures = car.performanceFigures()
46+
while figures.hasNext():
47+
figures.next()
48+
print('octaneRating: '+str(figures.getOctaneRating()))
49+
acceleration = figures.acceleration()
50+
while acceleration.hasNext():
51+
acceleration.next()
52+
print('mph: '+str(acceleration.getMph()))
53+
print('seconds: '+str(acceleration.getSeconds()))
54+
55+
# variable length
56+
make = car.getMake()
57+
print('make: '+str(make))
58+
59+
model = car.getModel()
60+
print('model: '+str(model))

examples/python/encode_example.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import io
2+
from baseline.Car import Car
3+
from baseline.BooleanType import BooleanType
4+
from baseline.Model import Model
5+
6+
buffer = bytearray(2048)
7+
8+
# start decoding
9+
car = Car()
10+
car.wrapForEncode(buffer, 0, len(buffer))
11+
12+
car.setSerialNumber(1234)
13+
car.setModelYear(2013)
14+
car.setAvailable(BooleanType.TRUE)
15+
car.setCode(Model.A)
16+
17+
# fixed arrays
18+
for i in range(0, car.someNumbersLength()) :
19+
car.setSomeNumbers(i, i)
20+
21+
22+
code = [x for x in 'abcdef']
23+
for i in range(0, car.vehicleCodeLength()):
24+
car.setVehicleCode(i, code[i])
25+
26+
car.extras().setCruiseControl(True)
27+
car.extras().setSportsPack(True)
28+
car.extras().setSunRoof(False)
29+
30+
# composites
31+
car.engine().setCapacity(2000)
32+
car.engine().setNumCylinders(4)
33+
code = [x for x in '123']
34+
for i in range(0, car.engine().manufacturerCodeLength()):
35+
car.engine().setManufacturerCode(i, code[i])
36+
37+
# groups
38+
fuelFigures = car.fuelFiguresCount(3)
39+
for speed, mpg in [(30,35.9), (55,49.0), (75,40.0)]:
40+
fuelFigures.next()
41+
fuelFigures.setSpeed(speed)
42+
fuelFigures.setMpg(mpg)
43+
44+
45+
performanceFigures = car.performanceFiguresCount(2)
46+
47+
performanceFigures.next()
48+
performanceFigures.setOctaneRating(95)
49+
50+
acceleration = performanceFigures.accelerationCount(3)
51+
for mph, seconds in [(30,4.0), (60,7.5), (100,12.2)]:
52+
acceleration.next()
53+
acceleration.setMph(mph)
54+
acceleration.setSeconds(seconds)
55+
56+
performanceFigures.next()
57+
performanceFigures.setOctaneRating(99)
58+
59+
acceleration = performanceFigures.accelerationCount(3)
60+
for mph, seconds in [(30,3.8), (60,7.1), (100,11.8)]:
61+
acceleration.next()
62+
acceleration.setMph(mph)
63+
acceleration.setSeconds(seconds)
64+
65+
# variable length
66+
car.setMake('Honda')
67+
car.setModel('Civic VTi')
68+
69+
length = car.encodedLength()
70+
71+
f = io.open('car.bin', 'wb')
72+
f.write(buffer[:length])
73+
f.close()

main/cpp/otf_api/Ir.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
#define __STDC_LIMIT_MACROS 1
18+
#include <stdint.h>
1719
#include <stdio.h>
1820
#include <iostream>
1921
#include <sys/types.h>

main/cpp/otf_api/Ir.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef _IR_H_
1717
#define _IR_H_
1818

19+
#define __STDC_LIMIT_MACROS 1
1920
#include <stdint.h>
2021
#include <string.h>
2122

@@ -143,6 +144,8 @@ class Ir
143144
* \return Ir for the message
144145
*/
145146
virtual Ir *irForTemplateId(const int templateId, const int version) = 0;
147+
148+
virtual ~Callback() {}
146149
};
147150

148151
// constructors and destructors

0 commit comments

Comments
 (0)