File: python_scripter.h

package info (click to toggle)
kig 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 18,892 kB
  • sloc: cpp: 41,461; xml: 843; python: 486; perl: 23; sh: 17; makefile: 3
file content (55 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download | duplicates (3)
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
// SPDX-FileCopyrightText: 2003 Dominique Devriese <devriese@kde.org>

// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "../objects/common.h"

#include <string>

class KigDocument;
class ObjectImp;

class CompiledPythonScript
{
    friend class PythonScripter;
    class Private;
    Private *const d;
    CompiledPythonScript(Private *);

public:
    CompiledPythonScript(const CompiledPythonScript &s);
    ~CompiledPythonScript();
    ObjectImp *calc(const Args &a, const KigDocument &doc);

    bool valid();
};

class PythonScripter
{
    friend class CompiledPythonScript;
    class Private;
    Private *d;
    PythonScripter();
    ~PythonScripter();

    void clearErrors();
    void saveErrors();

    bool erroroccurred;
    std::string lastexceptiontype;
    std::string lastexceptionvalue;
    std::string lastexceptiontraceback;

public:
    static PythonScripter *instance();

    bool errorOccurred() const;
    std::string lastErrorExceptionType() const;
    std::string lastErrorExceptionValue() const;
    std::string lastErrorExceptionTraceback() const;

    CompiledPythonScript compile(const char *code);
    ObjectImp *calc(CompiledPythonScript &script, const Args &args);
};