1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/*
* File: sort_CompInt_Impl.c
* Symbol: sort.CompInt-v0.1
* Symbol Type: class
* Babel Version: 0.10.2
* Description: Server-side implementation for sort.CompInt
*
* WARNING: Automatically generated; only changes within splicers preserved
*
* babel-version = 0.10.2
*/
/*
* DEVELOPERS ARE EXPECTED TO PROVIDE IMPLEMENTATIONS
* FOR THE FOLLOWING METHODS BETWEEN SPLICER PAIRS.
*/
/*
* Symbol "sort.CompInt" (version 0.1)
*
* Compare two Integer's. By default, this will sort in increasing order.
*/
#include "sort_CompInt_Impl.h"
#line 26 "../../../../babel/regression/sort/libC/sort_CompInt_Impl.c"
/* DO-NOT-DELETE splicer.begin(sort.CompInt._includes) */
#include <stdlib.h>
#include "sort_Integer.h"
/* DO-NOT-DELETE splicer.end(sort.CompInt._includes) */
#line 31 "sort_CompInt_Impl.c"
/*
* Static class initializer called exactly once before any user-defined method is dispatched
*/
#undef __FUNC__
#define __FUNC__ "impl_sort_CompInt__load"
void
impl_sort_CompInt__load(
void)
{
#line 42 "../../../../babel/regression/sort/libC/sort_CompInt_Impl.c"
/* DO-NOT-DELETE splicer.begin(sort.CompInt._load) */
/* Insert the implementation of the static class initializer method here... */
/* DO-NOT-DELETE splicer.end(sort.CompInt._load) */
#line 48 "sort_CompInt_Impl.c"
}
/*
* Class constructor called when the class is created.
*/
#undef __FUNC__
#define __FUNC__ "impl_sort_CompInt__ctor"
void
impl_sort_CompInt__ctor(
/* in */ sort_CompInt self)
{
#line 57 "../../../../babel/regression/sort/libC/sort_CompInt_Impl.c"
/* DO-NOT-DELETE splicer.begin(sort.CompInt._ctor) */
struct sort_CompInt__data *dptr =
malloc(sizeof(struct sort_CompInt__data));
if (dptr) {
dptr->d_increasing = TRUE;
}
sort_CompInt__set_data(self, dptr);
/* DO-NOT-DELETE splicer.end(sort.CompInt._ctor) */
#line 70 "sort_CompInt_Impl.c"
}
/*
* Class destructor called when the class is deleted.
*/
#undef __FUNC__
#define __FUNC__ "impl_sort_CompInt__dtor"
void
impl_sort_CompInt__dtor(
/* in */ sort_CompInt self)
{
#line 78 "../../../../babel/regression/sort/libC/sort_CompInt_Impl.c"
/* DO-NOT-DELETE splicer.begin(sort.CompInt._dtor) */
struct sort_CompInt__data *dptr =
sort_CompInt__get_data(self);
if (dptr) {
free((void*)dptr);
sort_CompInt__set_data(self, NULL);
}
/* DO-NOT-DELETE splicer.end(sort.CompInt._dtor) */
#line 93 "sort_CompInt_Impl.c"
}
/*
* If increasing is true, this will cause the comparator to
* report a normal definition of less than; otherwise, it will
* reverse the normal ordering.
*/
#undef __FUNC__
#define __FUNC__ "impl_sort_CompInt_setSortIncreasing"
void
impl_sort_CompInt_setSortIncreasing(
/* in */ sort_CompInt self,
/* in */ sidl_bool increasing)
{
#line 102 "../../../../babel/regression/sort/libC/sort_CompInt_Impl.c"
/* DO-NOT-DELETE splicer.begin(sort.CompInt.setSortIncreasing) */
struct sort_CompInt__data *dptr =
sort_CompInt__get_data(self);
if (dptr) {
dptr->d_increasing = increasing;
}
/* DO-NOT-DELETE splicer.end(sort.CompInt.setSortIncreasing) */
#line 118 "sort_CompInt_Impl.c"
}
/*
* This method is used to define an ordering of objects. This method
* will return -1 if i1 < i2, 0 if i1 = i2; and 1 if i1 > i2.
*/
#undef __FUNC__
#define __FUNC__ "impl_sort_CompInt_compare"
int32_t
impl_sort_CompInt_compare(
/* in */ sort_CompInt self,
/* in */ sidl_BaseInterface i1,
/* in */ sidl_BaseInterface i2)
{
#line 125 "../../../../babel/regression/sort/libC/sort_CompInt_Impl.c"
/* DO-NOT-DELETE splicer.begin(sort.CompInt.compare) */
int result = 0;
struct sort_CompInt__data *dptr =
sort_CompInt__get_data(self);
if (dptr) {
sort_Integer int1 = sort_Integer__cast(i1);
sort_Integer int2 = sort_Integer__cast(i2);
if (int1 && int2) {
const int32_t val1 = sort_Integer_getValue(int1);
const int32_t val2 = sort_Integer_getValue(int2);
if (val1 < val2) result = -1;
if (val1 > val2) result = 1;
if (!dptr->d_increasing) {
result = -result;
}
}
}
return result;
/* DO-NOT-DELETE splicer.end(sort.CompInt.compare) */
#line 155 "sort_CompInt_Impl.c"
}
|