Browse Source

Easier to find 'static inline'

Scott Lahteine 7 years ago
parent
commit
a4b0148365

+ 3
- 3
Marlin/src/feature/bedlevel/ubl/ubl.h View File

215
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
215
      * z_correction_for_x_on_horizontal_mesh_line is an optimization for
216
      * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
216
      * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
217
      */
217
      */
218
-    inline static float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
218
+    static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
219
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
219
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
220
         #if ENABLED(DEBUG_LEVELING_FEATURE)
220
         #if ENABLED(DEBUG_LEVELING_FEATURE)
221
           if (DEBUGGING(LEVELING)) {
221
           if (DEBUGGING(LEVELING)) {
249
     //
249
     //
250
     // See comments above for z_correction_for_x_on_horizontal_mesh_line
250
     // See comments above for z_correction_for_x_on_horizontal_mesh_line
251
     //
251
     //
252
-    inline static float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
252
+    static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
253
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
253
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
254
         #if ENABLED(DEBUG_LEVELING_FEATURE)
254
         #if ENABLED(DEBUG_LEVELING_FEATURE)
255
           if (DEBUGGING(LEVELING)) {
255
           if (DEBUGGING(LEVELING)) {
362
       static void line_to_destination_cartesian(const float &fr, const uint8_t e);
362
       static void line_to_destination_cartesian(const float &fr, const uint8_t e);
363
     #endif
363
     #endif
364
 
364
 
365
-    inline static bool mesh_is_valid() {
365
+    static inline bool mesh_is_valid() {
366
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
366
       for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
367
         for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
367
         for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
368
           if (isnan(z_values[x][y])) return false;
368
           if (isnan(z_values[x][y])) return false;

+ 15
- 15
Marlin/src/gcode/parser.h View File

175
   FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
175
   FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
176
 
176
 
177
   // Seen a parameter with a value
177
   // Seen a parameter with a value
178
-  inline static bool seenval(const char c) { return seen(c) && has_value(); }
178
+  static inline bool seenval(const char c) { return seen(c) && has_value(); }
179
 
179
 
180
   // Float removes 'E' to prevent scientific notation interpretation
180
   // Float removes 'E' to prevent scientific notation interpretation
181
-  inline static float value_float() {
181
+  static inline float value_float() {
182
     if (value_ptr) {
182
     if (value_ptr) {
183
       char *e = value_ptr;
183
       char *e = value_ptr;
184
       for (;;) {
184
       for (;;) {
198
   }
198
   }
199
 
199
 
200
   // Code value as a long or ulong
200
   // Code value as a long or ulong
201
-  inline static int32_t value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
202
-  inline static uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
201
+  static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, NULL, 10) : 0L; }
202
+  static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, NULL, 10) : 0UL; }
203
 
203
 
204
   // Code value for use as time
204
   // Code value for use as time
205
   FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
205
   FORCE_INLINE static millis_t value_millis() { return value_ulong(); }
208
   // Reduce to fewer bits
208
   // Reduce to fewer bits
209
   FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
209
   FORCE_INLINE static int16_t value_int() { return (int16_t)value_long(); }
210
   FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
210
   FORCE_INLINE static uint16_t value_ushort() { return (uint16_t)value_long(); }
211
-  inline static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
211
+  static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
212
 
212
 
213
   // Bool is true with no value or non-zero
213
   // Bool is true with no value or non-zero
214
-  inline static bool value_bool() { return !has_value() || !!value_byte(); }
214
+  static inline bool value_bool() { return !has_value() || !!value_byte(); }
215
 
215
 
216
   // Units modes: Inches, Fahrenheit, Kelvin
216
   // Units modes: Inches, Fahrenheit, Kelvin
217
 
217
 
220
     // Init linear units by constructor
220
     // Init linear units by constructor
221
     GCodeParser() { set_input_linear_units(LINEARUNIT_MM); }
221
     GCodeParser() { set_input_linear_units(LINEARUNIT_MM); }
222
 
222
 
223
-    inline static void set_input_linear_units(const LinearUnit units) {
223
+    static inline void set_input_linear_units(const LinearUnit units) {
224
       switch (units) {
224
       switch (units) {
225
         case LINEARUNIT_INCH:
225
         case LINEARUNIT_INCH:
226
           linear_unit_factor = 25.4f;
226
           linear_unit_factor = 25.4f;
233
       volumetric_unit_factor = POW(linear_unit_factor, 3);
233
       volumetric_unit_factor = POW(linear_unit_factor, 3);
234
     }
234
     }
235
 
235
 
236
-    inline static float axis_unit_factor(const AxisEnum axis) {
236
+    static inline float axis_unit_factor(const AxisEnum axis) {
237
       return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
237
       return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
238
     }
238
     }
239
 
239
 
240
-    inline static float value_linear_units()                     { return value_float() * linear_unit_factor; }
241
-    inline static float value_axis_units(const AxisEnum axis)    { return value_float() * axis_unit_factor(axis); }
242
-    inline static float value_per_axis_unit(const AxisEnum axis) { return value_float() / axis_unit_factor(axis); }
240
+    static inline float value_linear_units()                     { return value_float() * linear_unit_factor; }
241
+    static inline float value_axis_units(const AxisEnum axis)    { return value_float() * axis_unit_factor(axis); }
242
+    static inline float value_per_axis_unit(const AxisEnum axis) { return value_float() / axis_unit_factor(axis); }
243
 
243
 
244
   #else
244
   #else
245
 
245
 
251
 
251
 
252
   #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
252
   #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
253
 
253
 
254
-    inline static void set_input_temp_units(TempUnit units) { input_temp_units = units; }
254
+    static inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
255
 
255
 
256
     #if ENABLED(ULTIPANEL) && DISABLED(DISABLE_M503)
256
     #if ENABLED(ULTIPANEL) && DISABLED(DISABLE_M503)
257
 
257
 
261
       FORCE_INLINE static const char* temp_units_name() {
261
       FORCE_INLINE static const char* temp_units_name() {
262
         return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
262
         return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
263
       }
263
       }
264
-      inline static float to_temp_units(const float &f) {
264
+      static inline float to_temp_units(const float &f) {
265
         switch (input_temp_units) {
265
         switch (input_temp_units) {
266
           case TEMPUNIT_F:
266
           case TEMPUNIT_F:
267
             return f * 0.5555555556f + 32;
267
             return f * 0.5555555556f + 32;
275
 
275
 
276
     #endif // ULTIPANEL && !DISABLE_M503
276
     #endif // ULTIPANEL && !DISABLE_M503
277
 
277
 
278
-    inline static float value_celsius() {
278
+    static inline float value_celsius() {
279
       const float f = value_float();
279
       const float f = value_float();
280
       switch (input_temp_units) {
280
       switch (input_temp_units) {
281
         case TEMPUNIT_F:
281
         case TEMPUNIT_F:
288
       }
288
       }
289
     }
289
     }
290
 
290
 
291
-    inline static float value_celsius_diff() {
291
+    static inline float value_celsius_diff() {
292
       switch (input_temp_units) {
292
       switch (input_temp_units) {
293
         case TEMPUNIT_F:
293
         case TEMPUNIT_F:
294
           return value_float() * 0.5555555556f;
294
           return value_float() * 0.5555555556f;

+ 1
- 1
Marlin/src/libs/buzzer.h View File

82
      * @brief Resets the state of the class
82
      * @brief Resets the state of the class
83
      * @details Brings the class state to a known one.
83
      * @details Brings the class state to a known one.
84
      */
84
      */
85
-    inline static void reset() {
85
+    static inline void reset() {
86
       off();
86
       off();
87
       state.endtime = 0;
87
       state.endtime = 0;
88
     }
88
     }

+ 1
- 1
Marlin/src/module/planner.h View File

361
        *  Returns 1.0 if planner.z_fade_height is 0.0.
361
        *  Returns 1.0 if planner.z_fade_height is 0.0.
362
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
362
        *  Returns 0.0 if Z is past the specified 'Fade Height'.
363
        */
363
        */
364
-      inline static float fade_scaling_factor_for_z(const float &rz) {
364
+      static inline float fade_scaling_factor_for_z(const float &rz) {
365
         static float z_fade_factor = 1;
365
         static float z_fade_factor = 1;
366
         if (z_fade_height) {
366
         if (z_fade_height) {
367
           if (rz >= z_fade_height) return 0;
367
           if (rz >= z_fade_height) return 0;

+ 9
- 10
Marlin/src/module/planner_bezier.cpp View File

45
 #define SIGMA 0.1f
45
 #define SIGMA 0.1f
46
 
46
 
47
 // Compute the linear interpolation between two real numbers.
47
 // Compute the linear interpolation between two real numbers.
48
-inline static float interp(float a, float b, float t) { return (1 - t) * a + t * b; }
48
+static inline float interp(const float &a, const float &b, const float &t) { return (1 - t) * a + t * b; }
49
 
49
 
50
 /**
50
 /**
51
  * Compute a Bézier curve using the De Casteljau's algorithm (see
51
  * Compute a Bézier curve using the De Casteljau's algorithm (see
53
  * easy to code and has good numerical stability (very important,
53
  * easy to code and has good numerical stability (very important,
54
  * since Arudino works with limited precision real numbers).
54
  * since Arudino works with limited precision real numbers).
55
  */
55
  */
56
-inline static float eval_bezier(float a, float b, float c, float d, float t) {
57
-  float iab = interp(a, b, t);
58
-  float ibc = interp(b, c, t);
59
-  float icd = interp(c, d, t);
60
-  float iabc = interp(iab, ibc, t);
61
-  float ibcd = interp(ibc, icd, t);
62
-  float iabcd = interp(iabc, ibcd, t);
63
-  return iabcd;
56
+static inline float eval_bezier(const float &a, const float &b, const float &c, const float &d, const float &t) {
57
+  const float iab = interp(a, b, t),
58
+              ibc = interp(b, c, t),
59
+              icd = interp(c, d, t),
60
+              iabc = interp(iab, ibc, t),
61
+              ibcd = interp(ibc, icd, t);
62
+  return interp(iabc, ibcd, t);
64
 }
63
 }
65
 
64
 
66
 /**
65
 /**
67
  * We approximate Euclidean distance with the sum of the coordinates
66
  * We approximate Euclidean distance with the sum of the coordinates
68
  * offset (so-called "norm 1"), which is quicker to compute.
67
  * offset (so-called "norm 1"), which is quicker to compute.
69
  */
68
  */
70
-inline static float dist1(float x1, float y1, float x2, float y2) { return ABS(x1 - x2) + ABS(y1 - y2); }
69
+static inline float dist1(const float &x1, const float &y1, const float &x2, const float &y2) { return ABS(x1 - x2) + ABS(y1 - y2); }
71
 
70
 
72
 /**
71
 /**
73
  * The algorithm for computing the step is loosely based on the one in Kig
72
  * The algorithm for computing the step is loosely based on the one in Kig

+ 2
- 2
Marlin/src/module/stepper.h View File

435
     #endif
435
     #endif
436
 
436
 
437
     // Set the current position in steps
437
     // Set the current position in steps
438
-    inline static void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
438
+    static inline void set_position(const int32_t &a, const int32_t &b, const int32_t &c, const int32_t &e) {
439
       planner.synchronize();
439
       planner.synchronize();
440
       const bool was_enabled = STEPPER_ISR_ENABLED();
440
       const bool was_enabled = STEPPER_ISR_ENABLED();
441
       if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
441
       if (was_enabled) DISABLE_STEPPER_DRIVER_INTERRUPT();
443
       if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
443
       if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
444
     }
444
     }
445
 
445
 
446
-    inline static void set_position(const AxisEnum a, const int32_t &v) {
446
+    static inline void set_position(const AxisEnum a, const int32_t &v) {
447
       planner.synchronize();
447
       planner.synchronize();
448
 
448
 
449
       #ifdef __AVR__
449
       #ifdef __AVR__

Loading…
Cancel
Save