2017-10-03 18:55:50 +00:00
# Contributing to Cutter
There are many ways you can contribute to cutter.
The easy one is to open issues with bugs you found on the application.
The second one is to fix issues found in the GitHub issues tracker.
## Opening an issue
Make a clear description of the bug/feature, use screenshots, send binaries, etc.
## Contributing to the code
Note that cutter is still under development and many parts of the code are to be improved.
2017-10-09 18:08:35 +00:00
### CutterCore class
2018-05-04 08:11:10 +00:00
This is the main class where every link with r2 is made. It is *unique* accross the whole process. To access it, simply call `Core()` .
Example:
```c++
Core()->getOffset();
```
2017-10-09 18:08:35 +00:00
2017-10-03 18:55:50 +00:00
### Calling a radare2 command
There are two ways to do it:
* `CutterCore::cmd()` *(Discouraged)* Only use it for commands which yells no output
* `CutterCore::cmdj()` To be used with json commands like `cmdj("agj")` or `cmdj("aflj")` . It is way easier to parse a json output.
2018-05-04 08:11:10 +00:00
Example:
```c++
QJsonArray array = Core()->cmdj("pdj 1 @ main").array();
```
2017-10-03 18:55:50 +00:00
### Seek the current file
2017-10-09 18:08:35 +00:00
To modify radare2 seek use `CutterCore::seek(const RVA offset)` . This is important because it will emit a `CutterCore::seekChanged(RVA offset)` signal.
2018-05-04 08:11:10 +00:00
Never ever call `cmd("s offset")` ;
Example:
```c++
Core()->seek(0xdeadbeef);
```
2017-10-03 18:55:50 +00:00
### Creating a widget
2017-10-09 18:08:35 +00:00
Make sure to connect the `CutterCore::seekChanged(RVA offset)` signal so your widget refreshes its output when radare2 seek is modified (switching to another function, etc.).
2017-10-03 18:55:50 +00:00
## General coding guidelines
2018-05-04 08:11:10 +00:00
### Coding style
2017-04-09 20:04:01 +00:00
2018-03-21 20:32:32 +00:00
We follow [these guidelines ](https://wiki.qt.io/Qt_Coding_Style ) to format the code.
If in doubt, you can use [AStyle 2.06 ](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.06/ ) to format the code. The command line for formatting the code according to the style is:
2017-04-09 20:04:01 +00:00
```bash
2018-03-21 22:10:35 +00:00
astyle --project=src/Cutter.astylerc src/filename.cpp
2017-04-09 20:04:01 +00:00
```
2018-05-04 08:11:10 +00:00
#### Loops
We use C++11 foreach loop style which means any "foreach" loop should look like:
```c++
for (QJsonValue value : importsArray) {
doSomething(value);
}
```
#### Nullptr
Please do not use `0` nor `Q_NULLPTR` , only use `nullptr` .
Example:
```c++
QObject *object = nullptr;
```
#### Connecting signals
To connect a signal to a slot, this is the preferred way to do it:
```c++
connect(sender, & QObject::destroyed, this, &MyObject::objectDestroyed);
```
The main reason is that this syntax allows the use of lambda functions.
2018-03-21 20:32:32 +00:00
### Functions documentation
It's good to add some documentation to your functions when needed. To do so we follow these [rules ](http://doc.qt.io/qt-5/qdoc-guide-writing.html ).