mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
build: remove extern "C" linkage
No more C source files, no more necessity to use C-linkage. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
03b910ee7f
commit
b56dd13add
104 changed files with 364 additions and 577 deletions
|
@ -25,26 +25,26 @@
|
|||
* is freed, but the data it references. The object itself is passed in by value.
|
||||
* This is due to the fact how the table macros work.
|
||||
*/
|
||||
extern "C" void free_weightsystem(weightsystem_t ws)
|
||||
void free_weightsystem(weightsystem_t ws)
|
||||
{
|
||||
free((void *)ws.description);
|
||||
ws.description = NULL;
|
||||
}
|
||||
|
||||
extern "C" void free_cylinder(cylinder_t c)
|
||||
void free_cylinder(cylinder_t c)
|
||||
{
|
||||
free((void *)c.type.description);
|
||||
c.type.description = NULL;
|
||||
}
|
||||
|
||||
extern "C" void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d)
|
||||
void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d)
|
||||
{
|
||||
clear_weightsystem_table(d);
|
||||
for (int i = 0; i < s->nr; i++)
|
||||
add_cloned_weightsystem(d, s->weightsystems[i]);
|
||||
}
|
||||
|
||||
extern "C" void copy_cylinders(const struct cylinder_table *s, struct cylinder_table *d)
|
||||
void copy_cylinders(const struct cylinder_table *s, struct cylinder_table *d)
|
||||
{
|
||||
int i;
|
||||
clear_cylinder_table(d);
|
||||
|
@ -76,7 +76,7 @@ const char *cylinderuse_text[NUM_GAS_USE] = {
|
|||
QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen"), QT_TRANSLATE_NOOP("gettextFromC", "not used")
|
||||
};
|
||||
|
||||
extern "C" enum cylinderuse cylinderuse_from_text(const char *text)
|
||||
enum cylinderuse cylinderuse_from_text(const char *text)
|
||||
{
|
||||
for (int i = 0; i < static_cast<int>(NUM_GAS_USE); i++) {
|
||||
if (same_string(text, cylinderuse_text[i]) || same_string(text, translate("gettextFromC", cylinderuse_text[i])))
|
||||
|
@ -178,7 +178,7 @@ weight_t get_weightsystem_weight(const std::string &name)
|
|||
return it != ws_info_table.end() ? it->weight : weight_t();
|
||||
}
|
||||
|
||||
extern "C" weightsystem_t clone_weightsystem(weightsystem_t ws)
|
||||
weightsystem_t clone_weightsystem(weightsystem_t ws)
|
||||
{
|
||||
weightsystem_t res = { ws.weight, copy_string(ws.description), ws.auto_filled };
|
||||
return res;
|
||||
|
@ -186,19 +186,19 @@ extern "C" weightsystem_t clone_weightsystem(weightsystem_t ws)
|
|||
|
||||
/* Add a clone of a weightsystem to the end of a weightsystem table.
|
||||
* Cloned means that the description-string is copied. */
|
||||
extern "C" void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws)
|
||||
void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws)
|
||||
{
|
||||
add_to_weightsystem_table(t, t->nr, clone_weightsystem(ws));
|
||||
}
|
||||
|
||||
extern "C" cylinder_t clone_cylinder(cylinder_t cyl)
|
||||
cylinder_t clone_cylinder(cylinder_t cyl)
|
||||
{
|
||||
cylinder_t res = cyl;
|
||||
res.type.description = copy_string(res.type.description);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern "C" void add_cylinder(struct cylinder_table *t, int idx, cylinder_t cyl)
|
||||
void add_cylinder(struct cylinder_table *t, int idx, cylinder_t cyl)
|
||||
{
|
||||
add_to_cylinder_table(t, idx, cyl);
|
||||
/* FIXME: This is a horrible hack: we make sure that at the end of
|
||||
|
@ -212,18 +212,18 @@ extern "C" void add_cylinder(struct cylinder_table *t, int idx, cylinder_t cyl)
|
|||
|
||||
/* Add a clone of a cylinder to the end of a cylinder table.
|
||||
* Cloned means that the description-string is copied. */
|
||||
extern "C" void add_cloned_cylinder(struct cylinder_table *t, cylinder_t cyl)
|
||||
void add_cloned_cylinder(struct cylinder_table *t, cylinder_t cyl)
|
||||
{
|
||||
add_cylinder(t, t->nr, clone_cylinder(cyl));
|
||||
}
|
||||
|
||||
extern "C" bool same_weightsystem(weightsystem_t w1, weightsystem_t w2)
|
||||
bool same_weightsystem(weightsystem_t w1, weightsystem_t w2)
|
||||
{
|
||||
return w1.weight.grams == w2.weight.grams &&
|
||||
same_string(w1.description, w2.description);
|
||||
}
|
||||
|
||||
extern "C" void get_gas_string(struct gasmix gasmix, char *text, int len)
|
||||
void get_gas_string(struct gasmix gasmix, char *text, int len)
|
||||
{
|
||||
if (gasmix_is_air(gasmix))
|
||||
snprintf(text, len, "%s", translate("gettextFromC", "air"));
|
||||
|
@ -236,21 +236,21 @@ extern "C" void get_gas_string(struct gasmix gasmix, char *text, int len)
|
|||
}
|
||||
|
||||
/* Returns a static char buffer - only good for immediate use by printf etc */
|
||||
extern "C" const char *gasname(struct gasmix gasmix)
|
||||
const char *gasname(struct gasmix gasmix)
|
||||
{
|
||||
static char gas[64];
|
||||
get_gas_string(gasmix, gas, sizeof(gas));
|
||||
return gas;
|
||||
}
|
||||
|
||||
extern "C" int gas_volume(const cylinder_t *cyl, pressure_t p)
|
||||
int gas_volume(const cylinder_t *cyl, pressure_t p)
|
||||
{
|
||||
double bar = p.mbar / 1000.0;
|
||||
double z_factor = gas_compressibility_factor(cyl->gasmix, bar);
|
||||
return lrint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor);
|
||||
}
|
||||
|
||||
extern "C" int find_best_gasmix_match(struct gasmix mix, const struct cylinder_table *cylinders)
|
||||
int find_best_gasmix_match(struct gasmix mix, const struct cylinder_table *cylinders)
|
||||
{
|
||||
int i;
|
||||
int best = -1, score = INT_MAX;
|
||||
|
@ -355,18 +355,18 @@ struct std::vector<ws_info> ws_info_table = {
|
|||
{ QT_TRANSLATE_NOOP("gettextFromC", "clip-on"), weight_t() },
|
||||
};
|
||||
|
||||
extern "C" void remove_cylinder(struct dive *dive, int idx)
|
||||
void remove_cylinder(struct dive *dive, int idx)
|
||||
{
|
||||
remove_from_cylinder_table(&dive->cylinders, idx);
|
||||
}
|
||||
|
||||
extern "C" void remove_weightsystem(struct dive *dive, int idx)
|
||||
void remove_weightsystem(struct dive *dive, int idx)
|
||||
{
|
||||
remove_from_weightsystem_table(&dive->weightsystems, idx);
|
||||
}
|
||||
|
||||
// ws is cloned.
|
||||
extern "C" void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws)
|
||||
void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws)
|
||||
{
|
||||
if (idx < 0 || idx >= dive->weightsystems.nr)
|
||||
return;
|
||||
|
@ -376,7 +376,7 @@ extern "C" void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws)
|
|||
|
||||
/* when planning a dive we need to make sure that all cylinders have a sane depth assigned
|
||||
* and if we are tracking gas consumption the pressures need to be reset to start = end = workingpressure */
|
||||
extern "C" void reset_cylinders(struct dive *dive, bool track_gas)
|
||||
void reset_cylinders(struct dive *dive, bool track_gas)
|
||||
{
|
||||
pressure_t decopo2 = {.mbar = prefs.decopo2};
|
||||
|
||||
|
@ -403,7 +403,7 @@ static void copy_cylinder_type(const cylinder_t *s, cylinder_t *d)
|
|||
}
|
||||
|
||||
/* copy the equipment data part of the cylinders but keep pressures */
|
||||
extern "C" void copy_cylinder_types(const struct dive *s, struct dive *d)
|
||||
void copy_cylinder_types(const struct dive *s, struct dive *d)
|
||||
{
|
||||
int i;
|
||||
if (!s || !d)
|
||||
|
@ -416,7 +416,7 @@ extern "C" void copy_cylinder_types(const struct dive *s, struct dive *d)
|
|||
add_cloned_cylinder(&d->cylinders, *get_cylinder(s, i));
|
||||
}
|
||||
|
||||
extern "C" cylinder_t *add_empty_cylinder(struct cylinder_table *t)
|
||||
cylinder_t *add_empty_cylinder(struct cylinder_table *t)
|
||||
{
|
||||
cylinder_t cyl = empty_cylinder;
|
||||
cyl.type.description = strdup("");
|
||||
|
@ -432,7 +432,7 @@ extern "C" cylinder_t *add_empty_cylinder(struct cylinder_table *t)
|
|||
* Multiple cylinders might be created if the index is bigger than the
|
||||
* number of existing cylinders
|
||||
*/
|
||||
extern "C" cylinder_t *get_cylinder(const struct dive *d, int idx)
|
||||
cylinder_t *get_cylinder(const struct dive *d, int idx)
|
||||
{
|
||||
/* FIXME: The planner uses a dummy cylinder one past the official number of cylinders
|
||||
* in the table to mark no-cylinder surface interavals. This is horrendous. Fix ASAP. */
|
||||
|
@ -444,7 +444,7 @@ extern "C" cylinder_t *get_cylinder(const struct dive *d, int idx)
|
|||
return &d->cylinders.cylinders[idx];
|
||||
}
|
||||
|
||||
extern "C" cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
|
||||
cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
|
||||
{
|
||||
if (idx < 0) {
|
||||
report_info("Warning: accessing invalid cylinder %d", idx);
|
||||
|
@ -456,7 +456,7 @@ extern "C" cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
|
|||
}
|
||||
|
||||
/* if a default cylinder is set, use that */
|
||||
extern "C" void fill_default_cylinder(const struct dive *dive, cylinder_t *cyl)
|
||||
void fill_default_cylinder(const struct dive *dive, cylinder_t *cyl)
|
||||
{
|
||||
const char *cyl_name = prefs.default_cylinder;
|
||||
pressure_t pO2 = {.mbar = static_cast<int>(lrint(prefs.modpO2 * 1000.0))};
|
||||
|
@ -481,7 +481,7 @@ extern "C" void fill_default_cylinder(const struct dive *dive, cylinder_t *cyl)
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" cylinder_t create_new_cylinder(const struct dive *d)
|
||||
cylinder_t create_new_cylinder(const struct dive *d)
|
||||
{
|
||||
cylinder_t cyl = empty_cylinder;
|
||||
fill_default_cylinder(d, &cyl);
|
||||
|
@ -537,7 +537,7 @@ static bool show_cylinder(const struct dive *d, int i)
|
|||
}
|
||||
|
||||
/* The unused cylinders at the end of the cylinder list are hidden. */
|
||||
extern "C" int first_hidden_cylinder(const struct dive *d)
|
||||
int first_hidden_cylinder(const struct dive *d)
|
||||
{
|
||||
int res = d->cylinders.nr;
|
||||
while (res > 0 && !show_cylinder(d, res - 1))
|
||||
|
@ -546,7 +546,7 @@ extern "C" int first_hidden_cylinder(const struct dive *d)
|
|||
}
|
||||
|
||||
#ifdef DEBUG_CYL
|
||||
extern "C" void dump_cylinders(struct dive *dive, bool verbose)
|
||||
void dump_cylinders(struct dive *dive, bool verbose)
|
||||
{
|
||||
printf("Cylinder list:\n");
|
||||
for (int i = 0; i < dive->cylinders; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue