Skip to content

Commit

Permalink
pokemon: Convert to C from C++
Browse files Browse the repository at this point in the history
Most of the application was written in straight C except for
`extern "C"` declarations and using the `_cpp` variant of
`with_view_model`. Removing/cleaning up these, plus rename, were
the only changes.

Additionally, compiled C code ends up being a couple hundred bytes
smaller, than the commit before this did.
  • Loading branch information
kbembedded committed Sep 15, 2023
1 parent 56aceaa commit 1164e99
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pokemon_app.cpp → pokemon_app.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <furi_hal_light.h>
#include <pokemon_icons.h>

#include "views/trade.hpp"
#include "views/select_pokemon.hpp"
#include "views/trade.h"
#include "views/select_pokemon.h"
#include "pokemon_app.h"

const PokemonTable pokemon_table[] = {
Expand Down Expand Up @@ -265,7 +265,7 @@ void free_app(PokemonFap* pokemon_fap) {
pokemon_fap = NULL;
}

extern "C" int32_t pokemon_app(void* p) {
int32_t pokemon_app(void* p) {
UNUSED(p);
//App* app = (App*)pokemon_alloc();
PokemonFap* pokemon_fap = pokemon_alloc();
Expand Down
4 changes: 2 additions & 2 deletions views/select_pokemon.cpp → views/select_pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ View* select_pokemon_alloc(PokemonFap* pokemon_fap) {

view_set_context(view, pokemon_fap);
view_allocate_model(view, ViewModelTypeLockFree, sizeof(PokemonFap**));
with_view_model_cpp(
view, PokemonFap**, model_fap, { *model_fap = pokemon_fap; }, false);
with_view_model(
view, PokemonFap** model_fap, { *model_fap = pokemon_fap; }, false);

view_set_draw_callback(view, select_pokemon_render_callback);
view_set_input_callback(view, select_pokemon_input_callback);
Expand Down
6 changes: 3 additions & 3 deletions views/select_pokemon.hpp → views/select_pokemon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SELECCT_POKEMON_HPP
#define SELECCT_POKEMON_HPP
#ifndef SELECCT_POKEMON_H
#define SELECCT_POKEMON_H

#pragma once

Expand All @@ -10,4 +10,4 @@ View* select_pokemon_alloc(PokemonFap* pokemon_fap);

void select_pokemon_free(PokemonFap* pokemon_fap);

#endif /* SELECCT_POKEMON_HPP */
#endif /* SELECCT_POKEMON_H */
4 changes: 2 additions & 2 deletions views/trade.cpp → views/trade.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ View* trade_alloc(PokemonFap* pokemon_fap) {

view_set_context(view, pokemon_fap);
view_allocate_model(view, ViewModelTypeLockFree, sizeof(PokemonFap**));
with_view_model_cpp(
view, PokemonFap**, model_fap, { *model_fap = pokemon_fap; }, false);
with_view_model(
view, PokemonFap** model_fap, { *model_fap = pokemon_fap; }, false);

view_set_draw_callback(view, trade_draw_callback);
view_set_input_callback(view, trade_input_callback);
Expand Down
6 changes: 3 additions & 3 deletions views/trade.hpp → views/trade.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef TRADE_HPP
#define TRADE_HPP
#ifndef TRADE_H
#define TRADE_H

#pragma once

Expand All @@ -10,4 +10,4 @@ View* trade_alloc(PokemonFap* pokemon_fap);

void trade_free(PokemonFap* pokemon_fap);

#endif /* TRADE_HPP */
#endif /* TRADE_H */

0 comments on commit 1164e99

Please sign in to comment.