mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 20:36:53 +01:00
218 lines
5.7 KiB
Plaintext
218 lines
5.7 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "858dddfa",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import ipywidgets as widgets"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "94eff880",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"l = widgets.Label(value=\"Input:\")\n",
|
|
"ta = widgets.Textarea(layout=widgets.Layout(width='80%', height='200px'))\n",
|
|
"b = widgets.Button(description='Convert',tooltip='Convert',icon='check')\n",
|
|
"\n",
|
|
"ol = widgets.Label(value=\"Output:\")\n",
|
|
"\n",
|
|
"olh = widgets.Label(value=\"JSON:\")\n",
|
|
"otah = widgets.Output(layout={'border': '1px solid black'})\n",
|
|
"\n",
|
|
"ool = widgets.Label(value=\"Output:\")\n",
|
|
"out = widgets.Output(layout={'border': '1px solid black'})\n",
|
|
"\n",
|
|
"vbi = widgets.VBox([ l, ta, b])\n",
|
|
"vbo = widgets.VBox([ol, olh, otah, ool, out])\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "74160baa",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"if 'transform_input' in globals():\n",
|
|
" b.on_click(transform_input, True)\n",
|
|
"\n",
|
|
"def transform_input(b):\n",
|
|
" with out:\n",
|
|
" out.clear_output()\n",
|
|
" \n",
|
|
" with otah:\n",
|
|
" otah.clear_output()\n",
|
|
"\n",
|
|
" lines = ta.value.split('\\n')\n",
|
|
" \n",
|
|
" for l in lines:\n",
|
|
" if l.strip() == '':\n",
|
|
" #with otah:\n",
|
|
" # print('')\n",
|
|
" \n",
|
|
" continue\n",
|
|
" \n",
|
|
" with out:\n",
|
|
" print('line:')\n",
|
|
" print(l)\n",
|
|
" print('')\n",
|
|
" \n",
|
|
" if '//' in l:\n",
|
|
" #with otah:\n",
|
|
" # print(' ')\n",
|
|
" continue\n",
|
|
"\n",
|
|
" l = l.replace(';', '').strip()\n",
|
|
" l = l.replace('inline', '').strip()\n",
|
|
" l = l.replace('_FORCE_INLINE_', '').strip()\n",
|
|
" l = l.replace('GDAPI', '').strip()\n",
|
|
" l = l.replace(' ', ' ').strip()\n",
|
|
" l = l.replace(' ', ' ').strip()\n",
|
|
" l = l.replace(' ', ' ').strip()\n",
|
|
" l = l.replace(')', '').strip()\n",
|
|
" l = l.strip()\n",
|
|
" \n",
|
|
" data = {}\n",
|
|
" \n",
|
|
" method_def_and_argss = l.split('(')\n",
|
|
" \n",
|
|
" if len(method_def_and_argss) < 2:\n",
|
|
" #with otah:\n",
|
|
" # print(' ')\n",
|
|
" continue\n",
|
|
" \n",
|
|
" method_ret_and_name = method_def_and_argss[0]\n",
|
|
" method_ret_and_name_s = method_ret_and_name.split(' ')\n",
|
|
" \n",
|
|
" method_return_type = ' '.join(method_ret_and_name_s[:-1]).strip()\n",
|
|
" method_name = ' '.join(method_ret_and_name_s[len(method_ret_and_name_s) - 1:]).strip()\n",
|
|
" \n",
|
|
" if '*' in method_name:\n",
|
|
" method_name = method_name.replace('*', '')\n",
|
|
" method_return_type += ' *'\n",
|
|
" \n",
|
|
" data['name'] = method_name\n",
|
|
" data['return_type'] = method_return_type\n",
|
|
" \n",
|
|
" \n",
|
|
" method_all_args = method_def_and_argss[1]\n",
|
|
" method_all_argss = method_all_args.split(',')\n",
|
|
" \n",
|
|
" method_args = []\n",
|
|
" \n",
|
|
" for ma in method_all_argss:\n",
|
|
" mas = ma.split(' ')\n",
|
|
" \n",
|
|
" marg_type = ' '.join(mas[:-1]).strip()\n",
|
|
" marg_name = ' '.join(mas[len(mas) - 1:]).strip()\n",
|
|
" \n",
|
|
" sc = marg_name.count('*')\n",
|
|
" \n",
|
|
" marg_name = marg_name.replace('*', '')\n",
|
|
" \n",
|
|
" if sc > 0:\n",
|
|
" marg_type += ' ' + '*' * sc\n",
|
|
" \n",
|
|
" method_args.append([ marg_type, marg_name ])\n",
|
|
" \n",
|
|
" \n",
|
|
" \n",
|
|
" data['arguments'] = method_args\n",
|
|
" \n",
|
|
" \n",
|
|
" s = l\n",
|
|
" \n",
|
|
" \n",
|
|
" with otah:\n",
|
|
" #print(method_return_type)\n",
|
|
" #print(method_name)\n",
|
|
" #print(method_args)\n",
|
|
" \n",
|
|
" print(str(data).replace(\"'\", '\"') + ',')\n",
|
|
" \n",
|
|
" with out:\n",
|
|
" print(str(l))\n",
|
|
"\n",
|
|
"\n",
|
|
"b.on_click(transform_input)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "730e99a0",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Input"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a78d6458",
|
|
"metadata": {
|
|
"scrolled": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"display(vbi)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "1662e017",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Output"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "fae586c3",
|
|
"metadata": {
|
|
"scrolled": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"display(vbo)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a84ec551",
|
|
"metadata": {},
|
|
"source": [
|
|
" "
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.10"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|