diff --git a/.gitignore b/.gitignore index cb2f20b..180e21f 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ src/scanner/PoissonRecon/vbfile tests/scanner/data/inso # file that Cython generate +src/toolpath/_toolpath.cpp src/scanner/scanner.cpp src/printer/printer.cpp src/utils/utils.cpp diff --git a/fluxclient/__init__.py b/fluxclient/__init__.py index 5f32405..f045107 100644 --- a/fluxclient/__init__.py +++ b/fluxclient/__init__.py @@ -18,5 +18,5 @@ def check_platform(): p = "OSX" return (p, platform.architecture()[0]) -__version__ = "1.2.6" +__version__ = "1.3.4" SUPPORT_PCL = check_pcl() diff --git a/fluxclient/commands/fcode.py b/fluxclient/commands/fcode.py index b829606..3a63552 100644 --- a/fluxclient/commands/fcode.py +++ b/fluxclient/commands/fcode.py @@ -1,13 +1,49 @@ +from getpass import getuser import argparse +import time import sys +import os -from io import BytesIO, StringIO +# from io import StringIO PROG_DESCRIPTION = 'Flux fcode/gcode convertor.' PROG_EPILOG = '' +def create_fcode_metadata(options): + from fluxclient import __version__ + + title = os.path.splitext(os.path.basename(options.input))[0] + + md = { + "AUTHOR": getuser(), + "TITLE": title, + "SOFTWARE": "fluxclient-%s-G2F-CLI" % __version__, + "CREATED_AT": time.strftime('%Y-%m-%dT%H:%M:%SZ', + time.localtime(time.time())), + } + + if options.head_error_level is not None: + md['HEAD_ERROR_LEVEL'] = str(options.head_error_level) + if options.correction is not None: + md['CORRECTION'] = str(options.correction) + if options.filament_detect is not None: + md['FILAMENT_DETECT'] = str(options.filament_detect) + md['BACKLASH'] = 'Y' + + if options.preview and os.path.isfile(options.preview): + try: + with open(options.preview, "rb") as f: + previews = (f.read(), ) + except Exception: + previews = () + else: + previews = () + + return md, previews + + def gcode_2_fcode(params=None, input=None, output=None): parser = argparse.ArgumentParser(description=PROG_DESCRIPTION, epilog=PROG_EPILOG) @@ -17,6 +53,9 @@ def gcode_2_fcode(params=None, input=None, output=None): default='EXTRUDER', choices=['EXTRUDER', 'LASER', 'N/A'], help='Set toolhead type, default is EXTRUDER') + parser.add_argument('-p', '--preview', dest='preview', type=str, + default=None, help='Set preview image') + parser.add_argument('--cor', dest='correction', type=str, default=None, choices=['A', 'H', 'N'], help='Set correction, A=ALL, H=Do height only, N=No' @@ -26,49 +65,28 @@ def gcode_2_fcode(params=None, input=None, output=None): parser.add_argument('--fmd', dest='filament_detect', type=str, default=None, choices=['Y', 'N'], help='Set filament detect, only for extruder type') - parser.add_argument(dest='output', type=str, nargs="?", + + parser.add_argument(dest='output', type=str, help='Ouput fcode file') options = parser.parse_args(params) - from fluxclient.utils._utils import GcodeToFcodeCpp - from fluxclient.fcode.g_to_f import GcodeToFcode - - ext_metadata = {} - if options.head_error_level is not None: - ext_metadata['HEAD_ERROR_LEVEL'] = str(options.head_error_level) - if options.correction is not None: - ext_metadata['CORRECTION'] = str(options.correction) - if options.filament_detect is not None: - ext_metadata['FILAMENT_DETECT'] = str(options.filament_detect) - if options.head_type is not None: - ext_metadata['HEAD_TYPE'] = str(options.head_type) - - try: - if options.input: - input = open(options.input, 'r') - - if options.output: - output = BytesIO() - else: - output = sys.stdout.buffer - - if not input: - input = sys.stdin - - conv = GcodeToFcodeCpp(ext_metadata=ext_metadata) - conv.process(input, output) - + from fluxclient.toolpath import GCodeParser, FCodeV1FileWriter - f = open(options.output, "wb"); - f.write(output.getvalue()) - output = f + md, previews = create_fcode_metadata(options) - print(str(conv.md)) + parser = GCodeParser() + processor = FCodeV1FileWriter( + options.output, options.head_type, md, previews) + parser.set_processor(processor) + parser.parse_from_file(options.input) + processor.terminated() - finally: - input.close() - output.close() + errors = processor.errors() + if errors: + for err in errors: + sys.stderr.write(err.decode()) + sys.stderr.write("\n") def fcode_2_gcode(params=None, input=None, output=sys.stdout): @@ -76,35 +94,24 @@ def fcode_2_gcode(params=None, input=None, output=sys.stdout): epilog=PROG_EPILOG) parser.add_argument('-i', dest='input', type=str, help='Input fcode file') - # parser.add_argument('-I', dest='--include-preview', action='store_const', - # const=True, default=False, - # help='Output preview images') - parser.add_argument(dest='output', type=str, nargs="?", + parser.add_argument('-p', '--unpack-preview', dest="unpack_preview", + action='store_const', const=True, default=False, + help='Output preview images') + parser.add_argument(dest='output', type=str, help='Output gcode file') options = parser.parse_args(params) - from fluxclient.fcode.f_to_g import FcodeToGcode + from fluxclient.toolpath import FCodeParser, GCodeFileWriter - try: - if options.input: - input = open(options.input, "rb") + processor = GCodeFileWriter(options.output) + metadata, previews = FCodeParser.from_file(options.input, processor) - if options.output: - output = open(options.output, "w+") + if options.unpack_preview: + if previews: + basename, _ = os.path.splitext(options.output) + with open(basename + ".jpg", "wb") as f: + f.write(previews[0]) else: - output = sys.stdout.buffer - - if not input: - input = sys.stdin.buffer - - parser = FcodeToGcode() - res = parser.upload_content(input.read()) - print("Check file:: " + str(res)); - tmp_output = StringIO() - parser.f_to_g(tmp_output, include_meta=True) - gcode = tmp_output.getvalue(); - output.write(gcode) - finally: - input.close() - output.close() + sys.stderr.write("No previews to unpack\n") + processor.terminated() diff --git a/fluxclient/commands/laser.py b/fluxclient/commands/laser.py index 2542838..2f1c411 100755 --- a/fluxclient/commands/laser.py +++ b/fluxclient/commands/laser.py @@ -1,8 +1,9 @@ from argparse import ArgumentParser, RawTextHelpFormatter +from math import sqrt +import getpass import sys import os -from math import sqrt from PIL import Image @@ -13,17 +14,17 @@ flux_laser usage example: =============================================================================== \033[1ma) Convert single bitmap (Simple)\033[0m -$ flux_laser /my/image1.jpg +$ flux_laser -z 3.0 -o image1.fc bitmap /my/image1.jpg ------------------------------------------------------------------------------- \033[1mb) Convert single bitmap (With coordinate adjust)\033[0m -$ flux_laser @1,2,3,4,5,/my/image2.jpg +$ flux_laser -z 3.0 -o image1.fc bitmap @1,2,3,4,5,/my/image2.jpg Note: '@' is required prefix, 1: is X1, 2: Y1, 3: X2, 4, Y2, 5: Rotate ------------------------------------------------------------------------------- \033[1mc) Process multi image\033[0m -$ flux_laser @1,2,3,4,5,/my/image1.jpg /my/image2.jpg +$ flux_laser -z 3.0 -o image.fc bitmap @1,2,3,4,5,/my/image1.jpg /my/image2.jpg Note: Process image1.jpg with coordinate variable, then process image2.jpg with default @@ -32,17 +33,16 @@ logger = None -def process_svg(options, stream): - from fluxclient.laser.laser_svg import LaserSvg - m_laser_svg = LaserSvg() - count = 0 +def process_svg(options): + from fluxclient.toolpath.svg_factory import SvgImage, SvgFactory + + factory = SvgFactory() for arg in options.images: - name = str(count) if arg.startswith('@'): try: - w, h, x1, y1, x2, y2, rotation, filename = arg[1:].split(",") + x1, y1, x2, y2, rotation, filename = arg[1:].split(",") filename = os.path.expanduser(filename) - w, h = float(w), float(h) + logger.info("Processing image: %r", filename) x1, y1, x2, y2 = float(x1), float(y1), float(x2), float(y2) rotation = float(rotation) @@ -50,59 +50,57 @@ def process_svg(options, stream): logger.error("""SVG Image argument error, syntax: '@width,height,x1,y1,x2,y2,r,/your/image/file/path' Example: 50.2,40.2,-40.2,-30.2,3.1415,/home/flux/myimage.jpg""") - logger.exception("Argument Error") + raise else: filename = os.path.expanduser(arg) - w, h = 100., 100. + logger.info("Processing image: %r", filename) x1, y1 = -50., 50. x2, y2 = 50., -50. rotation = 0. + with open(filename, 'rb') as f: buf = f.read() - m_laser_svg.svgs[name] = m_laser_svg.preprocess(buf) - tmp_buf, tmp_w, tmp_h = m_laser_svg.svgs[name][1] - - m_laser_svg.compute( - name + '_ready', - [tmp_buf, w, h, x1, y1, x2, y2, rotation, 0, 0, b'']) - count += 1 + img = SvgImage(buf) + img.set_preview((0, 0), b"") + img.set_image_coordinate(point1=(x1, y2), point2=(x2, y2), + rotation=rotation) + factory.add_image(img) + return factory - m_laser_svg.export_to_stream(stream, [name + '_ready']) +def process_to_gray_bitmap(filename): + pil_image = Image.open(filename).convert('L') + return pil_image.size[0], pil_image.size[1], pil_image.tobytes() -def process_to_gray_bitmap(image): - # image is a PIL image object - image = image.convert('L') - return image.tobytes() +def process_bitmaps(options): + from fluxclient.toolpath.bitmap_factory import BitmapImage, BitmapFactory -def process_bitmaps(options, stream): - from fluxclient.laser.laser_bitmap import LaserBitmap - from fluxclient.hw_profile import HW_PROFILE - - lb = LaserBitmap() - + factory = BitmapFactory() for arg in options.images: if arg.startswith('@'): try: x1, y1, x2, y2, r, filename = arg[1:].split(",") + logger.info("Processing image: %r", filename) filename = os.path.expanduser(filename) - i = Image.open(filename) - w, h = i.size - lb.add_image(process_to_gray_bitmap(i), w, h, - float(x1), float(y1), float(x2), float(y2), - float(r), thres=options.threshold) + w, h, buf = process_to_gray_bitmap(filename) + image = BitmapImage(buf, size=(w, h), + point1=(float(x1), float(y1)), + point2=(float(x2), float(y2)), + rotation=float(r), + threshold=options.threshold) + factory.add_image(image) except Exception: logger.error("Bitmap Image argument error, syntax:") logger.error("'@x1,y1,x2,y2,r,/your/image/file/path'") logger.error("Example: 50.2,40.2,-40.2,-30.2,3.1415," "/home/flux/myimage.jpg") - logger.exception("Argument Error") + raise else: filename = os.path.expanduser(arg) - i = Image.open(arg) - w, h = i.size + logger.info("Processing image: %r", filename) + w, h, buf = process_to_gray_bitmap(filename) wh_realworld = [w / 472 * 100, h / 472 * 100] # dpi 120 tmp_index = 0 if wh_realworld[0] > wh_realworld[1] else 1 @@ -111,15 +109,34 @@ def process_bitmaps(options, stream): diagonal = sqrt(wh_realworld[0] ** 2 + wh_realworld[1] ** 2) if diagonal * HW_PROFILE['model-1']['radius']: # * 0.96 because pre-move in front of each row - wh_realworld[tmp_index] *= 2 * HW_PROFILE['model-1']['radius'] / diagonal * 0.96 - wh_realworld[1 - tmp_index] *= 2 * HW_PROFILE['model-1']['radius'] / diagonal * 0.96 + wh_realworld[tmp_index] *= 2 * HW_PROFILE['model-1']['radius'] / diagonal * 0.96 # noqa + wh_realworld[1 - tmp_index] *= 2 * HW_PROFILE['model-1']['radius'] / diagonal * 0.96 # noqa + + image = BitmapImage( + buf, size=(w, h), + point1=(wh_realworld[0] / -2, wh_realworld[1] / 2), + point2=(wh_realworld[0] / 2, wh_realworld[1] / -2), + rotation=.0, threshold=options.threshold) + factory.add_image(image) + return factory + + +def create_processor(options, factory): + if options.gcode: + from fluxclient.toolpath import GCodeFileWriter + processor = GCodeFileWriter(options.output) + else: + from fluxclient.toolpath import FCodeV1FileWriter + from fluxclient import __version__ - buf = process_to_gray_bitmap(i) - # print(w, h, len(buf), file=sys.stderr) - lb.add_image(buf, - w, h, wh_realworld[0] / -2, wh_realworld[1] / 2, wh_realworld[0] / 2, wh_realworld[1] / -2, .0, - thres=options.threshold) - lb.export_to_stream(stream) + previews = (factory.generate_preview(), ) + processor = FCodeV1FileWriter( + options.output, "LASER", + {"OBJECT_HEIGHT": str(options.zheight), + "AUTHOR": getpass.getuser(), + "SOFTWARE": "fluxclient %s laser CLI" % __version__}, + previews) + return processor def main(params=sys.argv[1:]): @@ -129,14 +146,32 @@ def main(params=sys.argv[1:]): formatter_class=RawTextHelpFormatter, epilog=PROG_EPILOG) - # Mode options - mode_args = parser.add_mutually_exclusive_group() - mode_args.add_argument('-b', dest='mode', action='store_const', - const="bitmap", help='Bitmap mode') - mode_args.add_argument('-s', dest='mode', action='store_const', - const="svg", help='Svg mode') - parser.add_argument('-t', dest='threshold', type=int, default=128, - help='Threshold for bitmap, default: 128') + subparsers = parser.add_subparsers(help='Select SVG or BITMAP mode', + dest="mode") + + bitmap_parser = subparsers.add_parser('bitmap') + bitmap_parser.add_argument( + '-t', dest='threshold', type=int, default=255, + help='Threshold for bitmap, default: 255') + bitmap_parser.add_argument('--max-engraving-strength', + dest='max_engraving_strength', type=float, + default=1.0, help='Value = 0.0 to 1.0') + bitmap_parser.add_argument('--disable-shading', dest='shading', + action='store_const', const=False, default=True, + help='Disable shading') + + svg_parser = subparsers.add_parser('svg') + svg_parser.add_argument('--engraving-strength', type=float, default=1.0, + dest='engraving_strength', + help='Value = 0.0 to 1.0') + + parser.add_argument('-g', '--gcode', dest='gcode', action='store_const', + const=True, default=False, help='Output gcode') + parser.add_argument('-z', dest='zheight', type=float, help='Object height') + parser.add_argument('--travel-speed', dest='travel_speed', type=int, + default=2400, help='Travel speed') + parser.add_argument('--engraving-speed', dest='engraving_speed', type=int, + default=2400, help='Travel speed') parser.add_argument('--verbose', dest='verbose', action='store_const', const=True, default=False, help='Verbose output') parser.add_argument('-o', dest='output', type=str, default=None, @@ -147,18 +182,33 @@ def main(params=sys.argv[1:]): options = parser.parse_args(params) logger = setup_logger(__name__, debug=options.verbose) - if options.mode == "bitmap": - logger.debug("Use bitmap processor") - processer = process_bitmaps - elif options.mode == "svg": - logger.debug("Use svg processor") - processer = process_svg - else: - logger.debug("Use bitmap processor") - processer = process_bitmaps - - if options.output: - with open(options.output, "w") as f: - processer(options, f) + from fluxclient.toolpath import laser + + if options.output is None: + raise RuntimeError("TODO: stdout not implement") + + if options.mode == "svg": + logger.debug("Process svg") + factory = process_svg(options) + writer = create_processor(options, factory) + logger.info("Calculating...") + laser.svg2laser( + writer, factory, + z_height=options.zheight, + travel_speed=options.travel_speed, + engraving_speed=options.engraving_speed, + engraving_strength=options.engraving_strength) + writer.terminated() else: - processer(options, sys.stdout) + logger.debug("Process bitmap") + factory = process_bitmaps(options) + writer = create_processor(options, factory) + logger.info("Calculating...") + laser.bitmap2laser( + writer, factory, z_height=options.zheight, + travel_speed=options.travel_speed, + engraving_speed=options.engraving_speed, + shading=options.shading, + max_engraving_strength=options.max_engraving_strength) + writer.terminated() + logger.debug("Done") diff --git a/fluxclient/commands/misc/__init__.py b/fluxclient/commands/misc/__init__.py index db219ec..1625a44 100644 --- a/fluxclient/commands/misc/__init__.py +++ b/fluxclient/commands/misc/__init__.py @@ -80,7 +80,7 @@ def start_usb_daemon(logstream): else: raise RuntimeError("Multi usb devices found") - usbprotocol = USBProtocol(usbdev) + usbprotocol = USBProtocol.connect(usbdev) t = threading.Thread(target=usbprotocol.run) t.daemon = True t.start() diff --git a/fluxclient/commands/toolpath.py b/fluxclient/commands/toolpath.py new file mode 100644 index 0000000..e9eef08 --- /dev/null +++ b/fluxclient/commands/toolpath.py @@ -0,0 +1,295 @@ + +from argparse import ArgumentParser +from datetime import datetime +import getpass +import sys +import os + +from fluxclient.commands.misc import setup_logger + +PROG_DESCRIPTION = "Create very toolpath" +PROG_EPILOG = "" +logger = None + + +def prepare_bitmap_factory(options): + from fluxclient.toolpath.bitmap_factory import BitmapImage, BitmapFactory + + factory = BitmapFactory() + for arg in options.images: + if arg.startswith('@'): + try: + x1, y1, x2, y2, r, filename = arg[1:].split(",") + logger.info("Processing image: %r", filename) + filename = os.path.expanduser(filename) + w, h, buf = process_to_gray_bitmap(filename) + image = BitmapImage(buf, size=(w, h), + point1=(float(x1), float(y1)), + point2=(float(x2), float(y2)), + rotation=float(r), + threshold=options.threshold) + factory.add_image(image) + except Exception: + logger.error("Bitmap Image argument error, syntax:") + logger.error("'@x1,y1,x2,y2,r,/your/image/file/path'") + logger.error("Example: 50.2,40.2,-40.2,-30.2,3.1415," + "/home/flux/myimage.jpg") + raise + else: + filename = os.path.expanduser(arg) + logger.info("Processing image: %r", filename) + w, h, buf = process_to_gray_bitmap(filename) + wh_realworld = [w / 472 * 100, h / 472 * 100] # dpi 120 + + tmp_index = 0 if wh_realworld[0] > wh_realworld[1] else 1 + + # shrink the image if needed + diagonal = sqrt(wh_realworld[0] ** 2 + wh_realworld[1] ** 2) + if diagonal * HW_PROFILE['model-1']['radius']: + # * 0.96 because pre-move in front of each row + wh_realworld[tmp_index] *= 2 * HW_PROFILE['model-1']['radius'] / diagonal * 0.96 # noqa + wh_realworld[1 - tmp_index] *= 2 * HW_PROFILE['model-1']['radius'] / diagonal * 0.96 # noqa + + image = BitmapImage( + buf, size=(w, h), + point1=(wh_realworld[0] / -2, wh_realworld[1] / 2), + point2=(wh_realworld[0] / 2, wh_realworld[1] / -2), + rotation=.0, threshold=options.threshold) + factory.add_image(image) + logger.info("Image ready") + return factory + + +def prepare_svg_factory(options): + from fluxclient.toolpath.svg_factory import SvgImage, SvgFactory + + factory = SvgFactory() + for arg in options.images: + if arg.startswith('@'): + try: + x1, y1, x2, y2, rotation, filename = arg[1:].split(",") + filename = os.path.expanduser(filename) + logger.info("Processing image: %r", filename) + x1, y1, x2, y2 = float(x1), float(y1), float(x2), float(y2) + rotation = float(rotation) + + except Exception: + logger.error("""SVG Image argument error, syntax: + '@width,height,x1,y1,x2,y2,r,/your/image/file/path' + Example: 50.2,40.2,-40.2,-30.2,3.1415,/home/flux/myimage.jpg""") + raise + else: + filename = os.path.expanduser(arg) + logger.info("Processing image: %r", filename) + x1, y1 = -50., 50. + x2, y2 = 50., -50. + rotation = 0. + + with open(filename, 'rb') as f: + buf = f.read() + + img = SvgImage(buf) + img.set_preview((0, 0), b"") + img.set_image_coordinate(point1=(x1, y1), point2=(x2, y2), + rotation=rotation) + for error in img.errors: + logger.warning("Ignore SVG patten: %s", error) + factory.add_image(img) + logger.info("Image ready") + return factory + + +def create_output_processor(options, factory, toolhead, metadata): + from fluxclient import __version__ + + metadata = dict(metadata) + metadata.update({ + "CREATED_AT": datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'), + "AUTHOR": getpass.getuser(), + "SOFTWARE": "fluxclient-%s-CLI" % __version__, + "OBJECT_HEIGHT": str(options.zheight)}) + + if options.gcode: + from fluxclient.toolpath import GCodeFileWriter + processor = GCodeFileWriter(options.output) + for k, v in metadata.items(): + processor.append_comment("%s: %s" % (k, v)) + return processor + else: + from fluxclient.toolpath import FCodeV1FileWriter + + previews = (factory.generate_preview(), ) + return FCodeV1FileWriter(options.output, toolhead, metadata, previews) + + +def process_laser(options): + from fluxclient.toolpath import laser + + if options.mode == "svg": + factory = prepare_svg_factory(options) + processor = create_output_processor( + options, factory, "LASER", {"BACKLASH": "Y"}) + laser.svg2laser( + processor, factory, + z_height=options.zheight, + travel_speed=options.travel_speed, + engraving_speed=options.speed, + engraving_strength=options.engraving_strength) + processor.terminated() + elif options.mode == "bitmap": + factory = prepare_bitmap_factory(options) + processor = create_output_processor(options, factory, "LASER", {}) + laser.bitmap2laser( + processor, factory, z_height=options.zheight, + travel_speed=options.travel_speed, + engraving_speed=options.speed, + shading=options.shading, + max_engraving_strength=options.max_engraving_strength) + processor.terminated() + return 0 + + +def process_penholder(options): + from fluxclient.toolpath.penholder import svg2drawing + + factory = prepare_svg_factory(options) + processor = create_output_processor( + options, factory, "N/A", {"BACKLASH": "Y"}) + svg2drawing(processor, factory, travel_speed=options.travel_speed, + drawing_speed=options.speed, + drawing_zheight=options.zheight, + travel_zheight=options.zheight + options.travel_lift) + processor.terminated() + return 0 + + +def process_vinyl(options): + from fluxclient.toolpath.penholder import svg2vinyl + metadata = {"BACKLASH": "Y"} + + if options.precut: + try: + str_x, str_y = options.precut.split(",") + precut = float(str_x), float(str_y) + metadata["PRECUT"] = options.precut + except (TypeError, ValueError): + logger.error("Can not parse --precut, syntax should be two number " + "splited by ','. For example: --precut 12.3,45.6") + return 1 + else: + precut = None + + factory = prepare_svg_factory(options) + processor = create_output_processor( + options, factory, "N/A", metadata) + + svg2vinyl(processor, factory, precut_at=precut, + cutting_speed=options.speed, cutting_zheight=options.zheight, + travel_speed=options.travel_speed, + travel_zheight=options.zheight + options.travel_lift) + processor.terminated() + + +def add_obj_z_arguments(parser, include_travel_lift=False, + default_lift_offset=3.0): + parser.add_argument('-z', '--zheight', dest='zheight', type=float, + required=True, help='Object height (mm)') + if include_travel_lift: + parser.add_argument('--travel-lift', dest='travel_lift', type=float, + default=default_lift_offset, + help='Lift when traveling (mm)') + + +def add_speed_arguments(parser, working_default, travel_default=2400): + parser.add_argument( + '--speed', type=int, default=working_default, dest='speed', + help='Working speed (mm/minute)') + parser.add_argument( + '--travel-speed', type=int, default=travel_default, + dest='travel_speed', help='Travel speed (mm/minute)') + + +def add_default_arguments(parser): + parser.add_argument('--verbose', dest='verbose', action='store_const', + const=True, default=False, help='Verbose output') + parser.add_argument('-g', '--gcode', dest='gcode', action='store_const', + const=True, default=False, help='Output gcode') + parser.add_argument('-i', dest='images', type=str, action='append', + help='Image files') + parser.add_argument('-o', dest='output', type=str, required=True, + help='Output file name') + + +def add_laser_arguments(parser): + subparser = parser.add_subparsers(title="Engraving type", dest="mode") + subparser.required = True + + svg_parser = subparser.add_parser('svg') + add_obj_z_arguments(svg_parser) + add_speed_arguments(svg_parser, 400) + svg_parser.add_argument('--strength', type=float, default=1.0, + dest='engraving_strength', + help='Value: 0.0 to 1.0') + add_default_arguments(svg_parser) + + bitmap_parser = subparser.add_parser('bitmap') + add_obj_z_arguments(bitmap_parser) + add_speed_arguments(bitmap_parser, 400) + bitmap_parser.add_argument( + '-t', '--threshold', dest='threshold', type=int, default=255, + help='Threshold for bitmap, default: 255') + bitmap_parser.add_argument( + '--max-engraving-strength', dest='max_engraving_strength', type=float, + default=1.0, help='Value = 0.0 to 1.0') + bitmap_parser.add_argument( + '--disable-shading', dest='shading', action='store_const', + const=False, default=True, help='Disable shading') + add_default_arguments(bitmap_parser) + + +def get_argument_parser(): + parser = ArgumentParser(description=PROG_DESCRIPTION, + epilog=PROG_EPILOG) + subparsers = parser.add_subparsers(title="Toolpath type", dest="type") + subparsers.required = True + + laser_parser = subparsers.add_parser('laser') + add_laser_arguments(laser_parser) + + penholder_parser = subparsers.add_parser('penholder') + add_obj_z_arguments(penholder_parser, True, 5.0) + add_speed_arguments(penholder_parser, working_default=600) + add_default_arguments(penholder_parser) + + vinyl_parser = subparsers.add_parser('vinyl') + add_obj_z_arguments(vinyl_parser, True, 5.0) + add_speed_arguments(vinyl_parser, working_default=600) + vinyl_parser.add_argument( + '--precut', dest='precut', type=str, + default=None, metavar="23.5,21.2", + help='Pre cut a short line at a point to fix knife direction.') + add_default_arguments(vinyl_parser) + + return parser + + +def main(params=None): + global logger + parser = get_argument_parser() + options = parser.parse_args(params) + logger = setup_logger(__name__, debug=options.verbose) + + if options.type == "laser": + ret = process_laser(options) + elif options.type == "penholder": + ret = process_penholder(options) + elif options.type == "vinyl": + ret = process_vinyl(options) + else: + logger.error("Can not handle type %r", options.type) + ret = 1 + sys.exit(ret) + + +if __name__ == "__main__": + main() diff --git a/fluxclient/device/discover.py b/fluxclient/device/discover.py index 168f370..d212af0 100644 --- a/fluxclient/device/discover.py +++ b/fluxclient/device/discover.py @@ -92,7 +92,8 @@ def __init__(self, uuid=None, device_ipaddr=None, self.uuid = uuid self.device_ipaddr = device_ipaddr - self.handlers = (BroadcastHelper(self), Version1Helper(self)) + self.handlers = (BroadcastHelper(self), Version1Helper(self), + Version2Helper(self)) self.socks = self.create_sockets(mcst_ipaddr, mcst_port) + tuple( (h.sock for h in self.handlers if hasattr(h, "sock"))) @@ -183,6 +184,10 @@ def on_recive(self, sock): # Bad magic number return + if proto_ver > 2: + logger.debug("Protocol %i not support", proto_ver) + return + ret = self.handlers[proto_ver].handle_message(endpoint, action_id, buf[6:]) return ret @@ -200,10 +205,12 @@ def add_master_key(self, uuid, serial, master_key, disc_ver): if device.serial != serial: raise Exception("Device %s got vart master keys", device.serial, serial) + return device else: d = Device(uuid, serial, master_key, disc_ver) d.update_status() self.devices[uuid] = d + return d def get_master_key(self, uuid): return self.devices[uuid].master_key @@ -362,3 +369,103 @@ def _handle_touch(self, endpoint, payload): logger.error("Slave key signuture error (V1)") else: logger.error("Master key signuture error (V1)") + + +class Version2Helper(Helper): + session_cache = None + session_swap = None + + def __init__(self, server): + super(Version2Helper, self).__init__(server) + self.session_cache = {} + self.session_swap = {} + + def _need_touch(self, uuid, session): + device = self.server.devices.get(uuid) + if device and uuid in self.session_cache and \ + self.session_cache[uuid] == session: + return False + else: + return True + + def handle_message(self, endpoint, action_id, payload): + if action_id == 0: + return self._handle_discover(endpoint, payload) + elif action_id == 3: + return self._handle_touch(endpoint, payload) + else: + logger.error("Can not handle proto_ver=1, action_id=%s", action_id) + + def _handle_discover(self, endpoint, payload): + args = struct.unpack("<16s8s", payload[:24]) + uuid_bytes, session = args[:3] + + uuid = UUID(bytes=uuid_bytes) + if not self.server.source_filter(uuid, endpoint): + return + + if self._need_touch(uuid, session): + payload = struct.pack("<4sBB16s", b"FLUX", 2, 2, uuid.bytes) + try: + self.session_swap[uuid] = session + self.sock.sendto(payload, endpoint) + except Exception: + logger.exception("Error while poke %s", endpoint) + else: + try: + st_ts, st_id, st_prog, st_head, st_err = \ + struct.unpack("dif16s32s", payload[24:88]) + + head_module = st_head.decode("ascii", "ignore").strip("\x00") + error_label = st_err.decode("ascii", "ignore").strip("\x00") + device = self.server.devices[uuid] + device.update_status(st_id=st_id, st_ts=st_ts, st_prog=st_prog, + head_module=head_module, + error_label=error_label) + device.discover_endpoint = endpoint + device.ipaddr = endpoint[0] + + return uuid + except Exception: + basic_info = self.server.devices[uuid] + if basic_info.version > StrictVersion("0.13a"): + logger.exception("Unpack status failed") + + def _handle_touch(self, endpoint, payload): + f = BytesIO(payload) + + buuid, l1, l2 = struct.unpack("<16sHH", f.read(20)) + uuid = UUID(bytes=buuid) + + if not self.server.source_filter(uuid, endpoint): + # Ingore this uuid + return + + pubkey_der = f.read(l1) + pubkey_signuture = f.read(l2) + dev_pubkey = KeyObject.load_keyobj(pubkey_der) + + bmeta = f.read(struct.unpack(" 3: + size, channel_idx = HEAD_PACKER.unpack(buf[:3]) + if size % 256 == 0: + buf = buf[1:] + continue + elif len(buf) == size and channel_idx != 0xa0: + data = channel_idx, buf[3:-1], buf[-1] + break + elif len(buf) > size: + buf = buf[size:] + else: + logger.error("Handshake payload size error") + data = None + buf = b"" + + if data: + channel_idx, buf, fin = data + if channel_idx == 0xff and fin == 0xf0: + cls._handle_handshake(handshake_state, buf, tx) + sleep(0.1) + continue + elif channel_idx == 0xfd and fin == 0xf0: + pf = cls._final_handshake(handshake_state, buf, tx) + if pf: + return pf + else: + logger.warning("Recv unexcept channel idx %r and fin " + "%r in handshake", channel_idx, fin) + else: + logger.info("Handshake timeout, retry") + + handshake_state = {} + cls._write(tx, req_handshake_payload) + sleep(1.0) + ttl -= 1 + raise FluxUSBError("Handshake failed.", symbol=("TIMEOUT", )) + + @classmethod + def _write(cls, tx, buf): + # Low level send try: - self.close() - except Exception as e: - logger.error("%s", e) + l = len(buf) + ret = tx.write(buf[:512]) + while ret < l: + ret += tx.write(buf[ret:ret + 512]) + + except usb.core.USBError as e: + if e.errno == ETIMEDOUT or e.backend_error_code == -116: + raise FluxUSBError(*e.args, symbol=("TIMEOUT", )) + else: + logger.error("unhandle libusb error: %s", e) + raise FluxUSBError(*e.args, + symbol=("UNKNOWN_ERROR", + errorcode.get(e.errno, e.errno))) + + @classmethod + def _recv(cls, rx, length, timeout=50): + # Low level recv + try: + # note: thread will dead lock if tiemout is 0 + b = rx.read(length, timeout).tobytes() + return b + except usb.core.USBError as e: + if e.errno == ETIMEDOUT or e.backend_error_code == -116: + return b"" + else: + logger.error("unhandle libusb error: %s", e) + raise FluxUSBError(*e.args) + + @classmethod + def build_object(cls, chl_idx, obj, fin): + data = msgpack.packb(obj) + l = len(data) + 4 + return b"".join((HEAD_PACKER.pack(l, chl_idx), data, BYTE_PACKER.pack(fin))) + + _dev = None + _tx = _rx = None + uuid = None + serial = None + version = None + model_id = None + nickname = None + endpoint_profile = None + + def __init__(self, dev, tx, rx, endpoint_profile): + self._dev = dev + self._tx = tx + self._rx = rx + + self.uuid = UUID(hex=endpoint_profile["uuid"]) + self.serial = endpoint_profile["serial"] + self.version = StrictVersion(endpoint_profile["version"]) + self.model_id = endpoint_profile["model"] + self.nickname = endpoint_profile["nickname"] + self.endpoint_profile = endpoint_profile + self.addr = dev.address + + def close(self): + if self._dev: + usb.util.dispose_resources(self._dev) + self._dev = self._tx = self._rx = None + + def __del__(self): + self.close() + + +class USBProtocol1(USBProtocol): + channels = None + running = False + session = None + device_status = None + timestamp = 0 + _flag = 0 + _buf = b"" + + _enable_ping = False + _wait_ping = False + + def __init__(self, dev, tx, rx, endpoint_profile): + super(USBProtocol1, self).__init__(dev, tx, rx, endpoint_profile) + + self._enable_ping = self.version >= StrictVersion("1.6.3") + self.tx_mutex = Lock() + self.chl_semaphore = Semaphore(0) + self.chl_open_mutex = Lock() + self.channels = {} + self.device_status = {} + self._flag = 1 def _send(self, buf): # Low level send try: - self._tx.write(buf) + l = len(buf) + with self.tx_mutex: + ret = self._tx.write(buf[:512]) + while ret < l: + ret += self._tx.write(buf[ret:ret + 512]) + except usb.core.USBError as e: - self._close_usbdev() + self.close() if e.errno == ETIMEDOUT: raise FluxUSBError(*e.args, symbol=("TIMEOUT", )) else: @@ -103,21 +293,22 @@ def _send(self, buf): def _send_binary_ack(self, channel_idx): self._send(HEAD_PACKER.pack(4, channel_idx) + b"\x80") - def _recv(self, length, timeout=0.001): + def _recv(self, length, timeout): # Low level recv try: # note: thread will dead lock if tiemout is 0 - b = self._rx.read(length, int(timeout * 1000)).tobytes() + b = self._rx.read(length, timeout).tobytes() + self.timestamp = time() return b except usb.core.USBError as e: if e.errno == ETIMEDOUT or e.backend_error_code == -116: return b"" else: - self._close_usbdev() + self.close() raise FluxUSBError(*e.args) - def _feed_buffer(self, timeout=0.05): - self._buf += self._recv(1024, timeout=0.05) + def _feed_buffer(self, timeout=50): + self._buf += self._recv(512, timeout) def _unpack_buffer(self): l = len(self._buf) @@ -133,94 +324,9 @@ def _unpack_buffer(self): fin = self._buf[size - 1] buf = self._buf[3:size - 1] self._buf = self._buf[size:] - self.timestamp = time() return channel_idx, buf, fin return None, None, None - def _handle_handshake(self, buf): - data = msgpack.unpackb(buf, use_list=False, encoding="utf8", - unicode_errors="ignore") - session = data.pop("session", "?") - if self.session is None: - logger.info("Get handshake session: %s", session) - else: - logger.info("Replace handshake session: %s", session) - - self.endpoint_profile = data - self.session = session - self.send_object(0xfe, {"session": self.session, - "client": "fluxclient-%s" % __version__}) - - def _final_handshake(self, buf): - data = msgpack.unpackb(buf, use_list=False, encoding="utf8", - unicode_errors="ignore") - if data["session"] == self.session: - self.uuid = UUID(hex=self.endpoint_profile["uuid"]) - self.serial = self.endpoint_profile["serial"] - self.version = StrictVersion(self.endpoint_profile["version"]) - self.model_id = self.endpoint_profile["model"] - self.nickname = self.endpoint_profile["nickname"] - - if self.version < StrictVersion("1.6.3"): - logger.debug("Disable usb ping/pong.") - self._disable_ping = True - - self._flag |= 1 - logger.info("Host2Host USB Connected") - logger.debug("Serial: %s {%s}\nModel: %s\nName: %s\n", - self.serial, self.uuid, self.model_id, self.nickname) - return True - else: - logger.info("USB final handshake error with wrong session " - "recv=%i, except=%i", data["session"], self.session) - self.session = None - return False - - def do_handshake(self): - ttl = 3 - self._usbdev.ctrl_transfer(0x40, 0xFD, 0, 0) - - self._send(b"\x00" * 1023) - self.send_object(0xfc, None) # Request handshake - while ttl: - bl = -1 - self._buf = b"" - while len(self._buf) != bl: - bl = len(self._buf) - self._feed_buffer(timeout=0.3) - - data = None - while True: - d = self._unpack_buffer() - if d[0] is None: - break - else: - data = d - - if data and data[0] is not None: - channel_idx, buf, fin = data - if channel_idx == 0xff and fin == 0xf0: - self._handle_handshake(buf) - continue - elif channel_idx == 0xfd and fin == 0xf0: - if self.session is not None: - if self._final_handshake(buf): - return True - else: - logger.warning("Recv unexcept final handshake") - elif channel_idx == -1: - logger.warning("Recv 0") - continue - else: - logger.warning("Recv unexcept channel idx %r and fin " - "%r in handshake", channel_idx, fin) - else: - logger.info("Handshake timeout, retry") - - self.send_object(0xfc, None) # Request handshake - ttl -= 1 - raise FluxUSBError("Handshake failed.", symbol=("TIMEOUT", )) - def run_once(self): self._feed_buffer() channel_idx, buf, fin = self._unpack_buffer() @@ -242,6 +348,8 @@ def run_once(self): channel.on_binary_ack() else: raise FluxUSBError("Recv bad fin 0x%02x" % fin) + elif channel_idx == 0xa0 and fin == 0xff: + logger.debug("Recv padding") elif channel_idx == 0xf1: if fin != 0xf0: raise FluxUSBError("Recv bad fin 0x%02x" % fin) @@ -258,7 +366,7 @@ def run(self): self._flag |= 2 while self._flag == 3: self.run_once() - if time() - self.timestamp > 1.0: + if time() - self.timestamp > USBTIMEOUT: self.ping() except FluxUSBError as e: logger.error("USB Error: %s", e) @@ -268,59 +376,50 @@ def run(self): logger.exception("Unknown error") self._flag = 0 self.close() - raise def stop(self): self._flag &= ~2 - def _close_usbdev(self): - if self._usbdev: - if self.channels: - for idx, channel in self.channels.items(): - channel.close(directly=True) - usb.util.dispose_resources(self._usbdev) - self._usbdev = self._tx = self._rx = None - logger.info("Host2Host dev closed") - def close(self): - if self._usbdev: - self.send_object(0xfc, None) - self._close_usbdev() + self._flag = 0 + while self.channels: + idx, channel = self.channels.popitem() + channel.close(directly=True) + super(USBProtocol1, self).close() def ping(self): - if self._disable_ping is True: + if self._enable_ping is False: return if self._wait_ping: raise FluxUSBError("PING/PONG timeout") else: + self.timestamp = time() self._wait_ping = True - self._send(PING_PACKER.pack(4, 0xfa, 0x00)) + self._send(CTRL_PACKER.pack(4, 0xfa, 0x00)) - def send_object(self, channel, obj): - payload = msgpack.packb(obj) - buf = HEAD_PACKER.pack(len(payload) + 4, channel) + payload + b"\xb0" + def send_object(self, chl_idx, obj): + data = msgpack.packb(obj) + l = len(data) + 4 + buf = b"".join((HEAD_PACKER.pack(l, chl_idx), data, b"\xb0")) self._send(buf) - def send_binary(self, channel, buf): - buf = HEAD_PACKER.pack(len(buf) + 4, channel) + buf + b"\xbf" + def send_binary(self, chl_idx, data): + l = len(data) + 4 + buf = b"".join((HEAD_PACKER.pack(l, chl_idx), data, b"\xbf")) self._send(buf) def _on_pong(self, buf): - if self._wait_ping: - self._wait_ping = False - if len(buf) != 64: - logger.error("PONG payload length: %i (should be 64)", - len(buf)) - else: - st_ts, st_id, st_prog, st_th, st_er = DEVST_PACKER.unpack(buf) - self.device_status = { - "timestamp": st_ts, "st_id": st_id, "st_prog": st_prog, - "st_head": st_th.decode("ascii").rstrip("\x00"), - "st_err": st_er.decode("ascii").rstrip("\x00")} + self._wait_ping = False + if len(buf) != 64: + logger.error("PONG payload length: %i (should be 64)", + len(buf)) else: - logger.error("Recv pong but did not ping") - raise FluxUSBError("Protocol error") + st_ts, st_id, st_prog, st_th, st_er = DEVST_PACKER.unpack(buf) + self.device_status = { + "timestamp": st_ts, "st_id": st_id, "st_prog": st_prog, + "st_head": st_th.decode("ascii").rstrip("\x00"), + "st_err": st_er.decode("ascii").rstrip("\x00")} def _on_channel_ctrl_response(self, obj): index = obj.get(b"channel") @@ -365,6 +464,153 @@ def open_channel(self, channel_type="robot", timeout=10.0): raise FluxUSBError("Channel creation failed") +class USBProtocol2(USBProtocol1): + def __init__(self, dev, tx, rx, endpoint_profile): + super(USBProtocol2, self).__init__(dev, tx, rx, endpoint_profile) + self.tx_semaphore = Semaphore(8) + self.tx_mutex2 = Lock() + self._local_queue = deque() + self._local_idx, self._remote_idx = 0, 0 + + def _unpack_buffer(self): + l = len(self._buf) + if l > 6: + size, seq, chl_idx, fin = HEAD_V2_PACKER.unpack(self._buf[:6]) + if size < 6: + raise FluxUSBError("Recv bad usb message size: %i" % size) + elif l >= size: + buf = self._buf[6:size] + self._buf = self._buf[size:] + return seq, chl_idx, fin, buf + return None, None, None, None + + def run(self): + last_ping = -1 + try: + self._flag |= 2 + while self._flag == 3: + self.run_once() + if time() - last_ping > 3.0: + last_ping = time() + self.ping() + + if time() - self.timestamp > 1.4 and self._local_queue: + logger.warning("Resend usb data") + for idx, ack, buf in self._local_queue: + self._send(buf) + self.timestamp = time() + + except FluxUSBError as e: + logger.error("USB Error: %s", e) + self._flag = 0 + self.close() + except Exception: + logger.exception("Unknown error") + self._flag = 0 + self.close() + + def run_once(self): + self._feed_buffer() + seq, channel_idx, fin, buf = self._unpack_buffer() + + if seq is None: + return + elif channel_idx == 0xf2: + # Remote send ack + while self._local_queue: + if self._local_queue[0][0] <= seq or \ + seq < 10000 and self._local_queue[0][0] > 50000: + _, ack, _ = self._local_queue.popleft() + if ack is not None: + channel = self.channels.get(ack) + if channel: + channel.on_binary_ack() + self.tx_semaphore.release() + else: + break + return + + if seq != self._remote_idx: # index not match + logger.debug("Remote seq error, Drop. (%s != %s)", seq, self._remote_idx) + if seq > self._remote_idx or (seq > 65000 and self._remote_idx < 100): + self._send_ack() + return + else: + self._send(HEAD_V2_PACKER.pack(6, self._remote_idx, 0xf2, 0)) + self._remote_idx = (self._remote_idx + 1) % 65536 + + if channel_idx < 0x80: + channel = self.channels.get(channel_idx) + if channel is None: + raise FluxUSBError("Recv bad channel idx 0x%02x" % channel_idx) + if fin == 0: + channel.on_object(msgpack.unpackb(buf, encoding="utf8", + unicode_errors="ignore")) + elif fin == 1: + channel.on_binary(buf) + else: + raise FluxUSBError("Recv bad fin 0x%02x" % (fin)) + elif channel_idx == 0xf1: + if fin == 0: + self._on_channel_ctrl_response(msgpack.unpackb(buf)) + else: + raise FluxUSBError("Recv bad fin 0x%02x" % (fin)) + elif channel_idx == 0xfb: + self._on_pong(buf) + else: + raise FluxUSBError("Recv bad control channel 0x%02x" % channel_idx) + + def _send_ack(self): + if self._remote_idx == 0: + self._send(HEAD_V2_PACKER.pack(6, 65535, 0xf2, 0)) + else: + self._send(HEAD_V2_PACKER.pack(6, self._remote_idx - 1, 0xf2, 0)) + + def send_object(self, chl_idx, obj): + data = msgpack.packb(obj) + l = len(data) + 6 + if l > 512: + raise RuntimeError("Payload size overlimit") + with self.tx_mutex2: + buf = HEAD_V2_PACKER.pack(l, self._local_idx, chl_idx, 0) + data + if self.tx_semaphore.acquire(timeout=15): + if not self._local_queue: + self.timestamp = time() + self._local_queue.append((self._local_idx, None, buf)) + self._local_idx = (self._local_idx + 1) % 65535 + self._send(buf) + else: + raise FluxUSBError("Transmit timeout") + + def send_binary(self, chl_idx, data): + l = len(data) + 6 + if l > 512: + raise RuntimeError("Payload size overlimit") + with self.tx_mutex2: + buf = HEAD_V2_PACKER.pack(l, self._local_idx, chl_idx, 1) + data + if self.tx_semaphore.acquire(timeout=15): + if not self._local_queue: + self.timestamp = time() + self._local_queue.append((self._local_idx, chl_idx, buf)) + self._local_idx = (self._local_idx + 1) % 65535 + self._send(buf) + else: + raise FluxUSBError("Transmit timeout") + + def ping(self): + if self.tx_mutex2.acquire(False): + try: + buf = HEAD_V2_PACKER.pack(6, self._local_idx, 0xfa, 1) + if self.tx_semaphore.acquire(blocking=0): + if not self._local_queue: + self.timestamp = time() + self._local_queue.append((self._local_idx, None, buf)) + self._local_idx = (self._local_idx + 1) % 65535 + self._send(buf) + finally: + self.tx_mutex2.release() + + class Channel(object): binary_stream = None @@ -409,7 +655,7 @@ def on_binary(self, buf): self.bufq.append(buf) self.buf_semaphore.release() - def get_buffer(self, timeout=60.0): + def get_buffer(self, timeout=20.0): if self.buf_semaphore.acquire(timeout=timeout) is False: raise FluxUSBError("Operation timeout", symbol=("TIMEOUT", )) return self.bufq.popleft() diff --git a/fluxclient/device/manager_backends/__init__.py b/fluxclient/device/manager_backends/__init__.py index 7549645..aaab3dd 100644 --- a/fluxclient/device/manager_backends/__init__.py +++ b/fluxclient/device/manager_backends/__init__.py @@ -17,6 +17,7 @@ def get_backend_via_network(device): for klass in (SSL1Backend, Udp1Backend): if klass.support_device(device.model_id, device.version): return klass + raise RuntimeError("NOT_SUPPORT", device.model_id, device.version) def get_backend_via_uuid(uuid, lookup_callback=None, diff --git a/fluxclient/device/manager_backends/host2host1.py b/fluxclient/device/manager_backends/host2host1.py index e24a802..56d25b2 100644 --- a/fluxclient/device/manager_backends/host2host1.py +++ b/fluxclient/device/manager_backends/host2host1.py @@ -25,7 +25,7 @@ def __init__(self, client_key, usbprotocol): def connect(self): self.channel = self.usbprotocol.open_channel("config") self._authorized = True - self.endpoint = "USB:%i@%i" % (self.usbprotocol._usbdev.address, + self.endpoint = "USB:%i@%i" % (self.usbprotocol._dev.address, self.channel.index) def connected(self): diff --git a/fluxclient/device/misc.py b/fluxclient/device/misc.py index 8e03603..ed14ade 100644 --- a/fluxclient/device/misc.py +++ b/fluxclient/device/misc.py @@ -20,6 +20,9 @@ def validate_identify(uuid, identify, serial=None, masterkey_doc=None): if serial == "X" * 10 and uuid.hex.startswith("f" * 16): return True + if serial.startswith("FL") and uuid.hex.startswith("3010"): + return True + if "delta-1" in VK_CACHE: vk = VK_CACHE["delta-1"] else: diff --git a/fluxclient/fcode/f_to_g.py b/fluxclient/fcode/f_to_g.py index 8c7d189..7d0f248 100644 --- a/fluxclient/fcode/f_to_g.py +++ b/fluxclient/fcode/f_to_g.py @@ -7,6 +7,9 @@ from fluxclient.fcode.fcode_base import FcodeBase from fluxclient.hw_profile import HW_PROFILE +import logging + +logger = logging.getLogger("F_TO_G") FILE_BROKEN = "FILE_BROKEN" FCODE_FAIL = "FCODE_FAIL" @@ -47,7 +50,6 @@ def __init__(self, buf=''): self.upload_content(buf) def upload_content(self, buf): - print("Start upload"); """ upload fcode content in this object, buf[in]: could be string indicating the path to .fcode or bytes @@ -81,24 +83,25 @@ def full_check(self): raise error if any error occur """ try: + logger.info("Start Checking CRC %s" % str(self.data[:8])); assert self.data[:8] == b"FCx0001\n" - print("Passed Header Check"); + logger.info("Passed Header Check"); self.script_size = uint_unpacker(self.data[8:12]) - print("Script size = " + str(self.script_size)) + logger.info("Script size = " + str(self.script_size)) assert crc32(self.data[12:12 + self.script_size]) == uint_unpacker(self.data[12 + self.script_size:16 + self.script_size]) - print("Passed CRC32 -1 "); + logger.info("Passed CRC32 -1 "); index = 16 + self.script_size self.meta_size = uint_unpacker(self.data[index:index + 4]) index += 4 assert crc32(self.data[index:index + self.meta_size]) == uint_unpacker(self.data[index + self.meta_size:index + self.meta_size + 4]) - print("Passed CRC32 -2 "); + logger.info("Passed CRC32 -2 "); index = index + self.meta_size + 4 self.image_size = uint_unpacker(self.data[index:index + 4]) index += 4 - print("Passed full check"); + logger.info("Passed full check"); return True except AssertionError as e: - print(str(e)); + logger.info(str(e)); return False def get_img(self): @@ -137,7 +140,6 @@ def get_metadata(self): itme = item.split(b"=", 1) if len(itme) == 2: metadata[itme[0].decode()] = itme[1].decode() - print(itme[0].decode() + " = " + itme[1].decode()); self.metadata = metadata return self.metadata @@ -146,7 +148,6 @@ def f_to_g(self, outstream, include_meta=False): if include_meta: meta = self.get_metadata() for key, value in meta.items(): - #print(bytes("WELL.. %s=%s\n" % (key, value)), file=sys.stderr) outstream.write(bytes(";%s=%s\n" % (key, value), "UTF-8")) outstream.write(bytes("\n", "UTF-8")) @@ -164,7 +165,7 @@ def f_to_g(self, outstream, include_meta=False): self.writeStr(outstream, 'G4 P{}\n'.format(float_unpacker(self.data[index:index + 4]))) index += 4 elif command == 5: - print('find pause fcode', file=sys.stderr) + pass elif command == 6: self.writeStr(outstream, '; raw command to mb\n') diff --git a/fluxclient/fcode/g_to_f.py b/fluxclient/fcode/g_to_f.py index 8d7ea0e..049f752 100644 --- a/fluxclient/fcode/g_to_f.py +++ b/fluxclient/fcode/g_to_f.py @@ -338,14 +338,14 @@ def process(self, input_stream, output_stream): if (self.layer_now == 2) and self.has_config and float(self._config['temperature']) > 0 and not self.backed_to_normal_temperature: self.writer(packer(16), output_stream) self.writer(packer_f(float(self._config['temperature'])), output_stream) - print("Setting toolhead temperature back to normal #" + str(self.layer_now) + " to " + str(float(self._config['temperature']))); + logger.error("Setting toolhead temperature back to normal #" + str(self.layer_now) + " to " + str(float(self._config['temperature']))); self.backed_to_normal_temperature = True # fix on slic3r bug slowing down in raft but not in real printing if self.has_config and self.layer_now == int(self._config['raft_layers']) and self._config['flux_first_layer'] == '1': data[0] = float(self._config['first_layer_speed']) * 60 subcommand |= (1 << 6) - print("Oh no speed overwrite first_layer. #" + str(self.layer_now) + " to " + str(data[0])); + logger.error("Oh no speed overwrite first_layer. #" + str(self.layer_now) + " to " + str(data[0])); # this will change the data base on serveral settings data = self.analyze_metadata(data, comment) @@ -366,7 +366,6 @@ def process(self, input_stream, output_stream): self.writer(packer(2), output_stream) # set to absolute for data in sub_g1: - # print('d', data) data = self.analyze_metadata(data, comment) self.writer(packer(command), output_stream) diff --git a/fluxclient/laser/laser_bitmap.py b/fluxclient/laser/laser_bitmap.py index 7661176..50d7f8d 100755 --- a/fluxclient/laser/laser_bitmap.py +++ b/fluxclient/laser/laser_bitmap.py @@ -1,20 +1,14 @@ # !/usr/bin/env python3 -from math import pi, sin, cos, degrees -import logging -from os import environ - import numpy as np -from PIL import Image -from math import sqrt - -from fluxclient.laser.laser_base import LaserBase +import logging +from .laser_middleware import LaserMiddleware logger = logging.getLogger(__name__) -class LaserBitmap(LaserBase): +class LaserBitmap(LaserMiddleware): """ LaserBitmap class: generate gcode base on given images @@ -34,38 +28,25 @@ def reset(self): self.thres = 255 self.ratio *= 1 / self.pixel_per_mm - def gcode_generate(self, res=1): - - if self.focus_by_color: - self.laser_speed = 8 * 60 - """ - return gcode in string type - res: resolution - use method: export_to_stream to export gcode to a stream - """ - gcode = [] - gcode += self.header('FLUX. Laser Bitmap.') + def process(self, processor, res=1): + processor.append_comment("FLUX Laser Bitmap Tool") + self.turnOff(processor) + self.moveTo(processor, x=0, y=0, speed=5000, + z=self.focal_l + self.obj_height) abs_shift = len(self.image_map) / 2 - rsquare = (self.pixel_per_mm * self.radius) * (self.pixel_per_mm * self.radius) - - # apply threshold in a efficient way t = np.vectorize(lambda x: x if x <= self.thres else 255) self.image_map = t(self.image_map) itera_o = list(range(0, len(self.image_map))) # iterate left to right itera_r = list(reversed(range(0, len(self.image_map)))) # iterate right to left - #row iteration + # row iteration for h in range(0, len(self.image_map)): - #column iteration + # column iteration if h % res != 0: continue - - h_calibration_offset = ((h - abs_shift) * self.ratio) * 0.2 / 2.5 - gcode += self.moveZ(self.focal_l + self.obj_height + self.height_offset + h_calibration_offset) - if self.one_way or h & 1 == 0: itera = itera_o # this 0.5 is for fixing tiny difference between iter from "left to right " and "right to left" @@ -74,8 +55,6 @@ def gcode_generate(self, res=1): itera = itera_r abs_shift_x = len(self.image_map) / 2 - 0.5 - final_x = itera[-1] - w = 0 back = True while w < len(itera): @@ -89,38 +68,15 @@ def gcode_generate(self, res=1): if this != 255: if back: back = False - # gcode += self.moveTo(itera[w_record] - abs_shift_x, abs_shift - h, speed=8000) - # calculate minimum x for speicifc h - min_x = - sqrt(rsquare - (abs_shift - h) * (abs_shift - h)) - # print("min x %d" % min_x) - # this step compensates for backlash issues - gcode += self.moveTo(max(min_x, itera[w_record] - abs_shift_x - 40), abs_shift - h, speed=5000) - gcode += self.turnOff() - gcode += self.moveTo(itera[w_record] - abs_shift_x, abs_shift - h) - - else: - gcode += self.moveTo(itera[w_record] - abs_shift_x, abs_shift - h) + self.moveTo(processor, itera[w_record] - abs_shift_x - 40, abs_shift - h, speed=5000) + self.turnOff(processor) + self.moveTo(processor, itera[w_record] - abs_shift_x, abs_shift - h) - if self.focus_by_color: - gcode += self.turnTo(255 - this, wait_sec = 1) else: - gcode += self.turnTo(255 - this) - gcode += self.moveTo(itera[w] - abs_shift_x, abs_shift - h) - gcode += self.turnOff() - - gcode += self.turnOff() - - gcode += self.turnOff() - gcode = "\n".join(gcode) + "\n" - logger.debug("generate gcode done:%d bytes" % len(gcode)) - ######################## fake code #################################### - if environ.get("flux_debug") == '1': - self.dump('./preview.png') - with open('output.gcode', 'w') as f: - print(gcode, file=f) - ####################################################################### - return gcode - + self.moveTo(processor, itera[w_record] - abs_shift_x, abs_shift - h) + self.turnTo(processor, 255 - this) + self.moveTo(processor, itera[w] - abs_shift_x, abs_shift - h) + self.turnOff(processor) -if __name__ == '__main__': - a = LaserBitmap() + self.turnOff(processor) + self.turnOff(processor) diff --git a/fluxclient/laser/laser_middleware.py b/fluxclient/laser/laser_middleware.py new file mode 100644 index 0000000..53960b4 --- /dev/null +++ b/fluxclient/laser/laser_middleware.py @@ -0,0 +1,94 @@ + +from math import sin, cos + +from .laser_base import LaserBase + + +class LaserMiddleware(LaserBase): + """Laser Middleware is a middle class to override old behivor with new + toolpath processor. All laser class shoule be refactor.""" + + def turnOn(self, processor): # noqa + if self.laser_on is True: + return [] + self.laser_on = True + processor.set_toolhead_pwm(1) + processor.sleep(0.002) + + def turnOff(self, processor): # noqa + if self.laser_on is False: + return + self.laser_on = False + processor.set_toolhead_pwm(0) + processor.sleep(0.002) + + def turnTo(self, processor, power=None): # noqa + """ + set laser power + """ + if power is None: + self.laser_on = True + processor.set_toolhead_pwm(self.fram_power / 255) + processor.sleep(0.002) + + elif power != 0: + self.laser_on = True + processor.set_toolhead_pwm(power / 255) + processor.sleep(0.002) + + elif power == 0: + return self.turnOff(processor) + + def moveTo(self, processor, x, y, speed=None, z=None, ending=None): # noqa + """ + apply global "rotation" and "scale" + move to position x,y + """ + + x2 = (x * cos(self.rotation) - y * sin(self.rotation)) * self.ratio + y2 = (x * sin(self.rotation) + y * cos(self.rotation)) * self.ratio + + x = x2 + y = y2 + + if speed is None: + speed = self.laser_speed + + if ending is None: + if self.laser_on: + processor.append_comment("Draw") + else: + processor.append_comment("Move") + else: + processor.append_comment(ending) + + self.current_x = x + self.current_y = y + if z is None: + processor.moveto(feedrate=speed, x=x, y=y) + else: + processor.moveto(feedrate=speed, x=x, y=y, z=z) + + def drawTo(self, processor, x, y, speed=None, z=None): # noqa + """ + turn on, move to x, y + + draw to position x,y + """ + self.turnOn(processor) + + if speed is None: + self.moveTo(processor, x, y, self.laser_speed, z, ending='draw') + else: + self.moveTo(processor, x, y, speed, z, ending='draw') + + def closeTo(self, processor, x, y, speed=None, z=None): # noqa + """ + turn off, move to x, y + """ + self.turnOff(processor) + + if speed is None: + self.moveTo(processor, x, y, self.travel_speed, z) + else: + self.moveTo(processor, x, y, speed, z) diff --git a/fluxclient/laser/laser_svg.py b/fluxclient/laser/laser_svg.py index 8cb7554..058656a 100644 --- a/fluxclient/laser/laser_svg.py +++ b/fluxclient/laser/laser_svg.py @@ -1,19 +1,17 @@ # !/usr/bin/env python3 -import sys import logging -from os import environ -from lxml import etree as ET +from lxml import etree as ET # noqa -from .laser_base import LaserBase +from .laser_middleware import LaserMiddleware from fluxclient.utils.svg_parser import SVGParser logger = logging.getLogger(__name__) -class LaserSvg(LaserBase, SVGParser): +class LaserSvg(LaserMiddleware, SVGParser): """ LaserSvg class: generate gcode base on given svg files @@ -36,10 +34,15 @@ def compute(self, name, data): """ self.ready_svgs[name] = data - def gcode_generate(self, names, ws=None): + def process(self, processor, names=None, ws=None): self.reset_image() - gcode = [] - gcode += self.header('FLUX. Laser SVG.') + + if not names: + names = self.ready_svgs.keys() + + processor.append_comment("FLUX Laser SVG Tool") + self.moveTo(processor, x=0, y=0, speed=5000, + z=self.focal_l + self.obj_height) progress = 0.1 offset = 4 * len(names) / 0.98 name_index = offset @@ -49,7 +52,9 @@ def gcode_generate(self, names, ws=None): ready_svg = self.ready_svgs[name] svg_data = ready_svg[0].decode('utf8') root = ET.fromstring(svg_data) - viewBox = list(map(float, root.attrib['viewBox'].replace(',', ' ').split())) + view_box = list( + map(float, root.attrib['viewBox'].replace(',', ' ').split()) + ) progress += offset if ws: @@ -61,44 +66,28 @@ def gcode_generate(self, names, ws=None): if ws: ws.send_progress('processing svg', progress) - path_data = self.process(path_data, ready_svg[1:-3], viewBox, self.radius) + path_data = SVGParser.process(path_data, ready_svg[1:-3], view_box, + self.radius) progress += offset if ws: ws.send_progress('generating fcode on svg', progress) for each_path in path_data: - moveTo = True # flag that means extruder should move to rather than drawto + # flag that means extruder should move to rather than drawto + move_to = True for x, y in each_path: if x != '\n': - if not moveTo: - gcode += self.drawTo(x, y, speed=self.laser_speed) + if not move_to: + self.drawTo(processor, x, y, speed=self.laser_speed) else: - gcode += self.closeTo(x, y, self.travel_speed) - moveTo = False + self.closeTo(processor, x, y, self.travel_speed) + move_to = False else: - moveTo = True + move_to = True continue progress += offset if ws: ws.send_progress('preparing image', progress) if ready_svg[-1]: self.add_image(ready_svg[-1], ready_svg[-3], ready_svg[-2], *ready_svg[3:-3], thres=100) - gcode += self.turnOff() - - gcode = "\n".join(gcode) + "\n" - logger.debug("generate gcode done:%d bytes" % len(gcode)) - - ################ fake code ############## - if environ.get("flux_debug") == '1': - self.dump('./preview.png') - with open('output.gcode', 'w') as f: - print(gcode, file=f) - ########################################## - - return gcode - -if __name__ == '__main__': - m_laser_svg = LaserSvg() - filename = sys.argv[1] - with open(filename, 'rb') as f: - m_laser_svg.preprocess(f.read()) + self.turnOff(processor) diff --git a/fluxclient/printer/__init__.py b/fluxclient/printer/__init__.py index 0704409..a98428f 100644 --- a/fluxclient/printer/__init__.py +++ b/fluxclient/printer/__init__.py @@ -294,6 +294,7 @@ def float_or_percent(key, value, percent_start=float('-inf'), percent_end=float( material_bed_temperature_layer_0 = 60 material_diameter = 1.75 material_flow = 100 +mesh_position_z = 0 retraction_enable = true retract_at_layer_change = false retraction_amount = 8 diff --git a/fluxclient/printer/stl_slicer.py b/fluxclient/printer/stl_slicer.py index d3bce15..f491af4 100644 --- a/fluxclient/printer/stl_slicer.py +++ b/fluxclient/printer/stl_slicer.py @@ -1,28 +1,28 @@ # !/usr/bin/env python3 +from platform import platform from struct import unpack, Struct, pack from io import BytesIO, StringIO -import traceback -import numpy as np -import gc import subprocess import tempfile -import os, sys -from platform import platform import logging -import copy +import shutil import json -from fluxclient.utils._utils import Tools +import copy +import sys +import gc +import os from PIL import Image +import numpy as np -from fluxclient.hw_profile import HW_PROFILE -from fluxclient.printer import _printer -from fluxclient.fcode.g_to_f import GcodeToFcode -from fluxclient.utils._utils import GcodeToFcodeCpp from fluxclient.scanner.tools import dot, normal, normalize, dotX, normalX -from fluxclient.printer import ini_string, ini_string_cura2, ini_constraint, ignore, ini_flux_params +from fluxclient.utils._utils import GcodeToFcodeCpp, Tools +from fluxclient.fcode.g_to_f import GcodeToFcode +from fluxclient.hw_profile import HW_PROFILE from fluxclient.printer.flux_raft import Raft +from fluxclient.printer import ini_string, ini_string_cura2, ini_constraint, ignore, ini_flux_params +from fluxclient.printer import _printer logger = logging.getLogger(__name__) @@ -31,6 +31,7 @@ def rreplace(s, old, new, occurrence): li = s.rsplit(old, occurrence) return new.join(li) + def read_until(f): """ eat all the empty line @@ -58,10 +59,8 @@ def reset(self, slic3r): # self.slic3r = '/Applications/Slic3r.app/Contents/MacOS/slic3r' self.slic3r = slic3r - # self.slic3r_setting = './fluxghost/assets/flux_slicing.ini' - self.config = self.my_ini_parser(ini_string.split('\n')) - self.configCura2 = self.my_ini_parser(ini_string_cura2.split('\n')) - # self.config = self.my_ini_parser(self.slic3r_setting) + self.config = self.parse_config(ini_string.split('\n')) + self.configCura2 = self.parse_config(ini_string_cura2.split('\n')) self.config['gcode_comments'] = '1' # force open comment in gcode generated self.path = None self.output = None @@ -94,8 +93,7 @@ def upload(self, name, buf, buf_type='stl'): else: raise('unknown file type') except: - logger.info("oops"); - traceback.print_exc(file=sys.stdout) + logger.exception("oops") return False else: return True @@ -205,11 +203,6 @@ def advanced_setting(self, lines): self.configCura2[key] = value else: self.config[key] = value - #if key == 'temperature': - # self.config['first_layer_temperature'] = str(min(230, float(value) + 5)) - # elif key == 'overhangs' and value == '0': - # self.config['support_material'] = '0' - # ini_constraint['support_material'] = [ignore] if key == 'spiral_vase' and value == '1': self.config['support_material'] = '0' ini_constraint['support_material'] = [ignore] @@ -242,7 +235,7 @@ def get_path(self): """ if self.T: self.T.join() - print("Returning get path") + logger.debug("Returning get path") return self.path_js def begin_slicing(self, names, ws, output_type): @@ -285,7 +278,7 @@ def begin_slicing(self, names, ws, output_type): m_mesh_merge = m_mesh else: m_mesh_merge.add_on(m_mesh) - + if float(self.config['cut_bottom']) > 0: m_mesh_merge = m_mesh_merge.cut(float(self.config['cut_bottom'])) @@ -293,7 +286,7 @@ def begin_slicing(self, names, ws, output_type): cx, cy = (bounding_box[0][0] + bounding_box[1][0]) / 2., (bounding_box[0][1] + bounding_box[1][1]) / 2. m_mesh_merge.write_stl(tmp_stl_file) - self.my_ini_writer(tmp_slic3r_setting_file, self.config, delete=ini_flux_params) + self.generate_slicer_config(tmp_slic3r_setting_file, self.config, delete=ini_flux_params) command = [self.slic3r, tmp_stl_file] command += ['--output', tmp_gcode_file] @@ -314,10 +307,17 @@ def begin_slicing(self, names, ws, output_type): def slicing_worker(self, command, config, image, ext_metadata, output_type, status_list, p_index): tmp_gcode_file = command[3] fail_flag = False - subp = subprocess.Popen(command, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True) + + try: + subp = subprocess.Popen(command, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True) + except Exception: + logger.exception("Slic3r start failed") + status_list.append([False, [None, None], None]) + return + path = None self.working_p[p_index].append(subp) - logger.info("#%d Real slicing started" % (p_index)); + logger.info("#%d Real slicing started", p_index) progress = 0.2 slic3r_error = False @@ -325,9 +325,6 @@ def slicing_worker(self, command, config, image, ext_metadata, output_type, stat while subp.poll() is None: line = subp.stdout.readline().strip() - # subp.stdout.read() - # for line in chunck.split('\n'): - # logger.debug(line.rstrip()) if line: logger.info(line) if line.startswith('=> ') and not line.startswith('=> Exporting'): @@ -336,11 +333,11 @@ def slicing_worker(self, command, config, image, ext_metadata, output_type, stat elif "Unable to close this loop" in line: slic3r_error = True slic3r_out = [5, line] # errorcode 5 - + subp_returned = subp.poll() if self.is_aborted(p_index): return logger.info('Worker #%d aborted' % p_index) - if subp_returned!= 0: + if subp_returned != 0: logger.info('#%d Slic3r returned abnormal %d ' % (p_index, subp_returned)) fail_flag = True @@ -404,7 +401,7 @@ def slicing_worker(self, command, config, image, ext_metadata, output_type, stat with open('output.fc', 'wb') as f: f.write(fcode_output.getvalue()) - StlSlicer.my_ini_writer("output.ini", config) + StlSlicer.generate_slicer_config("output.ini", config) ########################################################### # # clean up tmp files @@ -424,22 +421,22 @@ def end_slicing(self, exit_reason=""): when being called, end every working slic3r process but couldn't kill the thread """ - print("Abort slicing:: %s" % exit_reason) + logger.debug("Abort slicing:: %s", exit_reason) for p in self.working_p: if type(p[-1]) == (subprocess.Popen): if p[-1].poll() is None: - print("Aborting 'process' managed by worker:: #%d " % p[4]) + logger.debug("Aborting 'process' managed by worker:: #%d ", p[4]) p[-1].terminate() p[3] = True else: # Turn on abort tag if not p[3]: - print("Aborting 'thread' managed by worker:: #%d " % p[4]) + logger.debug("Aborting 'thread' managed by worker:: #%d ", p[4]) p[3] = True pass for filename in p[1]: try: - if not ".stl" in filename: + if ".stl" not in filename: os.remove(filename) except: pass @@ -486,7 +483,7 @@ def report_slicing(self): return ret @classmethod - def my_ini_parser(cls, data): + def parse_config(cls, data): """ data[in]: [str] indicating a file path or [list of str] indicating lines of ini file read-in .ini file setting file as default settings @@ -540,7 +537,7 @@ def ini_value_check_cura2(self, key, value): return 'Key not exists: %s' % key @classmethod - def my_ini_writer(cls, file_path, content, delete=None): + def generate_slicer_config(cls, file_path, content, delete=None): """ file_path[in]: str, output file_path content[in]: dict @@ -548,12 +545,15 @@ def my_ini_writer(cls, file_path, content, delete=None): specify delete not to write some key in content """ - if int(content.get('raft','1')) == 0: + if int(content.get('raft', '1')) == 0: logger.info("Raft off, remove raft_layers") - content['raft_layers'] = '0'; - - if content.get('start_gcode','') != "": - content['start_gcode'] = "M109 S[first_layer_temperature]\\n" + content.get('start_gcode','') + content['temp_raft_layers'] = content['raft_layers'] + content['raft_layers'] = '0' + elif not content.get('raftMargin'): + content['raft_layers'] = content.get('temp_raft_layers', 4) + + if content.get('start_gcode'): + content['start_gcode'] = "M109 S[first_layer_temperature]\\n" + content.get('start_gcode', '') with open(file_path, 'w') as f: for i in content: @@ -561,7 +561,6 @@ def my_ini_writer(cls, file_path, content, delete=None): pass else: print("%s=%s" % (i, content[i]), file=f) - return @classmethod def ascii_or_binary(cls, data, byte_order): @@ -633,7 +632,7 @@ def read_stl(cls, file_data): if pIdx is None: points_map[v] = counter pIdx = counter - points_list.append(v); + points_list.append(v) counter += 1 tFaces.append(pIdx) # Compact python list to nparray @@ -666,14 +665,14 @@ def read_stl(cls, file_data): if pIdx is None: points_map[v] = counter pIdx = counter - points_list.append(v); + points_list.append(v) counter += 1 faces[fptr] = pIdx fptr = fptr + 1 index += 50 logger.info("np array convert (bin) %d" % faces.size) - - print("Faces[0] type %s " % type(faces).__name__) + + logger.debug("Faces[0] type %s ", type(faces).__name__) return _printer.MeshCloud(points_list), faces @classmethod @@ -709,13 +708,17 @@ def read_obj(cls, file_data): faces[i][j] -= 1 else: faces[i][j] = len(points_list) + faces[i][j] - - print("Faces[0] type %s " % type(faces).__name__) + + logger.debug("Faces[0] type %s ", type(faces).__name__) return _printer.MeshCloud(points_list), faces + class StlSlicerCura(StlSlicer): - def __init__(self, slicer, version = 1): + def __init__(self, slicer, version=1): super(StlSlicerCura, self).__init__(slicer) + self._working_dir = tempfile.mkdtemp() + self.transform_file = os.path.join(self._working_dir, "temp.transform") + self.stl_cache_file = os.path.join(self._working_dir, "stl.cache") self.slicer = slicer self.version = version self.now_type = 3 @@ -733,7 +736,7 @@ def begin_slicing(self, names, ws, output_type): # End other slicing process once called self.end_slicing('cura next slicing') - logger.info('Begin slicing (CuraEngine)'); + logger.info('Begin slicing (CuraEngine)') # check if names are all seted for n in names: if not (n in self.models and n in self.parameter): @@ -744,39 +747,39 @@ def begin_slicing(self, names, ws, output_type): self.end_slicing() from threading import Thread # Do not expose thrading in module level - p = Thread(target=self.slicing_worker, args=(dict(mergedConfig), self.image, dict(self.ext_metadata), output_type, status_list, names, ws, len(self.working_p))) + p = Thread(target=self._slicing_worker, args=(dict(mergedConfig), self.image, dict(self.ext_metadata), output_type, status_list, names, ws, len(self.working_p))) # thread, files, status_list self.working_p.append([p, [], status_list, False, len(self.working_p)]) p.start() return True, '' - def slicing_worker(self, config, image, ext_metadata, output_type, status_list, names, ws, p_index): - - # Generate temp files - if platform().startswith("Windows"): - if not os.path.isdir('C:\Temp'): - os.mkdir('C:\Temp') - temp_dir = 'C:\Temp' - else: - temp_dir = None + def _slicing_worker(self, *args, **kw): + try: + self.slicing_worker(*args, **kw) + except Exception: + logger.exception("slicing error") - tmp = tempfile.NamedTemporaryFile(dir=temp_dir, suffix='.stl', delete=False) + def slicing_worker(self, config, image, ext_metadata, output_type, status_list, names, ws, p_index): + tmp = tempfile.NamedTemporaryFile(dir=self._working_dir, suffix='.stl', delete=False) tmp_stl_file = tmp.name # store gcode - tmp = tempfile.NamedTemporaryFile(dir=temp_dir, suffix='.gcode', delete=False) + tmp = tempfile.NamedTemporaryFile(dir=self._working_dir, suffix='.gcode', delete=False) tmp_gcode_file = tmp.name # store gcode - tmp = tempfile.NamedTemporaryFile(dir=temp_dir, suffix='.ini', delete=False) + tmp = tempfile.NamedTemporaryFile(dir=self._working_dir, suffix='.ini', delete=False) tmp_slicer_setting_file = tmp.name # store gcode m_mesh_merge = None + cura2 = self.version == 2 + # Read old transform to see if we need to regenerate the stl old_transform = "" - if os.path.exists('temp.transform'): - f = open('temp.transform', 'r+') - old_transform = f.read(); - f.close(); + + if os.path.exists(self.transform_file): + f = open(self.transform_file, 'r+') + old_transform = f.read() + f.close() params = {} @@ -784,13 +787,13 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list, params[n] = self.parameter[n] current_transform = json.dumps({'p': params, 'sink': float(config['cut_bottom'])}) - status_list.append('{"slice_status": "computing", "message": "Comparing Transformation", "percentage": 0.025}'); - + status_list.append('{"slice_status": "computing", "message": "Comparing Transformation", "percentage": 0.025}') + if self.is_aborted(p_index): return logger.info('Worker #%d aborted' % p_index) - if old_transform != current_transform: # Need to regenerate new stl - logger.info('Generating transformed stl'); + if old_transform != current_transform: # Need to regenerate new stl + logger.info('Generating transformed stl') # Applying transform to each mesh object, and merge to m_mesh_merge for n in names: m_mesh = _printer.MeshObj(self.models[n][0], self.models[n][1]) @@ -798,7 +801,7 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list, if self.is_aborted(p_index): return logger.info('Worker #%d aborted' % p_index) - m_mesh.apply_transform(self.parameter[n]) + m_mesh.apply_transform(self.parameter[n]) if self.is_aborted(p_index): return logger.info('Worker #%d aborted' % p_index) @@ -807,56 +810,54 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list, m_mesh_merge = m_mesh else: m_mesh_merge.add_on(m_mesh) - + if self.is_aborted(p_index): return logger.info('Worker #%d aborted' % p_index) - if float(config['cut_bottom']) > 0: - status_list.append('{"slice_status": "computing", "message": "Performing cut_bottom", "percentage": 0.04}'); + status_list.append('{"slice_status": "computing", "message": "Performing cut_bottom", "percentage": 0.04}') m_mesh_merge = m_mesh_merge.cut(float(config['cut_bottom'])) - - logger.info('Writing new stl'); - status_list.append('{"slice_status": "computing", "message": "Writing new stl", "percentage": 0.05}'); + + logger.info('Writing new stl') + status_list.append('{"slice_status": "computing", "message": "Writing new stl", "percentage": 0.05}') m_mesh_merge.write_stl(tmp_stl_file) # Save new file name for same transform # Remove old file - if os.path.exists('stl.cache'): - f = open('stl.cache', 'r+') - old_stl = f.read(); - f.close(); + if os.path.exists(self.stl_cache_file): + f = open(self.stl_cache_file, 'r+') + old_stl = f.read() + f.close() if os.path.exists(old_stl): os.remove(old_stl) - - f = open('stl.cache', 'w+') + f = open(self.stl_cache_file, 'w+') f.write(tmp_stl_file) - f.close(); + f.close() - f = open('temp.transform', 'w+') + f = open(self.transform_file, 'w+') f.write(current_transform) - f.close(); - else: # Read old stl - f = open('stl.cache', 'r+') - tmp_stl_file = f.read(); - logger.info('Using last stl %s' % tmp_stl_file); - f.close(); - - logger.info('Writing ini to %s' % tmp_slicer_setting_file); + f.close() + else: + # Read old stl + f = open(self.stl_cache_file, 'r+') + tmp_stl_file = f.read() + logger.info('Using last stl %s' % tmp_stl_file) + f.close() - cura2 = self.version == 2 - + logger.info('Writing ini to %s' % tmp_slicer_setting_file) command = [] if cura2: - self.cura2_ini_writer(tmp_slicer_setting_file, config, delete=ini_flux_params) + self.generate_cura2_config(tmp_slicer_setting_file, config, delete=ini_flux_params) # Call CuraEngine in command line binary_path = self.slicer - if platform().startswith("Windows"): - binary_path = binary_path.replace("CuraEngine.exe", "v2/CuraEngine2.exe") - else: - binary_path = binary_path.replace("lib/CuraEngine", "lib/CuraEngine2") + + src_dir = os.path.dirname(binary_path) + target_dir = os.path.dirname(tmp_slicer_setting_file) + for fn in ("fd1p.def.json", "fdmprinter.def.json", "fdmextruder.def.json"): + config_src = os.path.join(src_dir, fn) + shutil.copy(config_src, target_dir) command = [binary_path, 'slice', '-v', '-j', tmp_slicer_setting_file, '-o', tmp_gcode_file, '-l', tmp_stl_file] @@ -909,16 +910,12 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list, fail_flag = True logger.info('Worker #%d aborted' % p_index) if cura_result != 0: - logger.info("#%d CuraEngine: Exited abnormally %d" % (p_index, cura_result)); + logger.info("#%d CuraEngine: Exited abnormally %d" % (p_index, cura_result)) fail_flag = True except Exception as ex: fail_flag = True - logger.info("CuraEngine: initialization failed %s" % str(type(ex))); - exc_type, exc_value, exc_traceback = sys.exc_info() - logger.info("*** print_exception:") - traceback.print_exception(exc_type, exc_value, exc_traceback, - limit=10, file=sys.stdout) - + logger.info("CuraEngine: initialization failed %s" % str(type(ex))) + logger.exception("CuraEngine: initialization failed %s", ex) slicer_out = [5, 'CuraEngine: Failed'] # errorcode 5 if not fail_flag: @@ -955,7 +952,7 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list, status_list.append('{"slice_status": "warning", "message" : "%s"}' % ("{} empty layers, might be error when slicing {}".format(len(m_GcodeToFcode.empty_layer), repr(m_GcodeToFcode.empty_layer)))) if float(m_GcodeToFcode.md['MAX_R']) >= HW_PROFILE['model-1']['radius']: - logger.info("CuraEngine: gcode out of range"); + logger.info("CuraEngine: gcode out of range") fail_flag = True slicer_out = [6, "Gcode area too big MAX_R=%s" % str(m_GcodeToFcode.md['MAX_R'])] # errorcode 6 @@ -1002,7 +999,7 @@ def slicing_worker(self, config, image, ext_metadata, output_type, status_list, status_list.append([output, metadata, path]) @classmethod - def cura2_ini_writer(cls, file_path, content, delete=None): + def generate_cura2_config(cls, file_path, content, delete=None): """ file_path[in]: str, output file_path content[in]: dict @@ -1065,11 +1062,11 @@ def cura2_ini_writer(cls, file_path, content, delete=None): "machine_end_gcode": { "default_value": add_multi_line(content['machine_end_gcode']) }, - "machine_name": { "default_value": "DeltaBot style" }, + "machine_name": {"default_value": "DeltaBot style"}, "machine_shape": { "default_value": "elliptic" }, - "adhesion_type": { 'default_value': 'none' } + "adhesion_type": {'default_value': 'none'} # "raft_speed": int(content['first_layer_speed']), # "raft_surface_speed": { 'default_value': int(content['first_layer_speed']) }, # "layer_height": { 'default_value': float(content['layer_height']) }, @@ -1095,7 +1092,7 @@ def cura2_ini_writer(cls, file_path, content, delete=None): # "speed_support_infill": { 'default_value': float(content['support_material_speed']) }, # "speed_support_interface": { 'default_value': float(content['support_material_speed']) / 1.5 }, # "speed_wall_x": { 'default_value': float(content['perimeter_speed']) }, - # "speed_wall_0": { 'default_value': float(content['external_perimeter_speed']) }, + # "speed_wall_0": { 'default_value': float(content['external_perimeter_speed']) }, # "infill_overlap_mm": { 'default_value': 0.4 * float(content['infill_overlap'].rstrip('%')) / 100 }, # "speed_topbottom": { 'default_value': float(content['solid_infill_speed']) }, # "speed_print_layer_0": { 'default_value': float(content['first_layer_speed']) }, @@ -1118,23 +1115,28 @@ def cura2_ini_writer(cls, file_path, content, delete=None): } for key in content: - # if str(float(content[key])) == content[key]: - # content[key] = float(content[key]) if delete and any(j in key for j in delete): pass - definition['overrides'][key] = { 'default_value': content[key] } + definition['overrides'][key] = {'default_value': content[key]} definition['overrides']['machine_start_gcode']['default_value'] = add_multi_line('M109 S{}\n'.format(content['material_print_temperature_layer_0']) + content['machine_start_gcode']) definition['overrides']['machine_end_gcode']['default_value'] = add_multi_line(content['machine_end_gcode']) - # TODO FIX Raft layers - if int(content.get('raft','1')) == 1: + # Override cut_bottom + definition['overrides']["mesh_position_z"] = {'default_value' : str(-float(content['cut_bottom']))} + + # Override raft and skirt over brim + if int(content.get('raft', '1')) == 1: definition['overrides']['adhesion_type']['default_value'] = 'raft' elif int(content['brim_line_count']) == 0: # skirt definition['overrides']['adhesion_type']['default_value'] = 'skirt' else: definition['overrides']['adhesion_type']['default_value'] = 'brim' + # Compatible with old keyword + if definition['overrides']['support_type']['default_value'] == 'touching_build_plate': + definition['overrides']['support_type'] = {'default_value': 'buildplate'} + logger.info(json.dumps(definition)) with open(file_path, 'w') as f: f.write(json.dumps(definition)) @@ -1189,11 +1191,11 @@ def cura_ini_writer(cls, file_path, content, delete=None): else: new_content['supportAngle'] = 90 - int(content['support_material_threshold']) new_content['supportZDistance'] = thousand(content['support_material_contact_distance']) - new_content['supportXYDistance'] = thousand(content['support_material_spacing']) + new_content['supportLineDistance'] = thousand(content['support_material_spacing']) new_content['supportType'] = {'GRID': 0, 'LINES': 1}.get(content['support_material_pattern'], 0) new_content['supportEverywhere'] = int(content['support_everywhere']) - if int(content.get('raft','1')) == 0: + if int(content.get('raft', '1')) == 0: logger.info("Raft off, remove raft_layers") new_content['raftSurfaceLayers'] = 0 else: @@ -1230,7 +1232,7 @@ def cura_ini_writer(cls, file_path, content, delete=None): # speed new_content['moveSpeed'] = content['travel_speed'] - #support speed + # support speed new_content['printSpeed'] = content['support_material_speed'] new_content['inset0Speed'] = content['external_perimeter_speed'] # WALL-OUTER @@ -1242,7 +1244,7 @@ def cura_ini_writer(cls, file_path, content, delete=None): new_content['fanSpeedMin'] = content['min_fan_speed'].rstrip('%') new_content['fanSpeedMax'] = content['max_fan_speed'].rstrip('%') - #speed top bottom + # speed top bottom if fill_density == 100: new_content['skinSpeed'] = max(int(content['solid_infill_speed']), 4) else: @@ -1255,7 +1257,7 @@ def cura_ini_writer(cls, file_path, content, delete=None): new_content['retractionSpeed'] = content['retract_speed'] new_content['retractionAmount'] = thousand(content['retract_length']) - new_content['retractionZHop'] = thousand(content['retract_lift']) + new_content['retractionZHop'] = thousand(content['retract_lift']) new_content['minimalExtrusionBeforeRetraction'] = 200 @@ -1284,8 +1286,5 @@ def cura_ini_writer(cls, file_path, content, delete=None): new_content['startCode'] = add_multi_line(new_content['startCode']) new_content['endCode'] = add_multi_line(new_content['endCode']) - import pprint - pprint.pprint(new_content) - - cls.my_ini_writer(file_path, new_content, delete) + cls.generate_slicer_config(file_path, new_content, delete) return diff --git a/fluxclient/robot/aes_socket.py b/fluxclient/robot/aes_socket.py index ee3aa76..5d96f08 100644 --- a/fluxclient/robot/aes_socket.py +++ b/fluxclient/robot/aes_socket.py @@ -52,15 +52,15 @@ def __read_buffer(self, length): def do_handshake(self): if self.__handshake_flag == __READY__: - return True + return 0 elif self.__handshake_flag == __WAIT_IDENTIFY__: # Stage 1 self._do_handshake_validate_remote() - return False + return 1 elif self.__handshake_flag == __WAIT_RESPONSE__: # Stage 2 self._do_handshake_wait_validate() - return False + return 2 elif self.__handshake_flag == __WAIT_AESKEY__: # Stage 3 return self._do_handshake_wait_aeskey() @@ -118,7 +118,9 @@ def _do_handshake_wait_aeskey(self): key, iv = aes_init[:32], aes_init[32:48] self._encoder = AES.new(key, AES.MODE_CFB, iv) self._decoder = AES.new(key, AES.MODE_CFB, iv) - return True + return 0 + else: + return 3 def recv(self, size, flag=0): if flag & socket.MSG_PEEK > 0: diff --git a/fluxclient/robot/robot.py b/fluxclient/robot/robot.py index 201592d..62d469a 100644 --- a/fluxclient/robot/robot.py +++ b/fluxclient/robot/robot.py @@ -8,7 +8,7 @@ from .backends import InitBackend from .errors import RobotError, RobotSessionError from .robot_backend_usb import RobotBackendUSB -from .robot_backend_2 import RobotBackend2 +from .robot_backend_2 import RobotBackend2, RobotBackend3 def blocked_validator(fn): @@ -73,6 +73,9 @@ def __init__(self, endpoint, client_key, device=None, if proto_ver == 2: self._backend = RobotBackend2(init_backend.sock, client_key, device, ignore_key_validation) + elif proto_ver == 3: + self._backend = RobotBackend3(init_backend.sock, client_key, + device, ignore_key_validation) else: raise RobotSessionError("Protocol not support") diff --git a/fluxclient/robot/robot_backend_2.py b/fluxclient/robot/robot_backend_2.py index 74ace4f..137b527 100644 --- a/fluxclient/robot/robot_backend_2.py +++ b/fluxclient/robot/robot_backend_2.py @@ -1,17 +1,16 @@ from binascii import a2b_base64 from select import select -from errno import EPIPE from io import BytesIO from time import time import logging -import socket import struct import json + from PIL import Image -from io import StringIO from .aes_socket import AESSocket +from .ssl_socket import SSLSocket from .errors import RobotError, RobotSessionError from .misc import msg_waitall @@ -21,7 +20,10 @@ def raise_error(ret): if ret.startswith("error ") or ret.startswith("er "): errors = ret.split(" ")[1:] - raise RobotError(*errors, error_symbol=errors) + if errors and errors[0] == "KICKED": + raise RobotSessionError(*errors, error_symbol=errors) + else: + raise RobotError(*errors, error_symbol=errors) else: raise RobotError(ret, error_symbol="L_UNKNOW_ERROR") @@ -270,7 +272,13 @@ def scan_oneshot(self): if resp.startswith("binary "): mime, img_buff = self.recv_binary_buff(resp) img_buff.seek(0) - img = Image.open(img_buff) + + try: + img = Image.open(img_buff) + except OSError: + raise RobotError("Image broken", + error_symbol=("FILE_BROKEN", )) + if img.size[0] >= 720: img = img.transpose(Image.ROTATE_90) fake_file = BytesIO() @@ -283,9 +291,9 @@ def scan_oneshot(self): return images else: - raise RobotError(resp) + raise_error(resp) - def scan_images(self, stackResult = None, iterations = 0): + def scan_images(self, stack_result=None, iterations=0): self.send_cmd(b"scanimages") images = [] is_hd_camera = False @@ -294,9 +302,14 @@ def scan_images(self, stackResult = None, iterations = 0): resp = self.get_resp() if resp.startswith("binary "): mime, img_buff = self.recv_binary_buff(resp) - logger.info("scanimmages %s", (mime)) img_buff.seek(0) - img = Image.open(img_buff) + + try: + img = Image.open(img_buff) + except OSError: + raise RobotError("Image broken", + error_symbol=("FILE_BROKEN", )) + if img.size[0] >= 720: img = img.transpose(Image.ROTATE_90) is_hd_camera = True @@ -304,7 +317,7 @@ def scan_images(self, stackResult = None, iterations = 0): # save sample image images.append(img) else: - old_img = stackResult[img_idx] + old_img = stack_result[img_idx] img = Image.blend(old_img, img, 0.5) fake_file = BytesIO() img.save(fake_file, "jpeg") @@ -314,15 +327,13 @@ def scan_images(self, stackResult = None, iterations = 0): images.append((mime, img_buff.getvalue())) elif resp == "ok": - logger.info("return images") if is_hd_camera and iterations < 1: return self.scan_images(images, iterations + 1) return images else: - logger.info("robot error") - raise RobotError(resp) + raise_error(resp) logger.info("exit loop") @ok_or_error @@ -341,7 +352,7 @@ def __init__(self, sock, client_key, device=None, sock, client_key=client_key, device=device, ignore_key_validation=False) - while not aessock.do_handshake(): + while aessock.do_handshake() > 0: pass def fileno(self): @@ -362,11 +373,13 @@ def send_cmd(self, buf): def get_resp(self, timeout=180.0): rl = select((self.sock, ), (), (), timeout)[0] if not rl: - raise RobotError("get resp timeout") + self.close() + raise RobotSessionError("Get remote response timeout", + error_symbol=["TIMEOUT"]) bml = msg_waitall(self.sock, 2, timeout) if not bml: - logger.error("Message payload recv error") - raise socket.error(EPIPE, "Broken pipe") + self.close() + raise RobotSessionError("Message payload recv error") message_length = struct.unpack(" 0: + pass diff --git a/fluxclient/robot/robot_backend_usb.py b/fluxclient/robot/robot_backend_usb.py index 7ef1d7d..e4d1baa 100644 --- a/fluxclient/robot/robot_backend_usb.py +++ b/fluxclient/robot/robot_backend_usb.py @@ -23,8 +23,8 @@ def send_binary(self, buf): l = len(buf) offset = 0 while l > offset: - self.channel.send_binary(m[offset:offset + 1020]) - offset += 1020 + self.channel.send_binary(m[offset:offset + 506]) + offset += 506 def get_resp(self, timeout=180.0): try: @@ -51,7 +51,7 @@ def _upload_stream(self, instance, cmd, stream, size, process_callback(instance, sent, size) while sent < size: - buf = stream.read(1020) + buf = stream.read(506) lbuf = len(buf) if lbuf == 0: raise RobotError("Upload file error") diff --git a/fluxclient/scanner/freeless.py b/fluxclient/scanner/freeless.py index 63e179b..a33071c 100644 --- a/fluxclient/scanner/freeless.py +++ b/fluxclient/scanner/freeless.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 -import sys +import logging import time import math +import sys import numpy as np from PIL import Image @@ -14,7 +15,6 @@ NUM_LASER_RANGE_THRESHOLD = 3 RED_HUE_UPPER_THRESHOLD = 5 -import logging logger = logging.getLogger(__name__) @@ -54,7 +54,6 @@ def __init__(self, laserX, laserZ, scan_settings): self.place = {} def img_to_points(self, img_o, img_red, indices, step, side, cab_offset, clock=False): - logger.info("imp start") """ convert indices on the image into x-y-z-rgb points return [ @@ -77,10 +76,8 @@ def img_to_points(self, img_o, img_red, indices, step, side, cab_offset, clock=F for y, x in indices: ray = self.calculateCameraRay(x, y) f, point = self.intersectLaserPlane(ray) - #logger.info("F %s" % str(f)) if f: - # logger.info("%d %d pttest" % (y, x)) if point[0][0] ** 2 + point[0][2] ** 2 < MAX_DIST_XZ_SQ and point[0][1] >= PLATE_Y and point[0][1] < MAX_DIST_Y: int_x = int(x - cab_offset) int_x_origin = int(x) @@ -89,7 +86,6 @@ def img_to_points(self, img_o, img_red, indices, step, side, cab_offset, clock=F # point.append([img_o[y][x][0], img_o[y][x][1], img_o[y][x][2]]) point.append([int_x_origin, y]) - #logger.info("%d %d instance append" % (y, x)) points.append(point) else: # points that out of bounding cylinder @@ -130,7 +126,7 @@ def intersectLaserPlane(self, ray): # print denominator if abs(denominator) < 0.0000001: - print('warning: < 0.0000001:', denominator, file=sys.stderr) + logger.warning('warning: < 0.0000001: %s', denominator) return False, None v = [self.laser_plane[0][0] - ray[0][0], self.laser_plane[0] @@ -140,14 +136,12 @@ def intersectLaserPlane(self, ray): numerator = dot(v, self.laser_plane[1]) d = float(numerator) / denominator if d < 0: - print('warning: d < 0:', file=sys.stderr) + logger.warning('warning: d < 0') return False, None point = [[ray[0][0] + (ray[1][0] * d), ray[0][1] + (ray[1][1] * d), ray[0][2] + (ray[1][2] * d)]] point.append([self.settings.laserX_L - point[0][0], self.settings.laserY_L - point[0][1], self.settings.laserZ_L - point[0][2]]) - # print point - #logger.info("end intersect calc") return True, point def calculateCameraRay(self, x, y): @@ -173,7 +167,6 @@ def calculateCameraRay(self, x, y): ray = [[x, y, z], normalize([x - self.settings.cameraX, y - self.settings.cameraY, z - self.settings.cameraZ])] # self.place[(x, y)] = ray - # logger.info("end raay calc") return ray def writeTrianglesForColumn(self, lastFrame, currentFrame, tri): @@ -240,7 +233,6 @@ def subProcess(self, img1, img2, maxNumLocations): find out the location of the laser dots return a list of indices [[x,y], [x,y], [x,y]] """ - logger.info("subprocess start") laserLocations = [] numMerged = 0 prevLaserCol = self.firstRowLaserCol @@ -270,8 +262,6 @@ def subProcess(self, img1, img2, maxNumLocations): # print(mag, np.amax(mag), file=sys.stderr) # self.m_laserMagnitudeThreshold = .3 - logger.info("subprocess inited") - logger.info("subprocess row %d col %d" %(self.settings.img_height, self.settings.img_width)) for row in range(self.settings.img_height): m_laserRanges = [] # candidates, [ [starting index, ending index, middle point], ... ] @@ -334,8 +324,6 @@ def subProcess(self, img1, img2, maxNumLocations): if len(m_laserRanges) > NUM_LASER_RANGE_THRESHOLD: self.numSuspectedBadLaserLocations += 1 - logger.info("subprocess end") - return laserLocations def detectBestLaserRange(self, laserRanges, prevLaserCol): @@ -379,16 +367,12 @@ def detectLaserRangeCenter(self, bestRange, img1, img2, row): tmp = freeless(self.settings.laserX_L, self.settings.laserZ_L) im = np.array(Image.open('../../../rule.jpg')) - print(im.shape) # self, img_o, img_red, indices, step, side, cab_offset, clock=False # a = tmp.img_to_points(im, None, [(i, 325) for i in range(200, 352)], 0, 'L', -10) a = tmp.img_to_points(im, None, [(i, 325) for i in range(84, 350)], 0, 'L', 10) a = tmp.img_to_points(im, None, [(i, 325) for i in range(149, 350)], 0, 'L', 10) # a += tmp.img_to_points(im, None, [(i, 325) for i in range(0, 352)], 0, 'L', -10) output = '../../../tmp.pcd' - print(a[0]) - print(a[-1]) - print(a[0][2] - a[-1][2]) write_pcd(a, '../../../tmp.pcd') subprocess.call(['python', '../../../3ds/3ds/PCDViewer/pcd_to_js.py', output], stdout=open('../../../3ds/3ds/PCDViewer/model.js', 'w')) diff --git a/fluxclient/scanner/image_to_pc.py b/fluxclient/scanner/image_to_pc.py index 3df7b06..c6ec979 100644 --- a/fluxclient/scanner/image_to_pc.py +++ b/fluxclient/scanner/image_to_pc.py @@ -1,29 +1,19 @@ #!/usr/bin/env python3 -import struct -from io import BytesIO -import sys, os -import numpy as np +from io import BytesIO import logging +import struct +import sys +import os -logger = logging.getLogger(__name__) - -from PIL import ImageChops -from PIL import Image +import numpy as np +from PIL import ImageChops, Image -try: - from fluxclient.scanner import freeless - from fluxclient.scanner.tools import write_pcd -except: - import freeless - from tools import write_pcd +from fluxclient.scanner.tools import write_pcd +from fluxclient.scanner import freeless -from fluxclient.hw_profile import HW_PROFILE -try: - from fluxclient.scanner import _scanner -except: - pass +logger = logging.getLogger(__name__) class image_to_pc(): @@ -62,14 +52,10 @@ def feed(self, buffer_O, buffer_L, buffer_R, step, l_cab, r_cab): p1[x-coordinate, y-coord, z-coord, r, g, b, step, x, y] """ - logger.info("Feed start") - img_O = self.to_image(buffer_O) img_L = self.to_image(buffer_L) img_R = self.to_image(buffer_R) - logger.info("Feed to imaged") - path = "" if os.path.exists("C:\\DeltaScanResult"): path = "C:\\DeltaScanResult" @@ -77,7 +63,7 @@ def feed(self, buffer_O, buffer_L, buffer_R, step, l_cab, r_cab): path = "DeltaScanResult" if os.path.exists("/Users/simon/Dev/ScanResult"): path = "/Users/simon/Dev/ScanResult" - + # Check Domain if path != "": im1 = Image.fromarray(img_O) @@ -97,17 +83,13 @@ def feed(self, buffer_O, buffer_L, buffer_R, step, l_cab, r_cab): indices_L = self.fs_L.subProcess(img_O, img_L, self.settings.img_height) - logger.info("Subp") - indices_L = [[p[0], p[1] + l_cab]for p in indices_L] # indices_L = [[i, step] for i in range(self.settings.img_height)] - logger.info("End fs_L subProcess") + point_L_this = self.fs_L.img_to_points(img_O, img_L, indices_L, step, 'L', l_cab, clock=True) self.points_L.extend(point_L_this) # return [self.points_to_bytes(point_L_this), []] - logger.info("End subp") - indices_R = self.fs_R.subProcess(img_O, img_R, self.settings.img_height) indices_R = [[p[0], p[1] + r_cab]for p in indices_R] point_R_this = self.fs_R.img_to_points(img_O, img_R, indices_R, step, 'R', r_cab, clock=True) @@ -139,12 +121,10 @@ def merge(self): s_L = sum(int(p[3]) + p[4] + p[5] for p in self.points_L) if s_R > s_L: - print('R', file=sys.stderr) base = self.points_R add_on = self.points_L delta = round(60 / (360 / self.steps)) else: - print('L', file=sys.stderr) base = self.points_L add_on = self.points_R delta = -round(60 / (360 / self.steps)) @@ -154,8 +134,7 @@ def merge(self): record[(base[p][6], base[p][8])] = p self.points_M = base[:] - - print('merging base {}, add_on {}'.format(len(base), len(add_on)), file=sys.stderr) + logger.debug("merging base %s, add_on %s", len(base), len(add_on)) for p in add_on: t = (p[6] + delta) % 400, p[8] @@ -167,7 +146,7 @@ def merge(self): else: self.points_M.append(p) - print('merge done: output self.mpoints_M:{}'.format(len(self.points_M)), file=sys.stderr) + logger.warning('merge done: output self.mpoints_M:%s', len(self.points_M)) def print_progress(step, total): diff --git a/fluxclient/scanner/pc_process.py b/fluxclient/scanner/pc_process.py index 6f46735..6edbddf 100644 --- a/fluxclient/scanner/pc_process.py +++ b/fluxclient/scanner/pc_process.py @@ -138,8 +138,7 @@ def cluster(self, name_in, name_out, thres=2): pc0_size = len(pc[0]) output = (pc[0].add(pc[1])).Euclidean_Cluster(thres) output = sorted(output, key=lambda x: len(x)) - # for i in output: - # print(len(i)) + tmp_pc = self.to_cpp([[], []]) for j in output[-1:]: for i in j: @@ -458,7 +457,7 @@ def closure(self, name_in, name_out, z_value, floor, thick=5): x = np.array([p[0] for p in plane]) y = np.array([p[1] for p in plane]) z = np.array([p[2] for p in plane]) - print('plane len', len(plane), file=sys.stderr) + logger.debug('plane len %i', len(plane)) try: rbf = Rbf(x, y, z, function='thin_plate', smooth=0) @@ -491,8 +490,7 @@ def closure(self, name_in, name_out, z_value, floor, thick=5): tmp.append(p) del rbf except Exception as e: - print('rbf error', file=sys.stderr) - print(e.args, file=sys.stderr) + logger.exception("rbf error") plane += tmp for p in plane: diff --git a/fluxclient/sdk/delta.py b/fluxclient/sdk/delta.py index 72e8950..3cf7b56 100644 --- a/fluxclient/sdk/delta.py +++ b/fluxclient/sdk/delta.py @@ -10,7 +10,6 @@ import socket from time import sleep, time import threading -import sys from msgpack import packb, unpackb, Unpacker from PIL import Image @@ -131,23 +130,21 @@ def connect_delta(cls, target=None, ip=None, client_key=None, password=None, kic if password: type_check(password, str, 'password') - options = {'uuid': UUID(int=0)} - for i, name in [(target, 'uuid'), (ip, 'ipaddr'), (client_key, 'client_key')]: - if i: - options[name] = i - if password: - options['backend_options'] = {'password': password} - - manager = DeviceManager(**options) + if target: + manager = DeviceManager.from_uuid(client_key, target) + elif ip: + manager = DeviceManager.from_ipaddr(client_key, ip) if not manager.authorized: - if password: - manager.authorize_with_password(password) - if manager.authorized: - manager.add_trust('sdk key', client_key.public_key_pem.decode()) - logger.warning('[Warning]: adding new key into flux delta') + manager.authorize_with_password(password) + if manager.authorized: + manager.add_trust('sdk key', client_key.public_key_pem.decode()) + logger.warning('[Warning]: adding new key into flux delta') + else: + raise RuntimeError("Authorize error") + if manager.authorized: - robot = FluxRobot((manager.ipaddr, 23811), client_key) + robot = FluxRobot((ip, 23811), client_key) st_id = robot.report_play()["st_id"] if st_id > 0: diff --git a/fluxclient/toolpath/__init__.py b/fluxclient/toolpath/__init__.py new file mode 100644 index 0000000..e04539d --- /dev/null +++ b/fluxclient/toolpath/__init__.py @@ -0,0 +1,18 @@ + +from ._toolpath import (ToolpathProcessor, + PyToolpathProcessor, + GCodeMemoryWriter, + GCodeFileWriter, + FCodeV1FileWriter, + FCodeV1MemoryWriter, + GCodeParser) +from ._fcode_parser import FCodeParser + +__all__ = ["ToolpathProcessor", + "PyToolpathProcessor", + "GCodeMemoryWriter", + "GCodeFileWriter", + "FCodeV1FileWriter", + "FCodeV1MemoryWriter", + "FCodeParser", + "GCodeParser"] diff --git a/fluxclient/toolpath/_fcode_parser.py b/fluxclient/toolpath/_fcode_parser.py new file mode 100644 index 0000000..5d86b01 --- /dev/null +++ b/fluxclient/toolpath/_fcode_parser.py @@ -0,0 +1,148 @@ + +from zipfile import crc32 +import struct + + +def to_uint8(buf): + return struct.unpack(">= 1 + elif (cmd & 48) == 48: + tp.set_toolhead_fan_speed(reader.float()) + elif cmd & 32: + tp.set_toolhead_pwm(reader.float()) + elif cmd & 16: + block = True if cmd & 8 else False + tp.set_toolhead_heater_temperature(reader.float(), block) + elif cmd == 6: + tp.pause(True) + elif cmd == 5: + tp.pause(False) + elif cmd & 4: + tp.sleep(reader.float() / 1000.0) + else: + tp.on_error(True, "Can not handle command id: %i" % cmd) + + if reader.length != script_length: + raise ValueError("Script body size error (%s, %s)" % (reader.length, script_length)) + + reader.check_crc32() + + metadata_length = reader.data_length() + metadata_buf = reader.read(metadata_length) + reader.check_crc32() + previews = tuple(reader.get_previews()) + + keyvalues = map(lambda kv: kv.split("=", 1), + metadata_buf.decode("utf8").split("\x00")) + metadata = {} + for k, v in map(lambda i: i if len(i) == 2 else (i[0], None), + keyvalues): + if k: + metadata[k] = v + tp.append_comment("%s=%s" % (k, v)) + + return metadata, previews diff --git a/fluxclient/toolpath/bitmap_factory.py b/fluxclient/toolpath/bitmap_factory.py new file mode 100644 index 0000000..4d2c3d1 --- /dev/null +++ b/fluxclient/toolpath/bitmap_factory.py @@ -0,0 +1,78 @@ + +from math import sin, cos +from fluxclient.laser.laser_base import LaserBase + + +class BitmapImage(object): + def __init__(self, buf, size, point1, point2, rotation, threshold): + self.buf = buf + self.width, self.height = size + self.x1, self.y1 = point1 + self.x2, self.y2 = point2 + self.rotation = rotation + self.threshold = threshold + + def get_bound(self): + cx, cy = (self.x1 + self.x2) / 2.0, (self.y1 + self.y2) / 2.0 + r = self.rotation + s, c = sin(-r), cos(-r) + + x1, y1 = self.x1 - cx, self.y1 - cy + x2, y2 = self.x2 - cx, self.y2 - cy + + x1, y1 = c * x1 - s * y1, s * x1 + c * y1 + x2, y2 = c * x2 - s * y2, s * x2 + c * y2 + + orig_bounds = ((x1, y1), (x2, y1), (x2, y2), (x1, y2)) + s, c = sin(r), cos(r) + return tuple(((c * x - s * y + cx, s * x + c * y + cy) + for x, y in orig_bounds)) + + +class BitmapFactory(object): + def __init__(self, radius=85, pixel_per_mm=10): + self._magic = LaserBase() + self._magic.pixel_per_mm = pixel_per_mm + self._magic.radius = radius + self._magic.shading = True + + @property + def pixel_per_mm(self): + return self._magic.pixel_per_mm + + @property + def radius(self): + return self._magic.radius + + def add_image(self, bitmap_image): + self._magic.add_image(bitmap_image.buf, + bitmap_image.width, bitmap_image.height, + bitmap_image.x1, bitmap_image.y1, + bitmap_image.x2, bitmap_image.y2, + bitmap_image.rotation, + bitmap_image.threshold) + + def generate_preview(self): + return self._magic.dump(mode="preview") + + def walk_horizon(self): + ratio = 1 / self.pixel_per_mm + + xlen = len(self._magic.image_map[0]) + xoffset = xlen // 2 + + # xaxis is bitmap to real world mapping + xaxis = tuple((v * ratio + for v in range(-xoffset, xlen - xoffset))) + xlast = (xlen - xoffset + 1) * ratio + + def x_enum(row): + for ptr_x, x in enumerate(xaxis): + yield x, 255 - row[ptr_x] + yield xlast, 0 + + row_length = len(self._magic.image_map) + ytop = row_length * ratio / 2 + for ptr_y, row in enumerate(self._magic.image_map): + y = ytop - ptr_y * ratio + yield (ptr_y / row_length), y, x_enum(row) diff --git a/fluxclient/toolpath/laser.py b/fluxclient/toolpath/laser.py new file mode 100644 index 0000000..8ceed1a --- /dev/null +++ b/fluxclient/toolpath/laser.py @@ -0,0 +1,159 @@ + +from math import pow + +R2 = 85 ** 2 # temp + + +def svg2laser(proc, svg_factory, z_height, travel_speed=2400, + engraving_speed=400, engraving_strength=1.0, + focal_length=6.4, progress_callback=lambda p: None): + proc.append_comment("FLUX Laser Svg Tool") + proc.set_toolhead_pwm(0) + proc.moveto(feedrate=5000, x=0, y=0, z=z_height + focal_length) + current_xy = None + + for src_xy, dist_xy in svg_factory.walk(progress_callback): + if current_xy != src_xy: + proc.set_toolhead_pwm(0) + src_x, src_y = src_xy + proc.moveto(feedrate=travel_speed, x=src_x, y=src_y) + proc.set_toolhead_pwm(engraving_strength) + + dist_x, dist_y = dist_xy + proc.moveto(feedrate=engraving_speed, x=dist_x, y=dist_y) + current_xy = dist_xy + + proc.set_toolhead_pwm(0) + proc.moveto(feedrate=travel_speed, x=0, y=0) + + +def bitmap2laser(proc, bitmap_factory, z_height, one_way=True, + vertical=False, travel_speed=2400, engraving_speed=400, + shading=True, max_engraving_strength=1.0, focal_length=6.4, + progress_callback=lambda p: None): + current_pwm = 0 + proc.append_comment("FLUX Laser Bitmap Tool") + proc.set_toolhead_pwm(0) + proc.moveto(feedrate=5000, x=0, y=0, z=z_height + focal_length) + + ptr_width = 0.5 / bitmap_factory.pixel_per_mm + + if shading: + val2pwm = tuple(max_engraving_strength * pow(((i / 255.0)), 0.7) + for i in range(256)) + else: + val2pwm = tuple(0 if i == 0 else max_engraving_strength + for i in range(256)) + + for progress, y, enum in bitmap_factory.walk_horizon(): + progress_callback(progress) + x_bound = (R2 - y * y) ** 0.5 + + # Find first engrave point in row + for x, val in enum: + if x > -x_bound and val: + proc.moveto(y=y) + + if x - ptr_width > -x_bound: + proc.moveto(feedrate=travel_speed, x=max(x - 3 - ptr_width, + -x_bound)) + proc.moveto(feedrate=travel_speed, x=max(x - ptr_width, + -x_bound)) + proc.set_toolhead_pwm(val2pwm[val]) + current_pwm = val + break + + # Draw until x over limit + for x, val in enum: + if x + ptr_width > x_bound: + if val != current_pwm: + proc.moveto(feedrate=engraving_speed, x=(x - ptr_width)) + proc.set_toolhead_pwm(val) + + if val: + proc.moveto(feedrate=engraving_speed, x=x_bound) + proc.set_toolhead_pwm(0) + current_pwm = 0 + break + + else: + if val != current_pwm: + feedrate = engraving_speed if current_pwm else travel_speed + proc.moveto(feedrate=feedrate, x=x - ptr_width) + current_pwm = val + proc.set_toolhead_pwm(val2pwm[current_pwm]) + + if current_pwm: + proc.set_toolhead_pwm(0) + current_pwm = 0 + + +def laserCalibration(proc, bitmap_factory, z_height, one_way=True, + vertical=False, travel_speed=2400, engraving_speed=400, + shading=True, max_engraving_strength=1.0, + focal_length=6.4, progress_callback=lambda p: None): + + def isAnotherLine(): + return True if last_line - y > 0.1001 else False + + def moveZifNeeded(): + nonlocal last_line, z_height + if isAnotherLine(): + z_height = z_height + 0.2 + proc.moveto(z=z_height) + last_line = y + + #=============init setting=============================================== + current_pwm = 0 + last_line = -85 + proc.append_comment("FLUX Laser Calibration") + proc.set_toolhead_pwm(0) + z_height = z_height + focal_length - 2 + ptr_width = 0.5 / bitmap_factory.pixel_per_mm + proc.moveto(feedrate=5000, x=0, y=0, z=z_height) + val2pwm = tuple(max_engraving_strength * pow(((i / 255.0)), 0.7) + for i in range(256)) + + for progress, y, enum in bitmap_factory.walk_horizon(): + progress_callback(progress) + x_bound = (R2 - y * y) ** 0.5 + + # Find first engrave point in row + for x, val in enum: + if x > -x_bound and val: + proc.moveto(y=y) + + moveZifNeeded() + + if x - ptr_width > -x_bound: + proc.moveto(feedrate=travel_speed, x=max(x - 3 - ptr_width, + -x_bound)) + proc.moveto(feedrate=travel_speed, x=max(x - ptr_width, + -x_bound)) + proc.set_toolhead_pwm(val2pwm[val]) + current_pwm = val + break + + # Draw until x over limit + for x, val in enum: + if x + ptr_width > x_bound: + if val != current_pwm: + proc.moveto(feedrate=engraving_speed, x=(x - ptr_width)) + proc.set_toolhead_pwm(val) + + if val: + proc.moveto(feedrate=engraving_speed, x=x_bound) + proc.set_toolhead_pwm(0) + current_pwm = 0 + break + + else: + if val != current_pwm: + feedrate = engraving_speed if current_pwm else travel_speed + proc.moveto(feedrate=feedrate, x=x - ptr_width) + current_pwm = val + proc.set_toolhead_pwm(val2pwm[current_pwm]) + + if current_pwm: + proc.set_toolhead_pwm(0) + current_pwm = 0 diff --git a/fluxclient/toolpath/penholder.py b/fluxclient/toolpath/penholder.py new file mode 100644 index 0000000..cf308df --- /dev/null +++ b/fluxclient/toolpath/penholder.py @@ -0,0 +1,122 @@ + +from fluxclient.toolpath import vinyl_utils + +R2 = 85 ** 2 # temp + + +def bmp2drawing(proc, bitmap_factory, travel_speed=2400, travel_zheight=5.0, + drawing_zheight=(0.0, 0.2), progress_callback=lambda p: None): + proc.append_comment("FLUX Bitmap Drawing Tool") + proc.moveto(feedrate=5000, x=0, y=0, z=travel_zheight) + + base = drawing_zheight[0] + delta = drawing_zheight[1] - drawing_zheight[0] + working_zheight = tuple((base + ((255 - i) / 255 * delta) for i in range(255))) + + for progress, y, enum in bitmap_factory.walk_horizon(): + progress_callback(progress) + + y_sync = False + x_bound = (R2 - y * y) ** 0.5 + + for x, val in enum: + if -x > x_bound: + pass + elif x > x_bound: + continue + + if not y_sync: + y_sync = True + proc.moveto(feedrate=travel_speed, x=x, y=y) + else: + proc.moveto(feedrate=travel_speed, x=x) + + proc.moveto(feedrate=5000, z=working_zheight[val]) + proc.moveto(feedrate=5000, z=travel_zheight) + + +def svg2drawing(proc, svg_factory, travel_speed=2400, drawing_speed=1200, + travel_zheight=5.0, drawing_zheight=0.0, + progress_callback=lambda p: None): + proc.append_comment("FLUX Drawing Svg Tool") + proc.moveto(feedrate=5000, x=0, y=0, z=travel_zheight) + + current_xy = None + + for src_xy, dist_xy in svg_factory.walk(progress_callback): + if current_xy != src_xy: + proc.moveto(feedrate=5000, z=travel_zheight) + x, y = src_xy + proc.moveto(feedrate=travel_speed, x=x, y=y) + proc.moveto(feedrate=5000, z=drawing_zheight) + x, y = dist_xy + proc.moveto(feedrate=drawing_speed, x=x, y=y) + current_xy = dist_xy + + proc.moveto(feedrate=5000, z=travel_zheight) + proc.moveto(feedrate=travel_speed, x=0, y=0) + + +def svg2vinyl(proc, svg_factory, travel_speed=2400, cutting_speed=800, + travel_zheight=13, cutting_zheight=11.4, + blade_radius=0.24, overcut=2.0, + precut_at=None, progress_callback=lambda p: None): + proc.append_comment("FLUX Vinyl Svg Tool") + proc.moveto(feedrate=5000, x=0, y=0, z=travel_zheight) + + current_vector = None + current_xy = None + + g = svg_factory.walk(progress_callback) + + if precut_at: + src_x, src_y = precut_at + + current_vector = 1, 0 + current_xy = src_x + 1, src_y + + proc.moveto(feedrate=travel_speed, x=src_x, y=src_y) + proc.moveto(feedrate=5000, z=cutting_zheight) + + fix_x, fix_y = vinyl_utils.get_knife_compensation( + current_xy, current_vector, radius=blade_radius) + proc.moveto(feedrate=cutting_speed, x=fix_x, y=fix_y) + + else: + try: + src_xy, dist_xy = g.__next__() + src_x, src_y = src_xy + dist_x, dist_y = dist_xy + + vector = dist_x - src_x, dist_y - src_y + + proc.moveto(feedrate=travel_speed, x=src_x, y=src_y) + proc.moveto(feedrate=5000, z=cutting_zheight) + proc.moveto(feedrate=cutting_speed, x=dist_x, y=dist_y) + + current_vector = vector + current_xy = dist_xy + except StopIteration: + pass + + for src_xy, dist_xy in g: + vector = dist_xy[0] - src_xy[0], dist_xy[1] - src_xy[1] + for fix_x, fix_y in vinyl_utils.fix_knife_direction( + current_xy, current_vector, vector, radius=blade_radius): + proc.moveto(feedrate=400, x=fix_x, y=fix_y) + + if current_xy != src_xy: + # Travel from current_xy to src_xy and start cut + proc.moveto(feedrate=5000, z=travel_zheight) + fix_x, fix_y = vinyl_utils.get_knife_compensation( + src_xy, (-vector[0], -vector[1]), radius=blade_radius) + proc.moveto(feedrate=travel_speed, x=fix_x, y=fix_y) + proc.moveto(feedrate=5000, z=cutting_zheight) + + fix_x, fix_y = vinyl_utils.get_knife_compensation(dist_xy, vector, radius=blade_radius) + proc.moveto(feedrate=cutting_speed, x=fix_x, y=fix_y) + current_vector = vector + current_xy = dist_xy + + proc.moveto(feedrate=5000, z=travel_zheight) + proc.moveto(feedrate=travel_speed, x=0, y=0) diff --git a/fluxclient/toolpath/svg_factory.py b/fluxclient/toolpath/svg_factory.py new file mode 100644 index 0000000..6ed444d --- /dev/null +++ b/fluxclient/toolpath/svg_factory.py @@ -0,0 +1,96 @@ + +from lxml import etree as ET # noqa + +from fluxclient.laser.laser_base import LaserBase +from fluxclient.utils.svg_parser import SVGParser + + +class SvgImage(object): + _preview_buf = None + _coordinate_set = False + + buf = None + viewbox_width = viewbox_height = None + x1 = x2 = y1 = y2 = rotation = None + + def __init__(self, buf): + self.set_svg(buf) + + def set_svg(self, buf): + errors, result = SVGParser.preprocess(buf) + if errors and errors[-1] == "EMPTY": + raise RuntimeError("EMPTY") + self.errors = errors + self.buf, self.viewbox_width, self.viewbox_height = result + + def set_preview(self, preview_size, buf): + self._preview_width, self._preview_height = preview_size + self._preview_buf = buf + + def set_image_coordinate(self, point1, point2, rotation): + self._coordinate_set = True + + self.x1, self.y1 = point1 + self.x2, self.y2 = point2 + self.rotation = rotation + + +class SvgFactory(object): + def __init__(self, radius=85): + self._magic = LaserBase() + self._magic.pixel_per_mm = 10 + self._magic.radius = radius + self._magic.shading = False + + self._svg_images = [] + + @property + def radius(self): + return self._magic.radius + + def add_image(self, svg_image): + self._svg_images.append(svg_image) + + def generate_preview(self): + for img in self._svg_images: + if img._preview_buf: + self._magic.add_image(img._preview_buf, + img._preview_width, img._preview_height, + img.x1, img.y1, img.x2, img.y2, + img.rotation, 100) + return self._magic.dump(mode="preview") + + def walk(self, progress_callback=lambda p: None): + images_length = len(self._svg_images) + + for index, image in enumerate(self._svg_images, start=1): + progress_callback((index - 0.5) / images_length) + + svg_data = image.buf.decode('utf8') + root = ET.fromstring(svg_data) + viewbox = list( + map(float, root.attrib['viewBox'].replace(',', ' ').split()) + ) + + path_data = SVGParser.elements_to_list(root) + progress_callback(index / images_length) + + for each_path in SVGParser.process(path_data, (None, None, + image.x1, image.y1, + image.x2, image.y2, + image.rotation), + viewbox, self.radius): + # flag that means extruder should move to rather than drawto + src_xy = None + move_to = True + for x, y in each_path: + if x == '\n': + move_to = True + else: + if move_to: + src_xy = (x, y) + move_to = False + else: + next_xy = (x, y) + yield src_xy, next_xy + src_xy = next_xy diff --git a/fluxclient/toolpath/vinyl_utils.py b/fluxclient/toolpath/vinyl_utils.py new file mode 100644 index 0000000..b0f391e --- /dev/null +++ b/fluxclient/toolpath/vinyl_utils.py @@ -0,0 +1,45 @@ +from math import sqrt, sin, cos, acos + +KNIFE_RADIUS = 0.6 +ROTATE_ANGLE = 0.1 +ANGLE_THRESHOLD = 0.01 + + +def rotate(v, angle): + return (v[0] * cos(angle) - v[1] * sin(angle), + v[0] * sin(angle) + v[1] * cos(angle)) + + +def length(v): + x, y = v + return sqrt(x * x + y * y) + + +def get_angle(v1, v2): + x1, y1 = v1 + x2, y2 = v2 + + d = -1 if x1 * y2 - y1 * x2 < 0 else 1 + return d * acos(max(min((x1 * x2 + y1 * y2) / length(v1) / length(v2), 1), + -1)) + + +def get_knife_compensation(position, vector, radius=KNIFE_RADIUS): + r = radius / length(vector) + return position[0] + vector[0] * r, position[1] + vector[1] * r + + +def fix_knife_direction(current_pos, vector, target_vector, + radius=KNIFE_RADIUS): + angle = get_angle(vector, target_vector) + + while abs(angle) > ANGLE_THRESHOLD: + dir = 1 if angle > 0 else -1 + vector = rotate(vector, dir * min(ROTATE_ANGLE, abs(angle))) + v_scale = radius / length(vector) + vector = (vector[0] * v_scale, vector[1] * v_scale) + + x, y = current_pos[0] + vector[0], current_pos[1] + vector[1] + yield x, y + + angle = get_angle(vector, target_vector) diff --git a/setup_utils.py b/setup_utils.py index 77509bd..1aa1a8e 100644 --- a/setup_utils.py +++ b/setup_utils.py @@ -100,7 +100,7 @@ def get_entry_points(): "flux_manager=fluxclient.commands.manager:main", "flux_camera=fluxclient.commands.camera:main", "flux_scan=fluxclient.commands.scan:main", - "flux_laser=fluxclient.commands.laser:main", + "flux_toolpath=fluxclient.commands.toolpath:main", "flux_g2f=fluxclient.commands.fcode:gcode_2_fcode", "flux_f2g=fluxclient.commands.fcode:fcode_2_gcode", "flux_exp=fluxclient.commands.experiment_tool:main", @@ -110,15 +110,26 @@ def get_entry_points(): def get_default_extra_compile_args(): if is_darwin(): - return ["--stdlib=libc++", "-mmacosx-version-min=10.9"] + return ["--stdlib=libc++", "-std=c++11", "-mmacosx-version-min=10.9"] elif is_linux(): - return ["-lstdc++"] + return ["-lstdc++", "-std=c++11"] elif is_windows(): return [] def create_utils_extentions(): return [ + Extension( + 'fluxclient.toolpath._toolpath', + sources=[ + "src/toolpath/gcode_parser.cpp", + "src/toolpath/gcode_writer.cpp", + "src/toolpath/fcode_v1_writer.cpp", + "src/toolpath/py_processor.cpp", + "src/toolpath/_toolpath.pyx" + ], + language="c++", + extra_compile_args=get_default_extra_compile_args()), Extension( 'fluxclient.utils._utils', sources=[ @@ -139,8 +150,20 @@ def create_pcl_extentions(): library_dirs = [] try: + if is_darwin(): + try: + include_dirs += [locate_includes("flann")] + except RuntimeError: + sys.stderr.write("library flann not found, its may cause " + "compile issue in some environ.") + + if not os.path.exists("/usr/local/include/boost"): + raise RuntimeError("boost lib include not found at " + "/usr/local/include/boost/") + if is_posix(): include_dirs += [locate_includes("eigen3")] + libraries += ["pcl_common", "pcl_octree", "pcl_io", "pcl_kdtree", "pcl_search", "pcl_sample_consensus", "pcl_filters", "pcl_features", "pcl_segmentation", "pcl_surface", diff --git a/src/scanner/scan_module.cpp b/src/scanner/scan_module.cpp index 40eec5b..b9b5695 100644 --- a/src/scanner/scan_module.cpp +++ b/src/scanner/scan_module.cpp @@ -182,9 +182,6 @@ int SCP(PointXYZRGBNormalPtr scene, FeatureCloudTPtr scene_features, PointXYZRGB downsample(scene, scene_clone, leaf); downsample(object, object_clone, leaf); - // pcl::console::print_info (" before-> cloud size:%d, cloud2 size:%d \n",object->points.size(), scene->points.size()); - // pcl::console::print_info (" after-> cloud size:%d, cloud2 size:%d \n",object_clone->points.size(), scene_clone->points.size()); - FE(scene_clone, scene_features, 10); FE(object_clone, object_features, 10); diff --git a/src/toolpath/_toolpath.pyx b/src/toolpath/_toolpath.pyx new file mode 100644 index 0000000..d1a47e1 --- /dev/null +++ b/src/toolpath/_toolpath.pyx @@ -0,0 +1,186 @@ + +from libc.math cimport isnan, NAN +from libcpp cimport bool +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp.pair cimport pair +from _toolpathlib cimport (ToolpathProcessor as _ToolpathProcessor, + GCodeParser as _GCodeParser, + GCodeMemoryWriter as _GCodeMemoryWriter, + GCodeFileWriter as _GCodeFileWriter, + FCodeV1MemoryWriter as _FCodeV1MemoryWriter, + FCodeV1FileWriter as _FCodeV1FileWriter, + PythonToolpathProcessor) + + +cdef class ToolpathProcessor: + cdef _ToolpathProcessor *_proc + + def __dealloc__(self): + if self._proc: + del self._proc + self._proc = NULL + + cpdef moveto(self, float feedrate=NAN, + float x=NAN, float y=NAN, float z=NAN, + float e0=NAN, float e1=NAN, float e2=NAN): + cdef int flags = 0 + if not isnan(feedrate): + flags |= 64; + if not isnan(x): + flags |= 32; + if not isnan(y): + flags |= 16; + if not isnan(z): + flags |= 8; + if not isnan(e0): + flags |= 4; + if not isnan(e1): + flags |= 2; + if not isnan(e2): + flags |= 1; + self._proc.moveto(flags, feedrate, x, y, z, e0, e1, e2) + + cpdef sleep(self, float seconds): + self._proc.sleep(seconds) + + cpdef enable_motor(self): + self._proc.enable_motor() + + cpdef disable_motor(self): + self._proc.disable_motor() + + cpdef pause(self, bool to_standby_position): + self._proc.pause(to_standby_position) + + cpdef home(self): + self._proc.home() + + cpdef set_toolhead_heater_temperature(self, float temperature, bool wait): + self._proc.set_toolhead_heater_temperature(temperature, wait) + + cpdef set_toolhead_fan_speed(self, float strength): + self._proc.set_toolhead_fan_speed(strength) + + cpdef set_toolhead_pwm(self, float strength): + self._proc.set_toolhead_pwm(strength) + + cpdef append_comment(self, comment): + cdef bytes c = comment.encode() + self._proc.append_comment(c, len(c)) + + cpdef on_error(self, bool critical, str message): + cdef bytes cmessage = message.encode() + self._proc.on_error(critical, cmessage, len(cmessage)) + + cpdef terminated(self): + self._proc.terminated() + + +cdef class PyToolpathProcessor(ToolpathProcessor): + cdef object pvgc + + def __init__(self, callback): + self.pvgc = callback + self._proc = <_ToolpathProcessor*>new PythonToolpathProcessor(self.pvgc) + + +cdef class GCodeMemoryWriter(ToolpathProcessor): + def __init__(self): + self._proc = <_ToolpathProcessor*>new _GCodeMemoryWriter() + + def get_buffer(self): + # TODO + # cdef const string& swap = (<_GCodeMemoryWriter*>self._proc).get_buffer() + # return swap.c_str()[:swap.size()] + cdef string swap = (<_GCodeMemoryWriter*>self._proc).get_buffer() + return swap.c_str()[:swap.size()] + + +cdef class GCodeFileWriter(ToolpathProcessor): + def __init__(self, filename): + self._proc = <_ToolpathProcessor*>new _GCodeFileWriter(filename.encode()) + + +cdef class FCodeV1MemoryWriter(ToolpathProcessor): + cdef string headtype + cdef vector[pair[string, string]] metadata + cdef vector[string] previews + + def __init__(self, head_type, metadata, previews): + self.headtype = head_type.encode() + self.metadata = ((k.encode(), v.encode()) for k, v in metadata.items()) + self.previews = previews + self._proc = <_ToolpathProcessor*>new _FCodeV1MemoryWriter(&self.headtype, + &self.metadata, &self.previews) + + def get_buffer(self): + # TODO + # cdef const string& swap = (<_FCodeV1MemoryWriter*>self._proc).get_buffer() + # return swap.c_str()[:swap.size()] + cdef string swap = (<_FCodeV1MemoryWriter*>self._proc).get_buffer() + return swap.c_str()[:swap.size()] + + def set_metadata(self, metadata): + self.metadata = ((k.encode(), v.encode()) for k, v in metadata.items()) + (<_FCodeV1MemoryWriter*>self._proc).metadata = &self.metadata + + def set_previews(self, previews): + self.previews = previews + (<_FCodeV1MemoryWriter*>self._proc).previews = &self.previews + + def get_metadata(self): + return dict(self.metadata) + + def errors(self): + return (<_FCodeV1MemoryWriter*>self._proc).errors + + +cdef class FCodeV1FileWriter(ToolpathProcessor): + cdef string filename, headtype + cdef vector[pair[string, string]] metadata + cdef vector[string] previews + + def __init__(self, filename, head_type, metadata, previews): + self.filename = filename.encode() + self.headtype = head_type.encode() + self.metadata = ((k.encode(), v.encode()) for k, v in metadata.items()) + self.previews = previews + self._proc = <_ToolpathProcessor*>new _FCodeV1FileWriter(self.filename.c_str(), &self.headtype, + &self.metadata, &self.previews) + + def set_metadata(self, metadata): + self.metadata = ((k.encode(), v.encode()) for k, v in metadata.items()) + (<_FCodeV1FileWriter*>self._proc).metadata = &self.metadata + + def set_previews(self, previews): + self.previews = previews + (<_FCodeV1FileWriter*>self._proc).previews = &self.previews + + def get_metadata(self): + return dict(self.metadata) + + def errors(self): + return (<_FCodeV1FileWriter*>self._proc).errors + + +cdef class GCodeParser: + cdef _GCodeParser *_parser + + def __cinit__(self): + self._parser = new _GCodeParser() + + def __dealloc__(self): + del self._parser + + cdef set_c_processor(self, _ToolpathProcessor *proc): + self._parser.set_processor(proc) + + cpdef set_processor(self, ToolpathProcessor py_proc): + self.set_c_processor(py_proc._proc) + + cpdef parse_command(self, bytes command): + self._parser.parse_command(command, len(command)) + + cpdef parse_from_file(self, filename): + self._parser.parse_from_file(filename.encode()) diff --git a/src/toolpath/_toolpathlib.pxd b/src/toolpath/_toolpathlib.pxd new file mode 100644 index 0000000..f5073f7 --- /dev/null +++ b/src/toolpath/_toolpathlib.pxd @@ -0,0 +1,64 @@ + +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp.pair cimport pair +from libcpp cimport bool + +cdef extern from "toolpath.h" namespace "FLUX": + cdef cppclass ToolpathProcessor: + void moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2) nogil + void sleep(float seconds) nogil + void enable_motor() nogil + void disable_motor() nogil + void pause(bool to_standby_position) nogil + void home() nogil + void set_toolhead_heater_temperature(float temperature, bool wait) nogil + void set_toolhead_fan_speed(float strength) nogil + void set_toolhead_pwm(float strength) nogil + void append_comment(const char* message, size_t length) nogil + void on_error(bool critical, const char* message, size_t length) nogil + void terminated() nogil + + +cdef extern from "gcode.h" namespace "FLUX": + cdef cppclass GCodeParser: + GCodeParser() nogil except + + void set_processor(ToolpathProcessor*) nogil + void parse_from_file(const char*) nogil except + + void parse_command(const char*, size_t) nogil except + + + float feedrate + float position[3] + float position_offset[3] + float filaments[3] + float filaments_offset[3] + int T + bool from_inch + bool absolute + + cdef cppclass GCodeMemoryWriter: + GCodeMemoryWriter() nogil + string get_buffer() nogil + + cdef cppclass GCodeFileWriter: + GCodeFileWriter(const char* filename) nogil except + + + +cdef extern from "fcode.h" namespace "FLUX": + cdef cppclass FCodeV1MemoryWriter: + FCodeV1MemoryWriter(string*, vector[pair[string, string]]*, vector[string]*) nogil + string get_buffer() nogil + vector[pair[string, string]] *metadata + vector[string] *previews + vector[string] errors + + cdef cppclass FCodeV1FileWriter: + FCodeV1FileWriter(const char*, string*, vector[pair[string, string]]*, vector[string]*) nogil + vector[pair[string, string]] *metadata + vector[string] *previews + vector[string] errors + + +cdef extern from "py_processor.h" namespace "FLUX": + cdef cppclass PythonToolpathProcessor: + PythonToolpathProcessor(object) nogil diff --git a/src/toolpath/crc32.c b/src/toolpath/crc32.c new file mode 100644 index 0000000..81253aa --- /dev/null +++ b/src/toolpath/crc32.c @@ -0,0 +1,104 @@ +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * First, the polynomial itself and its table of feedback terms. The + * polynomial is + * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + * + * Note that we take it "backwards" and put the highest-order term in + * the lowest-order bit. The X^32 term is "implied"; the LSB is the + * X^31 term, etc. The X^0 term (usually shown as "+1") results in + * the MSB being 1 + * + * Note that the usual hardware shift register implementation, which + * is what we're using (we're merely optimizing it by doing eight-bit + * chunks at a time) shifts bits into the lowest-order term. In our + * implementation, that means shifting towards the right. Why do we + * do it this way? Because the calculated CRC must be transmitted in + * order from highest-order term to lowest-order term. UARTs transmit + * characters in order from LSB to MSB. By storing the CRC this way + * we hand it to the UART in the order low-byte to high-byte; the UART + * sends each low-bit to hight-bit; and the result is transmission bit + * by bit from highest- to lowest-order term without requiring any bit + * shuffling on our part. Reception works similarly + * + * The feedback terms table consists of 256, 32-bit entries. Notes + * + * The table can be generated at runtime if desired; code to do so + * is shown later. It might not be obvious, but the feedback + * terms simply represent the results of eight shift/xor opera + * tions for all combinations of data and CRC register values + * + * The values must be right-shifted by eight bits by the "updcrc + * logic; the shift must be unsigned (bring in zeroes). On some + * hardware you could probably optimize the shift in assembler by + * using byte-swap instructions + * polynomial $edb88320 + * + * + * CRC32 code derived from work by Gary S. Brown. + */ + +#include +#include + +static uint32_t crc32_tab[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +uint32_t +crc32(uint32_t crc, const void *buf, size_t size) +{ + const uint8_t *p; + + p = (uint8_t *)buf; + crc = crc ^ ~0U; + + while (size--) + crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + + return crc ^ ~0U; +} \ No newline at end of file diff --git a/src/toolpath/fcode.h b/src/toolpath/fcode.h new file mode 100644 index 0000000..c66ff45 --- /dev/null +++ b/src/toolpath/fcode.h @@ -0,0 +1,85 @@ + +#include +#include +#include +#include +#include "toolpath.h" + + +namespace FLUX { + class FCodeV1Base : public FLUX::ToolpathProcessor { + protected: + std::ostream *stream; + unsigned long script_crc32; + virtual void write(const char* buf, size_t size, unsigned long *crc32); + void write(float value, unsigned long *crc32); + void write(uint32_t value, unsigned long *crc32); + void write_command(unsigned char cmd, unsigned long *crc32); + public: + std::vector errors; + virtual void moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2); + virtual void sleep(float seconds); + virtual void enable_motor(void); + virtual void disable_motor(void); + virtual void pause(bool to_standby_position); + virtual void home(void); + virtual void set_toolhead_heater_temperature(float temperature, bool wait); + virtual void set_toolhead_fan_speed(float strength); + virtual void set_toolhead_pwm(float strength); + + virtual void append_anchor(uint32_t value); + virtual void append_comment(const char* message, size_t length); + + virtual void on_error(bool critical, const char* message, size_t length); + virtual void terminated(void) = 0; + }; + + class FCodeV1 : public FLUX::FCodeV1Base { + protected: + int script_offset; + // Return metadata crc32 + unsigned long write_metadata(void); + void begin(void); + public: + std::string *head_type; + float travled; + float time_cost; + float home_x, home_y, home_z; + float current_feedrate, current_x, current_y, current_z; + float max_x, max_y, max_z, max_r, filament[3]; + + std::vector> *metadata; + std::vector *previews; + + FCodeV1(std::string *type, std::vector> *file_metadata, + std::vector *image_previews); + + virtual void moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2); + virtual void sleep(float seconds); + virtual void home(void); + virtual void terminated(void); + }; + + class FCodeV1MemoryWriter : public FLUX::FCodeV1 { + protected: + bool opened; + public: + FCodeV1MemoryWriter( + std::string *type, std::vector> *file_metadata, + std::vector *image_previews); + ~FCodeV1MemoryWriter(void); + std::string get_buffer(void); + virtual void write(const char* buf, size_t size, unsigned long *crc32); + virtual void terminated(void); + }; + + class FCodeV1FileWriter : public FLUX::FCodeV1 { + public: + FCodeV1FileWriter(const char* filename, + std::string *type, std::vector> *file_metadata, + std::vector *image_previews); + ~FCodeV1FileWriter(void); + virtual void write(const char* buf, size_t size, unsigned long *crc32); + virtual void terminated(void); + }; +} \ No newline at end of file diff --git a/src/toolpath/fcode_v1_writer.cpp b/src/toolpath/fcode_v1_writer.cpp new file mode 100644 index 0000000..74500b3 --- /dev/null +++ b/src/toolpath/fcode_v1_writer.cpp @@ -0,0 +1,307 @@ +#include +#include +#include +#include +#include "crc32.c" +#include "fcode.h" + +void FLUX::FCodeV1Base::write(const char* buf, size_t size, unsigned long *crc32_ptr) { + stream->write(buf, size); + if(crc32_ptr) { + *crc32_ptr = crc32(*crc32_ptr, (const void *)buf, size); + // *crc32_ptr = crc32(*crc32_ptr, (const Bytef*)buf, size); + } +} + +void FLUX::FCodeV1Base::write(float value, unsigned long *crc32) { + write((const char *)&value, 4, crc32); +} + +void FLUX::FCodeV1Base::write(uint32_t value, unsigned long *crc32) { + write((const char *)&value, sizeof(uint32_t), crc32); +} + + +void FLUX::FCodeV1Base::write_command(unsigned char cmd, unsigned long *crc32) { + write((const char *)&cmd, 1, crc32); +} + + +void FLUX::FCodeV1Base::moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2) { + write_command(flags | 128, &script_crc32); + + if(flags & FLAG_HAS_FEEDRATE && feedrate > 0) write(feedrate, &script_crc32); + if(flags & FLAG_HAS_X) write(x, &script_crc32); + if(flags & FLAG_HAS_Y) write(y, &script_crc32); + if(flags & FLAG_HAS_Z) write(z, &script_crc32); + if(flags & FLAG_HAS_E(0)) write(e0, &script_crc32); + if(flags & FLAG_HAS_E(1)) write(e1, &script_crc32); + if(flags & FLAG_HAS_E(2)) write(e2, &script_crc32); +} + +void FLUX::FCodeV1Base::sleep(float seconds) { + write_command(4, &script_crc32); + write(seconds * 1000, &script_crc32); +} + +void FLUX::FCodeV1Base::enable_motor(void) { errors.push_back(std::string("NOT_SUPPORT ENABLE_MOTOR")); } + +void FLUX::FCodeV1Base::disable_motor(void) { errors.push_back(std::string("NOT_SUPPORT DISABLE_MOTOR")); } + +void FLUX::FCodeV1Base::pause(bool to_standby_position) { + write_command((to_standby_position ? 5 : 6), &script_crc32); +} + +void FLUX::FCodeV1Base::home(void) { + write_command(1, &script_crc32); +} +void FLUX::FCodeV1Base::set_toolhead_heater_temperature(float temperature, bool wait) { + write_command(wait ? 24 : 16, &script_crc32); + write(temperature, &script_crc32); +} +void FLUX::FCodeV1Base::set_toolhead_fan_speed(float strength) { + write_command(48, &script_crc32); + write(strength, &script_crc32); +} +void FLUX::FCodeV1Base::set_toolhead_pwm(float strength) { + write_command(32, &script_crc32); + write(strength, &script_crc32); +} + +void FLUX::FCodeV1Base::append_anchor(uint32_t value) {} +void FLUX::FCodeV1Base::append_comment(const char* message, size_t length) {} +void FLUX::FCodeV1Base::on_error(bool critical, const char* message, size_t length) { + if(critical) { + errors.push_back(std::string("ERROR ") + std::string(message, length)); + } else { + errors.push_back(std::string("WARNING ") + std::string(message, length)); + } +} + + +FLUX::FCodeV1::FCodeV1(std::string *type, std::vector> *file_metadata, std::vector *image_previews) { + home_x = 0; home_y = 0, home_z = 240; + current_feedrate = 0; + current_x = 0; current_y = 0; current_z = 0; + time_cost = 0; + max_x = max_y = max_z = max_r = filament[0] = filament[1] = filament[2] = 0; + + head_type = type; + metadata = file_metadata; + previews = image_previews; + script_crc32 = 0; +} + +void FLUX::FCodeV1::begin(void) { + write("FCx0001\n", 8, NULL); + script_offset = stream->tellp(); + if(script_offset < 0) { + throw std::runtime_error("NOT_SUPPORT STREAM"); + } + write("\x00\x00\x00\x00", 4, NULL); +} + +void FLUX::FCodeV1::moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2) { + if(flags & FLAG_HAS_FEEDRATE && feedrate > 0) { + current_feedrate = feedrate; + } + + bool has_move = false; + float mv[3] = {0, 0, 0}; + float fm[3] = {0, 0, 0}; + + if(flags & FLAG_HAS_X) { + mv[0] = x - current_x; + current_x = x; + max_x = fmax(max_x, x); + has_move = true; + } + if(flags & FLAG_HAS_Y) { + mv[1] = y - current_y; + current_y = y; + max_y = fmax(max_y, y); + has_move = true; + } + if(flags & FLAG_HAS_X || flags & FLAG_HAS_Y) { + float r = sqrtf(pow(current_x, 2) + pow(current_y, 2)); + max_r = fmax(max_r, r); + has_move = true; + } + if(flags & FLAG_HAS_Z) { + mv[2] = z - current_z; + current_z = z; + max_z = fmax(max_z, z); + has_move = true; + } + if(flags & FLAG_HAS_E(0)) { fm[0] = filament[0] - e0; filament[0] = e0; } + if(flags & FLAG_HAS_E(1)) { fm[1] = filament[1] - e1; filament[1] = e1; } + if(flags & FLAG_HAS_E(2)) { fm[2] = filament[2] - e2; filament[2] = e2; } + + if(has_move) { + float dist = sqrtf(pow(mv[0], 2) + pow(mv[1], 2) + pow(mv[2], 2)); + if(!isnan(dist)) { + travled += dist; + if(feedrate > 0) { + float tc = (dist / feedrate) * 60.0; + if(!isnan(tc)) time_cost += tc; + } else { + on_error(false, "UNDEF_FEEDRATE", 14); + } + } + } else { + float tc = (fmax(fmax(fm[0], fm[1]), fm[2]) / feedrate) * 60.0; + if(!isnan(tc)) time_cost += tc; + } + FCodeV1Base::moveto(flags, feedrate, x, y, z, e0, e1, e2); +} +void FLUX::FCodeV1::sleep(float seconds) { + if(!isnan(seconds)) time_cost += seconds; + FCodeV1Base::sleep(seconds); +} +void FLUX::FCodeV1::home(void) { + current_x = home_x; current_y = home_y; current_z = home_z; + FCodeV1Base::home(); +} + +unsigned long FLUX::FCodeV1::write_metadata(void) { + char metabuf[128]; + int metasize; + unsigned long metadata_crc32 = 0; + + if(filament[2]) { + metasize = snprintf(metabuf, 128, "%.2f,%.2f,%.2f", filament[0], filament[1], filament[2]); + } else if(filament[1]) { + metasize = snprintf(metabuf, 128, "%.2f,%.2f", filament[0], filament[1]); + } else { + metasize = snprintf(metabuf, 128, "%.2f", filament[0]); + } + metadata->insert(metadata->begin(), + std::pair("FILAMENT_USED", std::string(metabuf, metasize))); + + metasize = snprintf(metabuf, 32, "%.2f", max_r + 0.2); + metadata->insert(metadata->begin(), + std::pair("MAX_R", std::string(metabuf, metasize))); + + metasize = snprintf(metabuf, 32, "%.2f", max_z + 0.2); + metadata->insert(metadata->begin(), + std::pair("MAX_Z", std::string(metabuf, metasize))); + + metasize = snprintf(metabuf, 32, "%.2f", max_y + 0.2); + metadata->insert(metadata->begin(), + std::pair("MAX_Y", std::string(metabuf, metasize))); + + metasize = snprintf(metabuf, 32, "%.2f", max_x + 0.2); + metadata->insert(metadata->begin(), + std::pair("MAX_X", std::string(metabuf, metasize))); + + metasize = snprintf(metabuf, 32, "%.2f", travled); + metadata->insert(metadata->begin(), + std::pair("TRAVEL_DIST", std::string(metabuf, metasize))); + + metasize = snprintf(metabuf, 32, "%.2f", time_cost); + metadata->insert(metadata->begin(), + std::pair("TIME_COST", std::string(metabuf, metasize))); + + metadata->insert(metadata->begin(), + std::pair("HEAD_TYPE", *head_type)); + metadata->insert(metadata->begin(), + std::pair("VERSION", "1")); + + for(auto it=metadata->begin();it!=metadata->end();++it) { + // for(auto it : *metadata) { + write(it->first.data(), it->first.size(), &metadata_crc32); + write("=", 1, &metadata_crc32); + write(it->second.data(), it->second.size(), &metadata_crc32); + write("\x00", 1, &metadata_crc32); + } + return metadata_crc32; +} + +void FLUX::FCodeV1::terminated(void) { + uint32_t u32value; + + int script_end_offset = stream->tellp(); + stream->seekp(script_offset, stream->beg); + u32value = script_end_offset - script_offset - 4; + write(u32value, NULL); + stream->seekp(script_end_offset, stream->beg); + write((uint32_t)script_crc32, NULL); + + int metadata_offset = stream->tellp(); + int metadata_end_offset; + write("\x00\x00\x00\x00", 4, NULL); + unsigned long metadata_crc32 = write_metadata(); + metadata_end_offset = stream->tellp(); + stream->seekp(metadata_offset, stream->beg); + u32value = metadata_end_offset - metadata_offset - 4; + write(u32value, NULL); + stream->seekp(metadata_end_offset, stream->beg); + write((uint32_t)metadata_crc32, NULL); + + for(auto p=previews->begin();pend();++p) { + u32value = p->size(); + write(u32value, NULL); + write(p->data(), u32value, NULL); + } + write("\x00\x00\x00\x00", 4, NULL); +} + + +FLUX::FCodeV1MemoryWriter::FCodeV1MemoryWriter( + std::string *type, std::vector> *file_metadata, + std::vector *image_previews) : FCodeV1(type, file_metadata, image_previews) { + stream = new std::stringstream(); + opened = true; + begin(); +} + +FLUX::FCodeV1MemoryWriter::~FCodeV1MemoryWriter(void) { + if(opened) { + terminated(); + } + delete stream; +} + +std::string FLUX::FCodeV1MemoryWriter::get_buffer(void) { + return ((std::stringstream*)stream)->str(); +} + +void FLUX::FCodeV1MemoryWriter::write(const char* buf, size_t size, unsigned long *crc32) { + if(opened) { + FLUX::FCodeV1Base::write(buf, size, crc32); + } +} + +void FLUX::FCodeV1MemoryWriter::terminated(void) { + if(opened) { + FLUX::FCodeV1::terminated(); + opened = false; + } +} + + +FLUX::FCodeV1FileWriter::FCodeV1FileWriter(const char* filename, + std::string *type, std::vector> *file_metadata, + std::vector *image_previews) : FCodeV1(type, file_metadata, image_previews) { + stream = new std::ofstream(filename); + if(stream->fail()) { + throw std::runtime_error("OPEN FILE ERROR"); + } + begin(); +} + + +FLUX::FCodeV1FileWriter::~FCodeV1FileWriter(void) { + delete stream; +} + +void FLUX::FCodeV1FileWriter::write(const char* buf, size_t size, unsigned long *crc32) { + if(((std::ofstream*)stream)->is_open()) { + FLUX::FCodeV1Base::write(buf, size, crc32); + } +} + +void FLUX::FCodeV1FileWriter::terminated(void) { + FLUX::FCodeV1::terminated(); + if(((std::ofstream*)stream)->is_open()) { ((std::ofstream*)stream)->close(); } +} diff --git a/src/toolpath/gcode.h b/src/toolpath/gcode.h new file mode 100644 index 0000000..c3ec0f8 --- /dev/null +++ b/src/toolpath/gcode.h @@ -0,0 +1,106 @@ + +#include +#include +#include +#include +#include +#include +#include "toolpath.h" + + +namespace FLUX { + class GCodeParser { + public: + float feedrate; + + // AXIS[X, Y, Z] + float position[3]; + float position_offset[3]; + + // AXIS E[T0, T1, T2] + float filaments[3]; + float filaments_offset[3]; + + int T; + + // true if G0/G1/G92 command unit is inch + bool from_inch; + // true if G0/G1 command unit is absolute + bool absolute; + + GCodeParser(void); + void set_processor(FLUX::ToolpathProcessor* handler); + void parse_from_file(const char* filepth); + void parse_command(const char* linep, size_t size); + + protected: + FLUX::ToolpathProcessor* handler; + + void parse_comment(const char* linep, size_t offset, size_t size); + + int handle_g0g1(const char* linep, int offset, int size); + int handle_g4(const char* linep, int offset, int size); + int handle_g28(const char* linep, int offset, int size); + int handle_g92(const char* linep, int offset, int size); + int handle_m17(const char* linep, int offset, int size); + int handle_m18m84(const char* linep, int offset, int size); + int handle_m24m25m226(const char* linep, int offset, int size); + int handle_m104m109(const char* linep, int offset, int size, bool wait); + int handle_m106(const char* linep, int offset, int size); + int handle_m107(const char* linep, int offset, int size); + int handle_x2(const char* linep, int offset, int size); + }; + + class GCodeWriterBase : public FLUX::ToolpathProcessor { + public: + int t; + char buffer[32]; + + GCodeWriterBase(); + virtual void write(const char* buf, size_t size) = 0; + virtual void terminated(void) = 0; + + virtual void moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2); + virtual void sleep(float seconds); + virtual void enable_motor(void); + virtual void disable_motor(void); + virtual void pause(bool to_standby_position); + virtual void home(void); + virtual void set_toolhead_heater_temperature(float temperature, bool wait); + virtual void set_toolhead_fan_speed(float strength); + virtual void set_toolhead_pwm(float strength); + + virtual void append_anchor(uint32_t value); + virtual void append_comment(const char* message, size_t length); + + virtual void on_error(bool critical, const char* message, size_t length); + }; + + + class GCodeMemoryWriter : public GCodeWriterBase { + protected: + bool opened; + std::stringstream *stream; + public: + GCodeMemoryWriter(void); + ~GCodeMemoryWriter(void); + std::string get_buffer(void); + virtual void write(const char* buf, size_t size); + virtual void terminated(void); + }; + + class GCodeFileWriter : public GCodeWriterBase { + protected: + std::ofstream *stream; + public: + GCodeFileWriter(const char* filename); + ~GCodeFileWriter(void); + virtual void write(const char* buf, size_t size); + virtual void terminated(void); + }; +} + + +static inline double inch2mm(float inch) { + return inch * 25.4; +} diff --git a/src/toolpath/gcode_parser.cpp b/src/toolpath/gcode_parser.cpp new file mode 100644 index 0000000..e5073fc --- /dev/null +++ b/src/toolpath/gcode_parser.cpp @@ -0,0 +1,395 @@ + +#include +#include +#include +#include "gcode.h" + + +static inline bool move_to_next_char(const char* linep, int offset, int size, int* next_offset) { + while(offset < size) { + if(linep[offset] != ' ') { + *next_offset = offset; + return true; + } + offset++; + } + *next_offset = offset; + return false; +} + + +static inline int parse_command_int(const char* linep, int offset, int size, int* val) { + char* endptr; + if(offset + 1 >= size) { + *val = 0; + return size; + } + *val = (int)strtol(linep + offset + 1, &endptr, 10); + return endptr - linep; +} + + +static inline int parse_command_float(const char* linep, int offset, int size, float* val) { + char* endptr; + if(offset + 1 == size) { + *val = 0; + return size; + } + *val = strtof(linep + offset + 1, &endptr); + return endptr - linep; + +} + + +static inline void on_error(FLUX::ToolpathProcessor *handler, bool critical, const char* fmt, ...) { + va_list argptr; + va_start(argptr, fmt); + char* buf = (char*)malloc(1024); + int size = vsnprintf(buf, 1024, fmt, argptr); + handler->on_error(critical, buf, size); +} + + +FLUX::GCodeParser::GCodeParser(void) { + position[0] = position[1] = position[2] = 0; + filaments[0] = filaments[1] = filaments[2] = 0; + position_offset[0] = position_offset[1] = position_offset[2] = 0; + filaments_offset[0] = filaments_offset[1] = filaments_offset[2] = 0; + from_inch = false; + absolute = true; + T = 0; +} + + +void FLUX::GCodeParser::set_processor(FLUX::ToolpathProcessor* _handler) { + handler = _handler; +} + + +void FLUX::GCodeParser::parse_from_file(const char* filepth) { + std::ifstream infile(filepth); + std::string linep; + + while (std::getline(infile, linep)) { + parse_command(linep.c_str(), linep.size()); + } +} + + +void FLUX::GCodeParser::parse_command(const char* linep, size_t size) { + int cmd_offset = 0; + if(!move_to_next_char(linep, 0, size, &cmd_offset)) { return; } + + char cmdprefix = linep[cmd_offset]; + int cmdid; + cmd_offset = parse_command_int(linep, cmd_offset, size, &cmdid); + + switch(cmdprefix) { + case 'G': + switch(cmdid) { + case 0: + case 1: + cmd_offset = handle_g0g1(linep, cmd_offset, size); + break; + case 4: + cmd_offset = handle_g4(linep, cmd_offset, size); + break; + case 20: + from_inch = true; + break; + case 21: + from_inch = false; + break; + case 28: + cmd_offset = handle_g28(linep, cmd_offset, size); + break; + case 90: + absolute = true; + break; + case 91: + absolute = false; + break; + case 92: + cmd_offset = handle_g92(linep, cmd_offset, size); + break; + default: + on_error(handler, true, "BAD_COMMAND %.*s", size, linep); + break; + } + break; + case 'M': + switch(cmdid) { + case 17: + cmd_offset = handle_m17(linep, cmd_offset, size); + break; + case 18: + case 84: + cmd_offset = handle_m18m84(linep, cmd_offset, size); + break; + case 24: + case 25: + case 226: + cmd_offset = handle_m24m25m226(linep, cmd_offset, size); + break; + case 104: + cmd_offset = handle_m104m109(linep, cmd_offset, size, false); + break; + case 107: + cmd_offset = handle_m107(linep, cmd_offset, size); + break; + case 109: + cmd_offset = handle_m104m109(linep, cmd_offset, size, true); + break; + case 106: + cmd_offset = handle_m106(linep, cmd_offset, size); + break; + default: + on_error(handler, true, "BAD_COMMAND %.*s", size, linep); + break; + } + break; + case 'T': + if(cmdid >= 0 && cmdid <= 3) { + T = cmdid; + } else { + on_error(handler, true, "BAD_COMMAND %.*s", size, linep); + } + break; + case 'X': + if(cmdid == 2) { + cmd_offset = handle_x2(linep, cmd_offset, size); + } else { + on_error(handler, true, "BAD_COMMAND %.*s", size, linep); + } + break; + case ';': + parse_comment(linep, 0, size); + return; + case '\n': + return; + default: + on_error(handler, true, "BAD_COMMAND %.*s", size, linep); + break; + } + parse_comment(linep, cmd_offset, size); +} + +void FLUX::GCodeParser::parse_comment(const char* linep, size_t offset, size_t size) { + while(offset < size) { + if(linep[offset++] == ';') { + if(linep[size - 1] == '\n') { + handler->append_comment(linep + offset, size - offset - 1); + } else { + handler->append_comment(linep + offset, size - offset); + } + return; + } + } +} + +int FLUX::GCodeParser::handle_g0g1(const char* linep, int offset, int size) { + bool terminated = false; + uint8_t flags = 0; + float val; + + while(offset < size && !terminated) { + if(move_to_next_char(linep, offset, size, &offset)) { + char param = linep[offset]; + switch(param) { + case ';': + case '\n': + terminated = true; + break; + case 'E': + offset = parse_command_float(linep, offset, size, &val); + flags |= FLAG_HAS_E(T); + if(from_inch) { val = inch2mm(val); } + if(absolute) { + filaments[T] = val + filaments_offset[T]; + } else { + filaments[T] += val + filaments_offset[T]; + } + break; + case 'F': + offset = parse_command_float(linep, offset, size, &val); + if(flags & FLAG_HAS_FEEDRATE) { on_error(handler, false, "DULE_F"); } + flags |= FLAG_HAS_FEEDRATE; + feedrate = val; + break; + case 'X': + case 'Y': + case 'Z': + offset = parse_command_float(linep, offset, size, &val); + if(flags & FLAG_HAS_AXIS(param)) { on_error(handler, false, "DULE_%c", param); } + flags |= FLAG_HAS_AXIS(param); + int axis = param - 'X'; + if(from_inch) { val = inch2mm(val); } + if(absolute) { + position[axis] = val + position_offset[axis]; + } else { + position[axis] += val + position_offset[axis]; + } + break; + } + } else { + break; + } + } + + handler->moveto(flags, feedrate, + position[0], position[1], position[2], + filaments[0], filaments[1], filaments[2]); + return offset; +} + + +int FLUX::GCodeParser::handle_g4(const char* linep, int offset, int size) { + if(move_to_next_char(linep, offset, size, &offset)) { + char cmdchar = linep[offset]; + float timelength; + offset = parse_command_float(linep, offset, size, &timelength); + + switch(cmdchar) { + case 'P': + handler->sleep(timelength * 1000); + return offset; + case 'S': + handler->sleep(timelength); + return offset; + } + } + on_error(handler, false, "BAD_COMMAND %.*s", size, linep); + return offset; +} + +int FLUX::GCodeParser::handle_g28(const char* linep, int offset, int size) { + if(move_to_next_char(linep, offset, size, &offset)) { + on_error(handler, false, "G28_PARAM_IGNORED %.*s", size, linep); + } + handler->home(); + return offset; +} + +int FLUX::GCodeParser::handle_g92(const char* linep, int offset, int size) { + bool has_param_error = false; + bool terminated = false; + float val; + int axis; + + while(offset < size && !terminated) { + if(move_to_next_char(linep, offset, size, &offset)) { + char param = linep[offset]; + offset = parse_command_float(linep, offset, size, &val); + switch(param) { + case ';': + case '\n': + terminated = true; + break; + case 'X': + case 'Y': + case 'Z': + if(from_inch) { val = inch2mm(val); } + axis = param - 'X'; + position_offset[axis] = val - position[axis]; + break; + case 'E': + if(from_inch) { val = inch2mm(val); } + axis = T; + filaments_offset[axis] = val - filaments[axis]; + break; + default: + has_param_error = true; + } + } else { + break; + } + } + if(has_param_error) { + on_error(handler, false, "BAD_PARAM %.*s", size, linep); + } + return offset; +} + +int FLUX::GCodeParser::handle_m17(const char* linep, int offset, int size) { + handler->enable_motor(); + return offset; +} + +int FLUX::GCodeParser::handle_m18m84(const char* linep, int offset, int size) { + handler->disable_motor(); + return offset; +} + +int FLUX::GCodeParser::handle_m24m25m226(const char* linep, int offset, int size) { + if(move_to_next_char(linep, offset, size, &offset)) { + char cmdchar = linep[offset]; + int val; + offset = parse_command_int(linep, offset, size, &val); + if(cmdchar == 'Z') { + handler->pause(val != 0); + return offset; + } else { + handler->pause(true); + return offset; + } + } else { + handler->pause(true); + return offset; + } + return offset; +} + +int FLUX::GCodeParser::handle_m104m109(const char* linep, int offset, int size, bool wait) { + if(move_to_next_char(linep, offset, size, &offset)) { + char cmdchar = linep[offset]; + float temperature; + offset = parse_command_float(linep, offset, size, &temperature); + + if(cmdchar == 'S') { + handler->set_toolhead_heater_temperature(temperature, wait); + return offset; + } + } + on_error(handler, false, "BAD_COMMAND %.*s", size, linep); + return offset; +} + +int FLUX::GCodeParser::handle_m106(const char* linep, int offset, int size) { + if(move_to_next_char(linep, offset, size, &offset)) { + char cmdchar = linep[offset]; + float strength; + offset = parse_command_float(linep, offset, size, &strength); + + if(cmdchar == 'S') { + handler->set_toolhead_fan_speed(strength / 255.0); + return offset; + } + } + on_error(handler, false, "BAD_COMMAND %.*s", size, linep); + return offset; +} + + +int FLUX::GCodeParser::handle_m107(const char* linep, int offset, int size) { + handler->set_toolhead_fan_speed(0); + return offset; +} + + +int FLUX::GCodeParser::handle_x2(const char* linep, int offset, int size) { + if(move_to_next_char(linep, offset, size, &offset)) { + char cmdchar = linep[offset]; + float pwm; + + if(cmdchar == 'O') { + offset = parse_command_float(linep, offset, size, &pwm); + handler->set_toolhead_pwm(pwm / 255.0); + } else if(cmdchar == 'F') { + handler->set_toolhead_pwm(0); + } + return offset; + } + on_error(handler, false, "BAD_COMMAND %.*s", size, linep); + return offset; +} + diff --git a/src/toolpath/gcode_writer.cpp b/src/toolpath/gcode_writer.cpp new file mode 100644 index 0000000..90f4fa8 --- /dev/null +++ b/src/toolpath/gcode_writer.cpp @@ -0,0 +1,211 @@ + +#include +#include "gcode.h" + +FLUX::GCodeWriterBase::GCodeWriterBase() { + t = 0; +} + +void FLUX::GCodeWriterBase::moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2) { + int e_count = 0, + new_t = -1, + size; + + for(int i=0;i<3;i++) { + if(flags & FLAG_HAS_E(i)) { + new_t = i; + e_count++; + } + } + if(e_count > 1) { + throw std::runtime_error("CAN_NOT_HANDLE_MULTI_E"); + } else if(e_count == 1) { + if(new_t != t) { + t = new_t; + size = snprintf(buffer, 32, "T%i\n", t); + write(buffer, size); + } + } + + write("G1", 2); + if(flags & FLAG_HAS_FEEDRATE) { + size = snprintf(buffer, 32, " F%.4f", feedrate); + write(buffer, size); + } + if(flags & FLAG_HAS_X) { + size = snprintf(buffer, 32, " X%.4f", x); + write(buffer, size); + } + if(flags & FLAG_HAS_Y) { + size = snprintf(buffer, 32, " Y%.4f", y); + write(buffer, size); + } + if(flags & FLAG_HAS_Z) { + size = snprintf(buffer, 32, " Z%.4f", z); + write(buffer, size); + } + + if(e_count == 1) { + switch(t) { + case 0: + size = snprintf(buffer, 32, " E%.4f", e0); + break; + case 1: + size = snprintf(buffer, 32, " E%.4f", e1); + break; + case 2: + size = snprintf(buffer, 32, " E%.4f", e2); + break; + default: + size = 0; + } + write(buffer, size); + } + + write("\n", 1); +} + +void FLUX::GCodeWriterBase::sleep(float seconds) { + int size; + if(seconds > 1 && (((int)(seconds * 1000) % 1000) < 1)) { + size = snprintf(buffer, 32, "G4 S%i", (int)(seconds)); + write(buffer, size); + } else if(seconds > 0) { + size = snprintf(buffer, 32, "G4 P%i", (int)(seconds * 1000)); + write(buffer, size); + } + + write("\n", 1); +} + +void FLUX::GCodeWriterBase::enable_motor(void) { + write("M17", 3); + write("\n", 1); +} + +void FLUX::GCodeWriterBase::disable_motor(void) { + write("M84", 3); + write("\n", 1); +} + +void FLUX::GCodeWriterBase::pause(bool to_standby_position) { + if(to_standby_position) { + write("M25\n", 5); + } else { + write("M25 Z0\n", 4); + } +} + +void FLUX::GCodeWriterBase::home(void) { + write("G28", 3); + write("\n", 1); +} + +void FLUX::GCodeWriterBase::set_toolhead_heater_temperature(float temperature, bool wait) { + int size; + if(wait) { + size = snprintf(buffer, 32, "M109 S%.1f", temperature); + } else { + size = snprintf(buffer, 32, "M104 S%.1f", temperature); + } + write(buffer, size); + write("\n", 1); +} + +void FLUX::GCodeWriterBase::set_toolhead_fan_speed(float strength) { + if(strength > 0) { + int size; + size = snprintf(buffer, 32, "M106 S%i", (int)(strength * 255)); + write(buffer, size); + write("\n", 1); + } else { + write("M107\n", 5); + } +} + +void FLUX::GCodeWriterBase::set_toolhead_pwm(float strength) { + int size; + size = snprintf(buffer, 32, "X2O%i", (int)(strength * 255)); + write(buffer, size); + write("\n", 1); +} + + +void FLUX::GCodeWriterBase::append_anchor(uint32_t value) { + int size; + size = snprintf(buffer, 32, ";anchor=%i\n", value); + write(buffer, size); + write("\n", 1); +} + +void FLUX::GCodeWriterBase::append_comment(const char* message, size_t length) { + write(";", 1); + write(message, length); + write("\n", 1); +} + +void FLUX::GCodeWriterBase::on_error(bool critical, const char* message, size_t length) { + if(critical) { + write("\n; >>>>>>>>>> ERROR: ", 21); + } else { + write("\n; >>>>>>>>>> WARNING: ", 23); + } + write(message, length); + write("\n", 1); +} + + +// GCodeMemoryWriter +FLUX::GCodeMemoryWriter::GCodeMemoryWriter(void) { + stream = new std::stringstream(); + opened = true; +} + + +FLUX::GCodeMemoryWriter::~GCodeMemoryWriter(void) { + delete stream; +} + + +void FLUX::GCodeMemoryWriter::write(const char* buf, size_t size) { + if(opened) { + stream->write(buf, size); + } +} + + +void FLUX::GCodeMemoryWriter::terminated(void) { + opened = false; +} + + +std::string FLUX::GCodeMemoryWriter::get_buffer(void) { + return stream->str(); +} + +// GCodeFileWriter +FLUX::GCodeFileWriter::GCodeFileWriter(const char* filename) { + stream = new std::ofstream(filename); + if(stream->fail()) { + throw std::runtime_error("OPEN FILE ERROR"); + } +} + + +FLUX::GCodeFileWriter::~GCodeFileWriter(void) { + if(stream->is_open()) { + terminated(); + } + delete stream; +} + +void FLUX::GCodeFileWriter::write(const char* buf, size_t size) { + if(stream->is_open()) { + stream->write(buf, size); + } +} + + +void FLUX::GCodeFileWriter::terminated(void) { + if(stream->is_open()) stream->close(); +} diff --git a/src/toolpath/py_processor.cpp b/src/toolpath/py_processor.cpp new file mode 100644 index 0000000..24c6c93 --- /dev/null +++ b/src/toolpath/py_processor.cpp @@ -0,0 +1,144 @@ + +#include +#include "py_processor.h" + + +FLUX::PythonToolpathProcessor::PythonToolpathProcessor(PyObject *python_callback) { + callback = python_callback; +} + + +void FLUX::PythonToolpathProcessor::moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2) { + PyObject *arglist = Py_BuildValue("(s)", "moveto"); + PyObject *dictlist = Py_BuildValue("{s:i,s:f,s:f,s:f,s:f,s:(fff)}", + "flags", flags, "feedrate", feedrate, + "x", x, "y", y, "z", z, + "e", e0, e1, e2); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::sleep(float milliseconds) { + PyObject *arglist = Py_BuildValue("(s)", "sleep"); + PyObject *dictlist = Py_BuildValue("{s:f}", "milliseconds", milliseconds); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::enable_motor(void) { + PyObject *arglist = Py_BuildValue("(s)", "enable_motor"); + PyObject_CallObject(callback, arglist); + Py_DECREF(arglist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::disable_motor(void) { + PyObject *arglist = Py_BuildValue("(s)", "disable_motor"); + PyObject_CallObject(callback, arglist); + Py_DECREF(arglist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::pause(bool to_standby_position) { + PyObject *arglist = Py_BuildValue("(s)", "pause"); + PyObject *dictlist = Py_BuildValue("{s:b}", "to_standby_position", to_standby_position); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::home(void) { + PyObject *arglist = Py_BuildValue("(s)", "home"); + PyObject_CallObject(callback, arglist); + Py_DECREF(arglist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::set_toolhead_heater_temperature(float temperature, bool wait) { + PyObject *arglist = Py_BuildValue("(s)", "set_toolhead_heater_temperature"); + PyObject *dictlist = Py_BuildValue("{s:f,s:b}", "temperature", temperature, "wait", wait); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::set_toolhead_fan_speed(float strength) { + PyObject *arglist = Py_BuildValue("(s)", "set_toolhead_fan_speed"); + PyObject *dictlist = Py_BuildValue("{s:f}", "strength", strength); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::set_toolhead_pwm(float strength) { + PyObject *arglist = Py_BuildValue("(s)", "set_toolhead_pwm"); + PyObject *dictlist = Py_BuildValue("{s:f}", "strength", strength); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::append_anchor(uint32_t value) { + PyObject *arglist = Py_BuildValue("(s)", "append_anchor"); + PyObject *dictlist = Py_BuildValue("{s:i}", "value", value); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::append_comment(const char* message, size_t length) { + PyObject *arglist = Py_BuildValue("(s)", "append_comment"); + PyObject *dictlist = Py_BuildValue("{s:s#}", "message", message, length); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::on_error(bool critical, const char* message, size_t length) { + PyObject *arglist = Py_BuildValue("(s)", "on_error"); + PyObject *dictlist = Py_BuildValue("{s:b,s:s#}", + "critical", critical, + "message", message, length); + PyObject_Call(callback, arglist, dictlist); + Py_DECREF(arglist); + Py_DECREF(dictlist); + if(PyErr_Occurred()) { + throw std::runtime_error("PYERROR"); + } +} + +void FLUX::PythonToolpathProcessor::terminated(void) { + +} diff --git a/src/toolpath/py_processor.h b/src/toolpath/py_processor.h new file mode 100644 index 0000000..ad01a27 --- /dev/null +++ b/src/toolpath/py_processor.h @@ -0,0 +1,29 @@ + +#include +#include "toolpath.h" + +namespace FLUX { + class PythonToolpathProcessor: FLUX::ToolpathProcessor { + public: + PyObject *callback; + PythonToolpathProcessor(PyObject *python_callback); + + virtual void moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2); + virtual void sleep(float milliseconds); + virtual void enable_motor(void); + virtual void disable_motor(void); + virtual void pause(bool to_standby_position); + virtual void home(void); + virtual void set_toolhead_heater_temperature(float temperature, bool wait); + virtual void set_toolhead_fan_speed(float strength); + virtual void set_toolhead_pwm(float strength); + + virtual void append_anchor(uint32_t value); + virtual void append_comment(const char* message, size_t length); + + virtual void on_error(bool critical, const char* message, size_t length); + + virtual void terminated(void); + }; + +} \ No newline at end of file diff --git a/src/toolpath/toolpath.h b/src/toolpath/toolpath.h new file mode 100644 index 0000000..89fcfe1 --- /dev/null +++ b/src/toolpath/toolpath.h @@ -0,0 +1,37 @@ + +#ifndef _TOOLPATH_H +#define _TOOLPATH_H + +#include + +#define FLAG_HAS_FEEDRATE 64 +#define FLAG_HAS_X 32 +#define FLAG_HAS_Y 16 +#define FLAG_HAS_Z 8 +#define FLAG_HAS_AXIS(A) ( 1 << (5 - A + 'X')) +#define FLAG_HAS_E(T) (1 << (2 - T)) + + +namespace FLUX { + class ToolpathProcessor { + public: + virtual void moveto(int flags, float feedrate, float x, float y, float z, float e0, float e1, float e2) = 0; + virtual void sleep(float seconds) = 0; + virtual void enable_motor(void) = 0; + virtual void disable_motor(void) = 0; + virtual void pause(bool to_standby_position) = 0; + virtual void home(void) = 0; + virtual void set_toolhead_heater_temperature(float temperature, bool wait) = 0; + virtual void set_toolhead_fan_speed(float strength) = 0; + virtual void set_toolhead_pwm(float strength) = 0; + + virtual void append_anchor(uint32_t value) = 0; + virtual void append_comment(const char* message, size_t length) = 0; + + virtual void on_error(bool critical, const char* message, size_t length) = 0; + + virtual void terminated(void) = 0; + }; +} + +#endif diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp deleted file mode 100644 index e026de5..0000000 --- a/src/utils/utils.cpp +++ /dev/null @@ -1,13446 +0,0 @@ -/* Generated by Cython 0.25.2 */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. -#else -#define CYTHON_ABI "0_25_2" -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000) - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK -#endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) - -#ifndef __cplusplus - #error "Cython files generated with the C++ option must be compiled with a C++ compiler." -#endif -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #else - #define CYTHON_INLINE inline - #endif -#endif -template -void __Pyx_call_destructor(T& x) { - x.~T(); -} -template -class __Pyx_FakeReference { - public: - __Pyx_FakeReference() : ptr(NULL) { } - __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } - T *operator->() { return ptr; } - T *operator&() { return ptr; } - operator T&() { return *ptr; } - template bool operator ==(U other) { return *ptr == other; } - template bool operator !=(U other) { return *ptr != other; } - private: - T *ptr; -}; - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - - -#define __PYX_ERR(f_index, lineno, Ln_error) \ -{ \ - __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ -} - -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__fluxclient__utils___utils -#define __PYX_HAVE_API__fluxclient__utils___utils -#include -#include "ios" -#include "new" -#include "stdexcept" -#include "typeinfo" -#include -#include -#include -#include "utils_module.h" -#include "path_vector.h" -#include "g2f_module.h" -#include "../utils/utils_module.h" -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#ifdef PYREX_WITHOUT_ASSERTIONS -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 -#define __PYX_DEFAULT_STRING_ENCODING "" -#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) && defined (_M_X64) - #define __Pyx_sst_abs(value) _abs64(value) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if PY_MAJOR_VERSION < 3 -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ - -static PyObject *__pyx_m; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "ent-dev/src/utils/utils.pyx", - "ent-dev/stringsource", -}; - -/*--- Type declarations ---*/ -struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath; -struct __pyx_obj_10fluxclient_5utils_6_utils_Tools; -struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp; -struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path; - -/* "src/utils/utils.pyx":186 - * self.G92_delta[2] += z - * - * cpdef get_path(self, path_type='js'): # <<<<<<<<<<<<<< - * print("warning: get_path of g2fcpp function deprecated") - * if path_type == 'js': - */ -struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path { - int __pyx_n; - PyObject *path_type; -}; - -/* "src/utils/utils.pyx":40 - * int path_type - * - * cdef class NativePath: # <<<<<<<<<<<<<< - * cdef vector[vector[PathVector]]* ptr - * - */ -struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath { - PyObject_HEAD - struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_NativePath *__pyx_vtab; - std::vector > *ptr; -}; - - -/* "src/utils/utils.pyx":56 - * - * - * cdef class Tools: # <<<<<<<<<<<<<< - * def __init__(self): - * pass - */ -struct __pyx_obj_10fluxclient_5utils_6_utils_Tools { - PyObject_HEAD - struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_Tools *__pyx_vtab; -}; - - -/* "src/utils/utils.pyx":110 - * string path_to_js_cpp(vector[vector[PathVector]]* output) - * - * cdef class GcodeToFcodeCpp: # <<<<<<<<<<<<<< - * cdef FCode* fc - * cdef unsigned long crc - */ -struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp { - PyObject_HEAD - struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_vtab; - FCode *fc; - unsigned long crc; - PyObject *image; - PyObject *md; - char record_path; - PyObject *empty_layer; - PyObject *pause_at_layers; - PyObject *path_js; - PyObject *T; - PyObject *engine; - PyObject *path; - PyObject *G92_delta; - PyObject *config; -}; - - - -/* "src/utils/utils.pyx":40 - * int path_type - * - * cdef class NativePath: # <<<<<<<<<<<<<< - * cdef vector[vector[PathVector]]* ptr - * - */ - -struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_NativePath { - void (*setPtr)(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *, std::vector > *); - std::vector > *(*getPtr)(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *); -}; -static struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_NativePath *__pyx_vtabptr_10fluxclient_5utils_6_utils_NativePath; - - -/* "src/utils/utils.pyx":56 - * - * - * cdef class Tools: # <<<<<<<<<<<<<< - * def __init__(self): - * pass - */ - -struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_Tools { - PyObject *(*path_to_js)(struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *, PyObject *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_Tools *__pyx_vtabptr_10fluxclient_5utils_6_utils_Tools; - - -/* "src/utils/utils.pyx":110 - * string path_to_js_cpp(vector[vector[PathVector]]* output) - * - * cdef class GcodeToFcodeCpp: # <<<<<<<<<<<<<< - * cdef FCode* fc - * cdef unsigned long crc - */ - -struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_GcodeToFcodeCpp { - PyObject *(*extract_vector)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, PyObject *, int __pyx_skip_dispatch); - PyObject *(*sub_convert_path)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, int __pyx_skip_dispatch); - PyObject *(*get_path)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, int __pyx_skip_dispatch, struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path *__pyx_optional_args); - PyObject *(*trim_ends)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, PyObject *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_vtabptr_10fluxclient_5utils_6_utils_GcodeToFcodeCpp; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* KeywordStringCheck.proto */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* SetItemInt.proto */ -#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ - __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) -static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); -static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, - int is_list, int wraparound, int boundscheck); - -/* IncludeStringH.proto */ -#include - -/* BytesEquals.proto */ -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); - -/* UnicodeEquals.proto */ -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); - -/* StrEquals.proto */ -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals -#else -#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals -#endif - -/* IncludeCppStringH.proto */ -#include - -/* decode_c_bytes.proto */ -static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( - const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); - -/* decode_cpp_string.proto */ -static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string( - std::string cppstring, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { - return __Pyx_decode_c_bytes( - cppstring.data(), cppstring.size(), start, stop, encoding, errors, decode_func); -} - -/* StringJoin.proto */ -#if PY_MAJOR_VERSION < 3 -#define __Pyx_PyString_Join __Pyx_PyBytes_Join -#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v)) -#else -#define __Pyx_PyString_Join PyUnicode_Join -#define __Pyx_PyBaseString_Join PyUnicode_Join -#endif -#if CYTHON_COMPILING_IN_CPYTHON - #if PY_MAJOR_VERSION < 3 - #define __Pyx_PyBytes_Join _PyString_Join - #else - #define __Pyx_PyBytes_Join _PyBytes_Join - #endif -#else -static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); -#endif - -/* ListCompAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len)) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) -#endif - -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* FetchCommonType.proto */ -static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); - -/* CythonFunction.proto */ -#define __Pyx_CyFunction_USED 1 -#include -#define __Pyx_CYFUNCTION_STATICMETHOD 0x01 -#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 -#define __Pyx_CYFUNCTION_CCLASS 0x04 -#define __Pyx_CyFunction_GetClosure(f)\ - (((__pyx_CyFunctionObject *) (f))->func_closure) -#define __Pyx_CyFunction_GetClassObj(f)\ - (((__pyx_CyFunctionObject *) (f))->func_classobj) -#define __Pyx_CyFunction_Defaults(type, f)\ - ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) -#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ - ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) -typedef struct { - PyCFunctionObject func; -#if PY_VERSION_HEX < 0x030500A0 - PyObject *func_weakreflist; -#endif - PyObject *func_dict; - PyObject *func_name; - PyObject *func_qualname; - PyObject *func_doc; - PyObject *func_globals; - PyObject *func_code; - PyObject *func_closure; - PyObject *func_classobj; - void *defaults; - int defaults_pyobjects; - int flags; - PyObject *defaults_tuple; - PyObject *defaults_kwdict; - PyObject *(*defaults_getter)(PyObject *); - PyObject *func_annotations; -} __pyx_CyFunctionObject; -static PyTypeObject *__pyx_CyFunctionType = 0; -#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\ - __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code) -static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml, - int flags, PyObject* qualname, - PyObject *self, - PyObject *module, PyObject *globals, - PyObject* code); -static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, - size_t size, - int pyobjects); -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, - PyObject *tuple); -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, - PyObject *dict); -static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, - PyObject *dict); -static int __pyx_CyFunction_init(void); - -/* pyobject_as_double.proto */ -static double __Pyx__PyObject_AsDouble(PyObject* obj); -#if CYTHON_COMPILING_IN_PYPY -#define __Pyx_PyObject_AsDouble(obj)\ -(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\ - likely(PyInt_CheckExact(obj)) ?\ - PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj)) -#else -#define __Pyx_PyObject_AsDouble(obj)\ -((likely(PyFloat_CheckExact(obj))) ?\ - PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj)) -#endif - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, int inplace); -#else -#define __Pyx_PyInt_EqObjC(op1, op2, intval, inplace)\ - PyObject_RichCompare(op1, op2, Py_EQ) - #endif - -/* PyObjectCallMethod1.proto */ -static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); - -/* pop_index.proto */ -static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix); -static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix); -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix); -#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\ - (likely(PyList_CheckExact(L) && __Pyx_fits_Py_ssize_t(ix, type, is_signed))) ?\ - __Pyx__PyList_PopIndex(L, py_ix, ix) : (\ - (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\ - __Pyx__PyObject_PopIndex(L, py_ix))) -#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\ - __Pyx_fits_Py_ssize_t(ix, type, is_signed) ?\ - __Pyx__PyList_PopIndex(L, py_ix, ix) : (\ - (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\ - __Pyx__PyObject_PopIndex(L, py_ix))) -#else -#define __Pyx_PyList_PopIndex(L, py_ix, ix, is_signed, type, to_py_func)\ - __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) -#define __Pyx_PyObject_PopIndex(L, py_ix, ix, is_signed, type, to_py_func) (\ - (unlikely(py_ix == Py_None)) ? __Pyx__PyObject_PopNewIndex(L, to_py_func(ix)) :\ - __Pyx__PyObject_PopIndex(L, py_ix)) -#endif - -/* SliceTupleAndList.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop); -static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop); -#else -#define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop) -#define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop) -#endif - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); -#else -#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) -#endif - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* SetVTable.proto */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* Print.proto */ -static int __Pyx_Print(PyObject*, PyObject *, int); -#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3 -static PyObject* __pyx_print = 0; -static PyObject* __pyx_print_kwargs = 0; -#endif - -static PyObject* __pyx_convert__to_py_PathVector(PathVector s); -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CppExceptionConversion.proto */ -#ifndef __Pyx_CppExn2PyErr -#include -#include -#include -#include -static void __Pyx_CppExn2PyErr() { - try { - if (PyErr_Occurred()) - ; // let the latest Python exn pass through and ignore the current one - else - throw; - } catch (const std::bad_alloc& exn) { - PyErr_SetString(PyExc_MemoryError, exn.what()); - } catch (const std::bad_cast& exn) { - PyErr_SetString(PyExc_TypeError, exn.what()); - } catch (const std::bad_typeid& exn) { - PyErr_SetString(PyExc_TypeError, exn.what()); - } catch (const std::domain_error& exn) { - PyErr_SetString(PyExc_ValueError, exn.what()); - } catch (const std::invalid_argument& exn) { - PyErr_SetString(PyExc_ValueError, exn.what()); - } catch (const std::ios_base::failure& exn) { - PyErr_SetString(PyExc_IOError, exn.what()); - } catch (const std::out_of_range& exn) { - PyErr_SetString(PyExc_IndexError, exn.what()); - } catch (const std::overflow_error& exn) { - PyErr_SetString(PyExc_OverflowError, exn.what()); - } catch (const std::range_error& exn) { - PyErr_SetString(PyExc_ArithmeticError, exn.what()); - } catch (const std::underflow_error& exn) { - PyErr_SetString(PyExc_ArithmeticError, exn.what()); - } catch (const std::exception& exn) { - PyErr_SetString(PyExc_RuntimeError, exn.what()); - } - catch (...) - { - PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); - } -} -#endif - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value); - -/* PrintOne.proto */ -static int __Pyx_PrintOne(PyObject* stream, PyObject *o); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - -static void __pyx_f_10fluxclient_5utils_6_utils_10NativePath_setPtr(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_self, std::vector > *__pyx_v_pt); /* proto*/ -static std::vector > *__pyx_f_10fluxclient_5utils_6_utils_10NativePath_getPtr(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_self); /* proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_5Tools_path_to_js(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_extract_vector(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_sub_convert_path(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path *__pyx_optional_args); /* proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_trim_ends(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_path, int __pyx_skip_dispatch); /* proto*/ - -/* Module declarations from 'cython' */ - -/* Module declarations from 'libcpp.vector' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libcpp.string' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'libc.stdlib' */ - -/* Module declarations from 'libc' */ - -/* Module declarations from 'fluxclient.utils._utils' */ -static PyTypeObject *__pyx_ptype_10fluxclient_5utils_6_utils_NativePath = 0; -static PyTypeObject *__pyx_ptype_10fluxclient_5utils_6_utils_Tools = 0; -static PyTypeObject *__pyx_ptype_10fluxclient_5utils_6_utils_GcodeToFcodeCpp = 0; -static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ -static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ -static std::vector __pyx_convert_vector_from_py_float(PyObject *); /*proto*/ -static std::vector > __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(PyObject *); /*proto*/ -static std::vector > > __pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___(PyObject *); /*proto*/ -static PathVector __pyx_convert__from_py_PathVector(PyObject *); /*proto*/ -static CYTHON_INLINE PyObject *__Pyx_carray_to_py_float(float *, Py_ssize_t); /*proto*/ -static CYTHON_INLINE PyObject *__Pyx_carray_to_tuple_float(float *, Py_ssize_t); /*proto*/ -#define __Pyx_MODULE_NAME "fluxclient.utils._utils" -int __pyx_module_is_main_fluxclient__utils___utils = 0; - -/* Implementation of 'fluxclient.utils._utils' */ -static PyObject *__pyx_builtin_map; -static PyObject *__pyx_builtin_enumerate; -static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_range; -static const char __pyx_k_0[] = "0"; -static const char __pyx_k_1[] = "1"; -static const char __pyx_k_B[] = " 0)) { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_10NativePath___init__(((struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_10NativePath___init__(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__", 0); - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":46 - * pass - * - * cdef void setPtr(self, vector[vector[PathVector]]* pt): # <<<<<<<<<<<<<< - * self.ptr = pt - * - */ - -static void __pyx_f_10fluxclient_5utils_6_utils_10NativePath_setPtr(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_self, std::vector > *__pyx_v_pt) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("setPtr", 0); - - /* "src/utils/utils.pyx":47 - * - * cdef void setPtr(self, vector[vector[PathVector]]* pt): - * self.ptr = pt # <<<<<<<<<<<<<< - * - * cdef vector[vector[PathVector]]* getPtr(self): - */ - __pyx_v_self->ptr = __pyx_v_pt; - - /* "src/utils/utils.pyx":46 - * pass - * - * cdef void setPtr(self, vector[vector[PathVector]]* pt): # <<<<<<<<<<<<<< - * self.ptr = pt - * - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "src/utils/utils.pyx":49 - * self.ptr = pt - * - * cdef vector[vector[PathVector]]* getPtr(self): # <<<<<<<<<<<<<< - * return self.ptr - * - */ - -static std::vector > *__pyx_f_10fluxclient_5utils_6_utils_10NativePath_getPtr(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_self) { - std::vector > *__pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("getPtr", 0); - - /* "src/utils/utils.pyx":50 - * - * cdef vector[vector[PathVector]]* getPtr(self): - * return self.ptr # <<<<<<<<<<<<<< - * - * def __dealloc__(self): - */ - __pyx_r = __pyx_v_self->ptr; - goto __pyx_L0; - - /* "src/utils/utils.pyx":49 - * self.ptr = pt - * - * cdef vector[vector[PathVector]]* getPtr(self): # <<<<<<<<<<<<<< - * return self.ptr - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":52 - * return self.ptr - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * PyMem_Free(self.ptr) - * - */ - -/* Python wrapper */ -static void __pyx_pw_10fluxclient_5utils_6_utils_10NativePath_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pw_10fluxclient_5utils_6_utils_10NativePath_3__dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_pf_10fluxclient_5utils_6_utils_10NativePath_2__dealloc__(((struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_pf_10fluxclient_5utils_6_utils_10NativePath_2__dealloc__(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "src/utils/utils.pyx":53 - * - * def __dealloc__(self): - * PyMem_Free(self.ptr) # <<<<<<<<<<<<<< - * - * - */ - PyMem_Free(__pyx_v_self->ptr); - - /* "src/utils/utils.pyx":52 - * return self.ptr - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * PyMem_Free(self.ptr) - * - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "src/utils/utils.pyx":57 - * - * cdef class Tools: - * def __init__(self): # <<<<<<<<<<<<<< - * pass - * - */ - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_5Tools_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_5Tools_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_5Tools___init__(((struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_5Tools___init__(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__", 0); - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":60 - * pass - * - * cpdef path_to_js(self, path): # <<<<<<<<<<<<<< - * cdef vector[vector[vector [float]]] origin; - * cdef NativePath native = NativePath(); - */ - -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_5Tools_3path_to_js(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_5Tools_path_to_js(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *__pyx_v_self, PyObject *__pyx_v_path, int __pyx_skip_dispatch) { - struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_native = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - int __pyx_t_7; - std::vector > > __pyx_t_8; - __Pyx_RefNannySetupContext("path_to_js", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_path_to_js); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_5Tools_3path_to_js)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_path}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_path}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_path); - __Pyx_GIVEREF(__pyx_v_path); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_path); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "src/utils/utils.pyx":62 - * cpdef path_to_js(self, path): - * cdef vector[vector[vector [float]]] origin; - * cdef NativePath native = NativePath(); # <<<<<<<<<<<<<< - * print("path_type "+str(type(path))); - * if(type(path) is type(native)): - */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10fluxclient_5utils_6_utils_NativePath), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_native = ((struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":63 - * cdef vector[vector[vector [float]]] origin; - * cdef NativePath native = NativePath(); - * print("path_type "+str(type(path))); # <<<<<<<<<<<<<< - * if(type(path) is type(native)): - * native = path - */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_path))); - __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_path))); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(__pyx_v_path))); - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(__pyx_kp_s_path_type, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__Pyx_PrintOne(0, __pyx_t_1) < 0) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":64 - * cdef NativePath native = NativePath(); - * print("path_type "+str(type(path))); - * if(type(path) is type(native)): # <<<<<<<<<<<<<< - * native = path - * return path_to_js_cpp(native.ptr) - */ - __pyx_t_6 = (((PyObject *)Py_TYPE(__pyx_v_path)) == ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_native)))); - __pyx_t_7 = (__pyx_t_6 != 0); - if (__pyx_t_7) { - - /* "src/utils/utils.pyx":65 - * print("path_type "+str(type(path))); - * if(type(path) is type(native)): - * native = path # <<<<<<<<<<<<<< - * return path_to_js_cpp(native.ptr) - * else: - */ - if (!(likely(((__pyx_v_path) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_path, __pyx_ptype_10fluxclient_5utils_6_utils_NativePath))))) __PYX_ERR(0, 65, __pyx_L1_error) - __pyx_t_1 = __pyx_v_path; - __Pyx_INCREF(__pyx_t_1); - __Pyx_DECREF_SET(__pyx_v_native, ((struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *)__pyx_t_1)); - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":66 - * if(type(path) is type(native)): - * native = path - * return path_to_js_cpp(native.ptr) # <<<<<<<<<<<<<< - * else: - * print("path_to_js origin called") - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(path_to_js_cpp(__pyx_v_native->ptr)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "src/utils/utils.pyx":64 - * cdef NativePath native = NativePath(); - * print("path_type "+str(type(path))); - * if(type(path) is type(native)): # <<<<<<<<<<<<<< - * native = path - * return path_to_js_cpp(native.ptr) - */ - } - - /* "src/utils/utils.pyx":68 - * return path_to_js_cpp(native.ptr) - * else: - * print("path_to_js origin called") # <<<<<<<<<<<<<< - * return path_to_js(path) - * - */ - /*else*/ { - if (__Pyx_PrintOne(0, __pyx_kp_s_path_to_js_origin_called) < 0) __PYX_ERR(0, 68, __pyx_L1_error) - - /* "src/utils/utils.pyx":69 - * else: - * print("path_to_js origin called") - * return path_to_js(path) # <<<<<<<<<<<<<< - * - * cdef extern from "g2f_module.h": - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = __pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___(__pyx_v_path); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 69, __pyx_L1_error) - __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(path_to_js(__pyx_t_8)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - } - - /* "src/utils/utils.pyx":60 - * pass - * - * cpdef path_to_js(self, path): # <<<<<<<<<<<<<< - * cdef vector[vector[vector [float]]] origin; - * cdef NativePath native = NativePath(); - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("fluxclient.utils._utils.Tools.path_to_js", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_native); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_5Tools_3path_to_js(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_5Tools_3path_to_js(PyObject *__pyx_v_self, PyObject *__pyx_v_path) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("path_to_js (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_5Tools_2path_to_js(((struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *)__pyx_v_self), ((PyObject *)__pyx_v_path)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_5Tools_2path_to_js(struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *__pyx_v_self, PyObject *__pyx_v_path) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("path_to_js", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_10fluxclient_5utils_6_utils_5Tools_path_to_js(__pyx_v_self, __pyx_v_path, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("fluxclient.utils._utils.Tools.path_to_js", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":130 - * analyze metadata - * """ - * def __init__(self, version=1, head_type="EXTRUDER", ext_metadata={}): # <<<<<<<<<<<<<< - * self.T = None - * - */ - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - CYTHON_UNUSED PyObject *__pyx_v_version = 0; - PyObject *__pyx_v_head_type = 0; - PyObject *__pyx_v_ext_metadata = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_version,&__pyx_n_s_head_type,&__pyx_n_s_ext_metadata,0}; - PyObject* values[3] = {0,0,0}; - values[0] = ((PyObject *)__pyx_int_1); - values[1] = ((PyObject *)__pyx_n_s_EXTRUDER); - values[2] = __pyx_k_; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_version); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_head_type); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ext_metadata); - if (value) { values[2] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 130, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_version = values[0]; - __pyx_v_head_type = values[1]; - __pyx_v_ext_metadata = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 130, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp___init__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), __pyx_v_version, __pyx_v_head_type, __pyx_v_ext_metadata); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp___init__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_version, PyObject *__pyx_v_head_type, PyObject *__pyx_v_ext_metadata) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - __Pyx_RefNannySetupContext("__init__", 0); - - /* "src/utils/utils.pyx":131 - * """ - * def __init__(self, version=1, head_type="EXTRUDER", ext_metadata={}): - * self.T = None # <<<<<<<<<<<<<< - * - * #super(GcodeToFcode, self).__init__() - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->T); - __Pyx_DECREF(__pyx_v_self->T); - __pyx_v_self->T = Py_None; - - /* "src/utils/utils.pyx":134 - * - * #super(GcodeToFcode, self).__init__() - * self.crc = 0 # computing crc32, use for generating fcode # <<<<<<<<<<<<<< - * self.image = None # png image that will store in fcode as perview image, should be a bytes obj - * - */ - __pyx_v_self->crc = 0; - - /* "src/utils/utils.pyx":135 - * #super(GcodeToFcode, self).__init__() - * self.crc = 0 # computing crc32, use for generating fcode - * self.image = None # png image that will store in fcode as perview image, should be a bytes obj # <<<<<<<<<<<<<< - * - * self.path = [[[0,0,0,0]]] - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->image); - __Pyx_DECREF(__pyx_v_self->image); - __pyx_v_self->image = Py_None; - - /* "src/utils/utils.pyx":137 - * self.image = None # png image that will store in fcode as perview image, should be a bytes obj - * - * self.path = [[[0,0,0,0]]] # <<<<<<<<<<<<<< - * - * self.G92_delta = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # X, Y, Z, E1, E2, E3 -> recording the G92 delta for each axis - */ - __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_0); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_0); - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); - __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->path); - __Pyx_DECREF(__pyx_v_self->path); - __pyx_v_self->path = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":139 - * self.path = [[[0,0,0,0]]] - * - * self.G92_delta = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # X, Y, Z, E1, E2, E3 -> recording the G92 delta for each axis # <<<<<<<<<<<<<< - * - * self.md = {'HEAD_TYPE': head_type, 'TIME_COST': 0, 'FILAMENT_USED': '0,0,0', 'MAX_R': 0} # basic metadata, use extruder as default - */ - __pyx_t_1 = PyList_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_float_0_0); - __Pyx_GIVEREF(__pyx_float_0_0); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_float_0_0); - __Pyx_INCREF(__pyx_float_0_0); - __Pyx_GIVEREF(__pyx_float_0_0); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_float_0_0); - __Pyx_INCREF(__pyx_float_0_0); - __Pyx_GIVEREF(__pyx_float_0_0); - PyList_SET_ITEM(__pyx_t_1, 2, __pyx_float_0_0); - __Pyx_INCREF(__pyx_float_0_0); - __Pyx_GIVEREF(__pyx_float_0_0); - PyList_SET_ITEM(__pyx_t_1, 3, __pyx_float_0_0); - __Pyx_INCREF(__pyx_float_0_0); - __Pyx_GIVEREF(__pyx_float_0_0); - PyList_SET_ITEM(__pyx_t_1, 4, __pyx_float_0_0); - __Pyx_INCREF(__pyx_float_0_0); - __Pyx_GIVEREF(__pyx_float_0_0); - PyList_SET_ITEM(__pyx_t_1, 5, __pyx_float_0_0); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->G92_delta); - __Pyx_DECREF(__pyx_v_self->G92_delta); - __pyx_v_self->G92_delta = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":141 - * self.G92_delta = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] # X, Y, Z, E1, E2, E3 -> recording the G92 delta for each axis - * - * self.md = {'HEAD_TYPE': head_type, 'TIME_COST': 0, 'FILAMENT_USED': '0,0,0', 'MAX_R': 0} # basic metadata, use extruder as default # <<<<<<<<<<<<<< - * - * self.md.update(ext_metadata) - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_HEAD_TYPE, __pyx_v_head_type) < 0) __PYX_ERR(0, 141, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_TIME_COST, __pyx_int_0) < 0) __PYX_ERR(0, 141, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_FILAMENT_USED, __pyx_kp_s_0_0_0) < 0) __PYX_ERR(0, 141, __pyx_L1_error) - if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_MAX_R, __pyx_int_0) < 0) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->md); - __Pyx_DECREF(__pyx_v_self->md); - __pyx_v_self->md = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":143 - * self.md = {'HEAD_TYPE': head_type, 'TIME_COST': 0, 'FILAMENT_USED': '0,0,0', 'MAX_R': 0} # basic metadata, use extruder as default - * - * self.md.update(ext_metadata) # <<<<<<<<<<<<<< - * - * self.record_path = True # to speed up, set this flag to False - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->md, __pyx_n_s_update); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_ext_metadata); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_ext_metadata}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_ext_metadata}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(__pyx_v_ext_metadata); - __Pyx_GIVEREF(__pyx_v_ext_metadata); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_ext_metadata); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":145 - * self.md.update(ext_metadata) - * - * self.record_path = True # to speed up, set this flag to False # <<<<<<<<<<<<<< - * self.config = None # config dict(given from fluxstudio) - * - */ - __pyx_v_self->record_path = 1; - - /* "src/utils/utils.pyx":146 - * - * self.record_path = True # to speed up, set this flag to False - * self.config = None # config dict(given from fluxstudio) # <<<<<<<<<<<<<< - * - * self.pause_at_layers = [] - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->config); - __Pyx_DECREF(__pyx_v_self->config); - __pyx_v_self->config = Py_None; - - /* "src/utils/utils.pyx":148 - * self.config = None # config dict(given from fluxstudio) - * - * self.pause_at_layers = [] # <<<<<<<<<<<<<< - * self.empty_layer = [] - * - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->pause_at_layers); - __Pyx_DECREF(__pyx_v_self->pause_at_layers); - __pyx_v_self->pause_at_layers = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":149 - * - * self.pause_at_layers = [] - * self.empty_layer = [] # <<<<<<<<<<<<<< - * - * self.empty_layer = [] - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->empty_layer); - __Pyx_DECREF(__pyx_v_self->empty_layer); - __pyx_v_self->empty_layer = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":151 - * self.empty_layer = [] - * - * self.empty_layer = [] # <<<<<<<<<<<<<< - * self.path_js = None - * - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->empty_layer); - __Pyx_DECREF(__pyx_v_self->empty_layer); - __pyx_v_self->empty_layer = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":152 - * - * self.empty_layer = [] - * self.path_js = None # <<<<<<<<<<<<<< - * - * def get_metadata(self): - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->path_js); - __Pyx_DECREF(__pyx_v_self->path_js); - __pyx_v_self->path_js = Py_None; - - /* "src/utils/utils.pyx":130 - * analyze metadata - * """ - * def __init__(self, version=1, head_type="EXTRUDER", ext_metadata={}): # <<<<<<<<<<<<<< - * self.T = None - * - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":154 - * self.path_js = None - * - * def get_metadata(self): # <<<<<<<<<<<<<< - * """ - * Gets the metadata - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_3get_metadata(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2get_metadata[] = "\n Gets the metadata\n "; -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_3get_metadata(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_metadata (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2get_metadata(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2get_metadata(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_metadata", 0); - - /* "src/utils/utils.pyx":158 - * Gets the metadata - * """ - * return self.md # <<<<<<<<<<<<<< - * - * def get_img(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->md); - __pyx_r = __pyx_v_self->md; - goto __pyx_L0; - - /* "src/utils/utils.pyx":154 - * self.path_js = None - * - * def get_metadata(self): # <<<<<<<<<<<<<< - * """ - * Gets the metadata - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":160 - * return self.md - * - * def get_img(self): # <<<<<<<<<<<<<< - * """ - * Gets the preview image - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5get_img(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4get_img[] = "\n Gets the preview image\n "; -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5get_img(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_img (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4get_img(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4get_img(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_img", 0); - - /* "src/utils/utils.pyx":164 - * Gets the preview image - * """ - * return self.image # <<<<<<<<<<<<<< - * - * def header(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->image); - __pyx_r = __pyx_v_self->image; - goto __pyx_L0; - - /* "src/utils/utils.pyx":160 - * return self.md - * - * def get_img(self): # <<<<<<<<<<<<<< - * """ - * Gets the preview image - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":166 - * return self.image - * - * def header(self): # <<<<<<<<<<<<<< - * """ - * Returns header for fcode version 1 - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_7header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6header[] = "\n Returns header for fcode version 1\n "; -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_7header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("header (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6header(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6header(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("header", 0); - - /* "src/utils/utils.pyx":170 - * Returns header for fcode version 1 - * """ - * return b'FC' + b'x0001' + b'\n' # <<<<<<<<<<<<<< - * - * cpdef extract_vector(self, obj): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_n_b_FCx0001); - __pyx_r = __pyx_n_b_FCx0001; - goto __pyx_L0; - - /* "src/utils/utils.pyx":166 - * return self.image - * - * def header(self): # <<<<<<<<<<<<<< - * """ - * Returns header for fcode version 1 - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":172 - * return b'FC' + b'x0001' + b'\n' - * - * cpdef extract_vector(self, obj): # <<<<<<<<<<<<<< - * cdef PathVector v = obj - * print("{" + str(v.x) + "," + str(v.y) + "}") - */ - -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9extract_vector(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_extract_vector(CYTHON_UNUSED struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_skip_dispatch) { - PathVector __pyx_v_v; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PathVector __pyx_t_6; - __Pyx_RefNannySetupContext("extract_vector", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_extract_vector); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9extract_vector)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_obj}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_obj}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_obj); - __Pyx_GIVEREF(__pyx_v_obj); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_obj); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "src/utils/utils.pyx":173 - * - * cpdef extract_vector(self, obj): - * cdef PathVector v = obj # <<<<<<<<<<<<<< - * print("{" + str(v.x) + "," + str(v.y) + "}") - * - */ - __pyx_t_6 = __pyx_convert__from_py_PathVector(__pyx_v_obj); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L1_error) - __pyx_v_v = __pyx_t_6; - - /* "src/utils/utils.pyx":174 - * cpdef extract_vector(self, obj): - * cdef PathVector v = obj - * print("{" + str(v.x) + "," + str(v.y) + "}") # <<<<<<<<<<<<<< - * - * cpdef sub_convert_path(self): - */ - __pyx_t_1 = __pyx_convert__to_py_PathVector(__pyx_v_v); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(__pyx_kp_s__2, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_kp_s__3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __pyx_convert__to_py_PathVector(__pyx_v_v); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_y); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_kp_s__4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__Pyx_PrintOne(0, __pyx_t_3) < 0) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "src/utils/utils.pyx":172 - * return b'FC' + b'x0001' + b'\n' - * - * cpdef extract_vector(self, obj): # <<<<<<<<<<<<<< - * cdef PathVector v = obj - * print("{" + str(v.x) + "," + str(v.y) + "}") - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.extract_vector", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9extract_vector(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9extract_vector(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("extract_vector (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_8extract_vector(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_obj)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_8extract_vector(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_obj) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("extract_vector", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_extract_vector(__pyx_v_self, __pyx_v_obj, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.extract_vector", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":176 - * print("{" + str(v.x) + "," + str(v.y) + "}") - * - * cpdef sub_convert_path(self): # <<<<<<<<<<<<<< - * # self.path_js = FcodeBase.path_to_js(self.path) - * cdef FCode* fc = self.fc - */ - -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11sub_convert_path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_sub_convert_path(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, int __pyx_skip_dispatch) { - CYTHON_UNUSED FCode *__pyx_v_fc; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - FCode *__pyx_t_5; - __Pyx_RefNannySetupContext("sub_convert_path", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sub_convert_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11sub_convert_path)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "src/utils/utils.pyx":178 - * cpdef sub_convert_path(self): - * # self.path_js = FcodeBase.path_to_js(self.path) - * cdef FCode* fc = self.fc # <<<<<<<<<<<<<< - * #self.path_js = path_to_js_cpp(fc.native_path).decode() - * - */ - __pyx_t_5 = __pyx_v_self->fc; - __pyx_v_fc = __pyx_t_5; - - /* "src/utils/utils.pyx":176 - * print("{" + str(v.x) + "," + str(v.y) + "}") - * - * cpdef sub_convert_path(self): # <<<<<<<<<<<<<< - * # self.path_js = FcodeBase.path_to_js(self.path) - * cdef FCode* fc = self.fc - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.sub_convert_path", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11sub_convert_path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11sub_convert_path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sub_convert_path (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_10sub_convert_path(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_10sub_convert_path(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("sub_convert_path", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_sub_convert_path(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.sub_convert_path", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":181 - * #self.path_js = path_to_js_cpp(fc.native_path).decode() - * - * def offset(self, x=0.0, y=0.0, z=0.0): # <<<<<<<<<<<<<< - * self.G92_delta[0] += x - * self.G92_delta[1] += y - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_13offset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_13offset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_x = 0; - PyObject *__pyx_v_y = 0; - PyObject *__pyx_v_z = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("offset (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_z,0}; - PyObject* values[3] = {0,0,0}; - values[0] = ((PyObject *)__pyx_float_0_0); - values[1] = ((PyObject *)__pyx_float_0_0); - values[2] = ((PyObject *)__pyx_float_0_0); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_z); - if (value) { values[2] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "offset") < 0)) __PYX_ERR(0, 181, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_x = values[0]; - __pyx_v_y = values[1]; - __pyx_v_z = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("offset", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.offset", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_12offset(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_z); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_12offset(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_z) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - __Pyx_RefNannySetupContext("offset", 0); - - /* "src/utils/utils.pyx":182 - * - * def offset(self, x=0.0, y=0.0, z=0.0): - * self.G92_delta[0] += x # <<<<<<<<<<<<<< - * self.G92_delta[1] += y - * self.G92_delta[2] += z - */ - __Pyx_INCREF(__pyx_v_self->G92_delta); - __pyx_t_1 = __pyx_v_self->G92_delta; - __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, __pyx_t_2, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_x); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(__Pyx_SetItemInt(__pyx_t_1, __pyx_t_2, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":183 - * def offset(self, x=0.0, y=0.0, z=0.0): - * self.G92_delta[0] += x - * self.G92_delta[1] += y # <<<<<<<<<<<<<< - * self.G92_delta[2] += z - * - */ - __Pyx_INCREF(__pyx_v_self->G92_delta); - __pyx_t_1 = __pyx_v_self->G92_delta; - __pyx_t_2 = 1; - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_t_2, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_v_y); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(__Pyx_SetItemInt(__pyx_t_1, __pyx_t_2, __pyx_t_3, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":184 - * self.G92_delta[0] += x - * self.G92_delta[1] += y - * self.G92_delta[2] += z # <<<<<<<<<<<<<< - * - * cpdef get_path(self, path_type='js'): - */ - __Pyx_INCREF(__pyx_v_self->G92_delta); - __pyx_t_1 = __pyx_v_self->G92_delta; - __pyx_t_2 = 2; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, __pyx_t_2, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_z); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(__Pyx_SetItemInt(__pyx_t_1, __pyx_t_2, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":181 - * #self.path_js = path_to_js_cpp(fc.native_path).decode() - * - * def offset(self, x=0.0, y=0.0, z=0.0): # <<<<<<<<<<<<<< - * self.G92_delta[0] += x - * self.G92_delta[1] += y - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.offset", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":186 - * self.G92_delta[2] += z - * - * cpdef get_path(self, path_type='js'): # <<<<<<<<<<<<<< - * print("warning: get_path of g2fcpp function deprecated") - * if path_type == 'js': - */ - -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15get_path(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path *__pyx_optional_args) { - PyObject *__pyx_v_path_type = ((PyObject *)__pyx_n_s_js); - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - int __pyx_t_7; - __Pyx_RefNannySetupContext("get_path", 0); - if (__pyx_optional_args) { - if (__pyx_optional_args->__pyx_n > 0) { - __pyx_v_path_type = __pyx_optional_args->path_type; - } - } - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_get_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15get_path)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_path_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_path_type}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_path_type}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_path_type); - __Pyx_GIVEREF(__pyx_v_path_type); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_path_type); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "src/utils/utils.pyx":187 - * - * cpdef get_path(self, path_type='js'): - * print("warning: get_path of g2fcpp function deprecated") # <<<<<<<<<<<<<< - * if path_type == 'js': - * self.T.join() - */ - if (__Pyx_PrintOne(0, __pyx_kp_s_warning_get_path_of_g2fcpp_funct) < 0) __PYX_ERR(0, 187, __pyx_L1_error) - - /* "src/utils/utils.pyx":188 - * cpdef get_path(self, path_type='js'): - * print("warning: get_path of g2fcpp function deprecated") - * if path_type == 'js': # <<<<<<<<<<<<<< - * self.T.join() - * if self.path_js is None: - */ - __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_v_path_type, __pyx_n_s_js, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 188, __pyx_L1_error) - if (__pyx_t_6) { - - /* "src/utils/utils.pyx":189 - * print("warning: get_path of g2fcpp function deprecated") - * if path_type == 'js': - * self.T.join() # <<<<<<<<<<<<<< - * if self.path_js is None: - * self.path_js = path_to_js_cpp(self.fc.native_path).decode() - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->T, __pyx_n_s_join); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":190 - * if path_type == 'js': - * self.T.join() - * if self.path_js is None: # <<<<<<<<<<<<<< - * self.path_js = path_to_js_cpp(self.fc.native_path).decode() - * return self.path_js - */ - __pyx_t_6 = (__pyx_v_self->path_js == Py_None); - __pyx_t_7 = (__pyx_t_6 != 0); - if (__pyx_t_7) { - - /* "src/utils/utils.pyx":191 - * self.T.join() - * if self.path_js is None: - * self.path_js = path_to_js_cpp(self.fc.native_path).decode() # <<<<<<<<<<<<<< - * return self.path_js - * else: - */ - __pyx_t_1 = __Pyx_decode_cpp_string(path_to_js_cpp(__pyx_v_self->fc->native_path), 0, PY_SSIZE_T_MAX, NULL, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->path_js); - __Pyx_DECREF(__pyx_v_self->path_js); - __pyx_v_self->path_js = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":190 - * if path_type == 'js': - * self.T.join() - * if self.path_js is None: # <<<<<<<<<<<<<< - * self.path_js = path_to_js_cpp(self.fc.native_path).decode() - * return self.path_js - */ - } - - /* "src/utils/utils.pyx":192 - * if self.path_js is None: - * self.path_js = path_to_js_cpp(self.fc.native_path).decode() - * return self.path_js # <<<<<<<<<<<<<< - * else: - * if self.path: - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->path_js); - __pyx_r = __pyx_v_self->path_js; - goto __pyx_L0; - - /* "src/utils/utils.pyx":188 - * cpdef get_path(self, path_type='js'): - * print("warning: get_path of g2fcpp function deprecated") - * if path_type == 'js': # <<<<<<<<<<<<<< - * self.T.join() - * if self.path_js is None: - */ - } - - /* "src/utils/utils.pyx":194 - * return self.path_js - * else: - * if self.path: # <<<<<<<<<<<<<< - * return self.path - * else: - */ - /*else*/ { - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_self->path); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 194, __pyx_L1_error) - if (__pyx_t_7) { - - /* "src/utils/utils.pyx":195 - * else: - * if self.path: - * return self.path # <<<<<<<<<<<<<< - * else: - * return None - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->path); - __pyx_r = __pyx_v_self->path; - goto __pyx_L0; - - /* "src/utils/utils.pyx":194 - * return self.path_js - * else: - * if self.path: # <<<<<<<<<<<<<< - * return self.path - * else: - */ - } - - /* "src/utils/utils.pyx":197 - * return self.path - * else: - * return None # <<<<<<<<<<<<<< - * - * cpdef trim_ends(self, path): - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; - } - } - - /* "src/utils/utils.pyx":186 - * self.G92_delta[2] += z - * - * cpdef get_path(self, path_type='js'): # <<<<<<<<<<<<<< - * print("warning: get_path of g2fcpp function deprecated") - * if path_type == 'js': - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.get_path", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15get_path(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15get_path(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_path_type = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_path (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path_type_2,0}; - PyObject* values[1] = {0}; - values[0] = ((PyObject *)__pyx_n_s_js); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path_type_2); - if (value) { values[0] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_path") < 0)) __PYX_ERR(0, 186, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_path_type = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_path", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 186, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.get_path", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_14get_path(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), __pyx_v_path_type); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_14get_path(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_path_type) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path __pyx_t_2; - __Pyx_RefNannySetupContext("get_path", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_2.__pyx_n = 1; - __pyx_t_2.path_type = __pyx_v_path_type; - __pyx_t_1 = __pyx_vtabptr_10fluxclient_5utils_6_utils_GcodeToFcodeCpp->get_path(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.get_path", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":199 - * return None - * - * cpdef trim_ends(self, path): # <<<<<<<<<<<<<< - * """ - * trim the moving(non-extruding) part in path's both end - */ - -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_17trim_ends(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ -static PyObject *__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_trim_ends(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_path, int __pyx_skip_dispatch) { - struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *__pyx_v_np = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - std::vector > *__pyx_t_6; - __Pyx_RefNannySetupContext("trim_ends", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_trim_ends); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_17trim_ends)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_path}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_path}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_path); - __Pyx_GIVEREF(__pyx_v_path); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_path); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "src/utils/utils.pyx":203 - * trim the moving(non-extruding) part in path's both end - * """ - * cdef NativePath np = NativePath(); # <<<<<<<<<<<<<< - * trim_ends_cpp(self.fc.native_path) - * np.ptr = self.fc.native_path - */ - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_10fluxclient_5utils_6_utils_NativePath), __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_np = ((struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":204 - * """ - * cdef NativePath np = NativePath(); - * trim_ends_cpp(self.fc.native_path) # <<<<<<<<<<<<<< - * np.ptr = self.fc.native_path - * return np - */ - trim_ends_cpp(__pyx_v_self->fc->native_path); - - /* "src/utils/utils.pyx":205 - * cdef NativePath np = NativePath(); - * trim_ends_cpp(self.fc.native_path) - * np.ptr = self.fc.native_path # <<<<<<<<<<<<<< - * return np - * - */ - __pyx_t_6 = __pyx_v_self->fc->native_path; - __pyx_v_np->ptr = __pyx_t_6; - - /* "src/utils/utils.pyx":206 - * trim_ends_cpp(self.fc.native_path) - * np.ptr = self.fc.native_path - * return np # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_np)); - __pyx_r = ((PyObject *)__pyx_v_np); - goto __pyx_L0; - - /* "src/utils/utils.pyx":199 - * return None - * - * cpdef trim_ends(self, path): # <<<<<<<<<<<<<< - * """ - * trim the moving(non-extruding) part in path's both end - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.trim_ends", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_np); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_17trim_ends(PyObject *__pyx_v_self, PyObject *__pyx_v_path); /*proto*/ -static char __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_16trim_ends[] = "\n trim the moving(non-extruding) part in path's both end\n "; -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_17trim_ends(PyObject *__pyx_v_self, PyObject *__pyx_v_path) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("trim_ends (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_16trim_ends(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_path)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_16trim_ends(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_path) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("trim_ends", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_trim_ends(__pyx_v_self, __pyx_v_path, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.trim_ends", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":209 - * - * - * def write_metadata(self, stream, md): # <<<<<<<<<<<<<< - * """ - * Writes fcode's metadata - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_19write_metadata(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_18write_metadata[] = "\n Writes fcode's metadata\n including a dict, and a png image\n "; -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_19write_metadata(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_stream = 0; - PyObject *__pyx_v_md = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("write_metadata (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stream,&__pyx_n_s_md,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stream)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_md)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("write_metadata", 1, 2, 2, 1); __PYX_ERR(0, 209, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_metadata") < 0)) __PYX_ERR(0, 209, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_stream = values[0]; - __pyx_v_md = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("write_metadata", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 209, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.write_metadata", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_18write_metadata(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), __pyx_v_stream, __pyx_v_md); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_18write_metadata(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_stream, PyObject *__pyx_v_md) { - PyObject *__pyx_v_md_join = NULL; - PyObject *__pyx_v_i = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - Py_ssize_t __pyx_t_4; - PyObject *(*__pyx_t_5)(PyObject *); - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - int __pyx_t_12; - int __pyx_t_13; - __Pyx_RefNannySetupContext("write_metadata", 0); - - /* "src/utils/utils.pyx":214 - * including a dict, and a png image - * """ - * md_join = '\x00'.join([i + '=' + md[i] for i in md]).encode() # <<<<<<<<<<<<<< - * - * stream.write(struct.pack('tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_5)) { - if (likely(PyList_CheckExact(__pyx_t_3))) { - if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 214, __pyx_L1_error) - #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - #endif - } else { - if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 214, __pyx_L1_error) - #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - #endif - } - } else { - __pyx_t_6 = __pyx_t_5(__pyx_t_3); - if (unlikely(!__pyx_t_6)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 214, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_6); - } - __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_v_i, __pyx_kp_s__6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyObject_GetItem(__pyx_v_md, __pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyString_Join(__pyx_kp_s__5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_md_join = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":216 - * md_join = '\x00'.join([i + '=' + md[i] for i in md]).encode() - * - * stream.write(struct.pack('image == Py_None); - __pyx_t_13 = (__pyx_t_12 != 0); - if (__pyx_t_13) { - - /* "src/utils/utils.pyx":221 - * - * if self.image is None: - * stream.write(struct.pack('image; - __Pyx_INCREF(__pyx_t_11); - __pyx_t_4 = PyObject_Length(__pyx_t_11); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_10 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_I, __pyx_t_11}; - __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_kp_s_I, __pyx_t_11}; - __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_10) { - __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_11); - __pyx_t_11 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_7}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_7}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":224 - * else: - * stream.write(struct.pack('image); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->image}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_v_self->image}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_INCREF(__pyx_v_self->image); - __Pyx_GIVEREF(__pyx_v_self->image); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->image); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __pyx_L5:; - - /* "src/utils/utils.pyx":209 - * - * - * def write_metadata(self, stream, md): # <<<<<<<<<<<<<< - * """ - * Writes fcode's metadata - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.write_metadata", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_md_join); - __Pyx_XDECREF(__pyx_v_i); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":226 - * stream.write(self.image) - * - * def process(self, input_stream, output_stream): # <<<<<<<<<<<<<< - * """ - * Process a input_stream consist of gcode strings and write the fcode into output_stream - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_21process(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_20process[] = "\n Process a input_stream consist of gcode strings and write the fcode into output_stream\n "; -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_21process(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_input_stream = 0; - PyObject *__pyx_v_output_stream = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("process (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input_stream,&__pyx_n_s_output_stream,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_input_stream)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_output_stream)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process", 1, 2, 2, 1); __PYX_ERR(0, 226, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process") < 0)) __PYX_ERR(0, 226, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_input_stream = values[0]; - __pyx_v_output_stream = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("process", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 226, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.process", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_20process(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), __pyx_v_input_stream, __pyx_v_output_stream); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":230 - * Process a input_stream consist of gcode strings and write the fcode into output_stream - * """ - * packer = lambda x: struct.pack('fc = __pyx_v_fc; - - /* "src/utils/utils.pyx":240 - * self.fc = fc - * - * if self.config is not None: # <<<<<<<<<<<<<< - * if self.engine == 'cura': - * self.offset(z=float(self.config.get('z_offset', '0'))) - */ - __pyx_t_2 = (__pyx_v_self->config != Py_None); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "src/utils/utils.pyx":241 - * - * if self.config is not None: - * if self.engine == 'cura': # <<<<<<<<<<<<<< - * self.offset(z=float(self.config.get('z_offset', '0'))) - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): - */ - __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_v_self->engine, __pyx_n_s_cura, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 241, __pyx_L1_error) - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "src/utils/utils.pyx":242 - * if self.config is not None: - * if self.engine == 'cura': - * self.offset(z=float(self.config.get('z_offset', '0'))) # <<<<<<<<<<<<<< - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): - * if auto_pause_layer.isdigit(): - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->config, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyNumber_Float(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_z, __pyx_t_5) < 0) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "src/utils/utils.pyx":241 - * - * if self.config is not None: - * if self.engine == 'cura': # <<<<<<<<<<<<<< - * self.offset(z=float(self.config.get('z_offset', '0'))) - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): - */ - } - - /* "src/utils/utils.pyx":243 - * if self.engine == 'cura': - * self.offset(z=float(self.config.get('z_offset', '0'))) - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): # <<<<<<<<<<<<<< - * if auto_pause_layer.isdigit(): - * fc.pause_at_layers.push_back(int(auto_pause_layer)) - */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->config, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { - __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0; - __pyx_t_8 = NULL; - } else { - __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 243, __pyx_L1_error) - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - for (;;) { - if (likely(!__pyx_t_8)) { - if (likely(PyList_CheckExact(__pyx_t_5))) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 243, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 243, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 243, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_8(__pyx_t_5); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 243, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF_SET(__pyx_v_auto_pause_layer, __pyx_t_4); - __pyx_t_4 = 0; - - /* "src/utils/utils.pyx":244 - * self.offset(z=float(self.config.get('z_offset', '0'))) - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): - * if auto_pause_layer.isdigit(): # <<<<<<<<<<<<<< - * fc.pause_at_layers.push_back(int(auto_pause_layer)) - * fc.printing_temperature = float(self.config.get('temperature', '0')) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_auto_pause_layer, __pyx_n_s_isdigit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (__pyx_t_6) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else { - __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 244, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_2) { - - /* "src/utils/utils.pyx":245 - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): - * if auto_pause_layer.isdigit(): - * fc.pause_at_layers.push_back(int(auto_pause_layer)) # <<<<<<<<<<<<<< - * fc.printing_temperature = float(self.config.get('temperature', '0')) - * logger.info("[G2FCPP] FCode Printing Temperature = " + str(fc.printing_temperature)) - */ - __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_auto_pause_layer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 245, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - try { - __pyx_v_fc->pause_at_layers->push_back(__pyx_t_9); - } catch(...) { - __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 245, __pyx_L1_error) - } - - /* "src/utils/utils.pyx":244 - * self.offset(z=float(self.config.get('z_offset', '0'))) - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): - * if auto_pause_layer.isdigit(): # <<<<<<<<<<<<<< - * fc.pause_at_layers.push_back(int(auto_pause_layer)) - * fc.printing_temperature = float(self.config.get('temperature', '0')) - */ - } - - /* "src/utils/utils.pyx":243 - * if self.engine == 'cura': - * self.offset(z=float(self.config.get('z_offset', '0'))) - * for auto_pause_layer in self.config.get('pause_at_layers', '').split(','): # <<<<<<<<<<<<<< - * if auto_pause_layer.isdigit(): - * fc.pause_at_layers.push_back(int(auto_pause_layer)) - */ - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - - /* "src/utils/utils.pyx":246 - * if auto_pause_layer.isdigit(): - * fc.pause_at_layers.push_back(int(auto_pause_layer)) - * fc.printing_temperature = float(self.config.get('temperature', '0')) # <<<<<<<<<<<<<< - * logger.info("[G2FCPP] FCode Printing Temperature = " + str(fc.printing_temperature)) - * - */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->config, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__pyx_t_10 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_fc->printing_temperature = __pyx_t_10; - - /* "src/utils/utils.pyx":247 - * fc.pause_at_layers.push_back(int(auto_pause_layer)) - * fc.printing_temperature = float(self.config.get('temperature', '0')) - * logger.info("[G2FCPP] FCode Printing Temperature = " + str(fc.printing_temperature)) # <<<<<<<<<<<<<< - * - * fc.is_cura = self.engine == 'cura' - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_fc->printing_temperature); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_kp_s_G2FCPP_FCode_Printing_Temperatu, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (!__pyx_t_5) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "src/utils/utils.pyx":240 - * self.fc = fc - * - * if self.config is not None: # <<<<<<<<<<<<<< - * if self.engine == 'cura': - * self.offset(z=float(self.config.get('z_offset', '0'))) - */ - } - - /* "src/utils/utils.pyx":249 - * logger.info("[G2FCPP] FCode Printing Temperature = " + str(fc.printing_temperature)) - * - * fc.is_cura = self.engine == 'cura' # <<<<<<<<<<<<<< - * fc.tool = 0; - * fc.filament[0] = 0 - */ - __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_self->engine, __pyx_n_s_cura, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 249, __pyx_L1_error) - __pyx_v_fc->is_cura = __pyx_t_2; - - /* "src/utils/utils.pyx":250 - * - * fc.is_cura = self.engine == 'cura' - * fc.tool = 0; # <<<<<<<<<<<<<< - * fc.filament[0] = 0 - * fc.G92_delta[1] = self.G92_delta[0] - */ - __pyx_v_fc->tool = 0; - - /* "src/utils/utils.pyx":251 - * fc.is_cura = self.engine == 'cura' - * fc.tool = 0; - * fc.filament[0] = 0 # <<<<<<<<<<<<<< - * fc.G92_delta[1] = self.G92_delta[0] - * fc.G92_delta[2] = self.G92_delta[1] - */ - (__pyx_v_fc->filament[0]) = 0.0; - - /* "src/utils/utils.pyx":252 - * fc.tool = 0; - * fc.filament[0] = 0 - * fc.G92_delta[1] = self.G92_delta[0] # <<<<<<<<<<<<<< - * fc.G92_delta[2] = self.G92_delta[1] - * fc.G92_delta[3] = self.G92_delta[2] - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_self->G92_delta, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - (__pyx_v_fc->G92_delta[1]) = __pyx_t_12; - - /* "src/utils/utils.pyx":253 - * fc.filament[0] = 0 - * fc.G92_delta[1] = self.G92_delta[0] - * fc.G92_delta[2] = self.G92_delta[1] # <<<<<<<<<<<<<< - * fc.G92_delta[3] = self.G92_delta[2] - * - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_self->G92_delta, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - (__pyx_v_fc->G92_delta[2]) = __pyx_t_12; - - /* "src/utils/utils.pyx":254 - * fc.G92_delta[1] = self.G92_delta[0] - * fc.G92_delta[2] = self.G92_delta[1] - * fc.G92_delta[3] = self.G92_delta[2] # <<<<<<<<<<<<<< - * - * logger.info("[G2FCPP] FCode Tool = " + str(fc.tool)) - */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_self->G92_delta, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - (__pyx_v_fc->G92_delta[3]) = __pyx_t_12; - - /* "src/utils/utils.pyx":256 - * fc.G92_delta[3] = self.G92_delta[2] - * - * logger.info("[G2FCPP] FCode Tool = " + str(fc.tool)) # <<<<<<<<<<<<<< - * - * try: - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_v_fc->tool)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_kp_s_G2FCPP_FCode_Tool, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_1)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - } - } - if (!__pyx_t_1) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_6}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "src/utils/utils.pyx":258 - * logger.info("[G2FCPP] FCode Tool = " + str(fc.tool)) - * - * try: # <<<<<<<<<<<<<< - * output_stream.write(self.header()) - * output_stream.write(struct.pack('tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L8_error) - } - for (;;) { - if (likely(!__pyx_t_8)) { - if (likely(PyList_CheckExact(__pyx_t_4))) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_11 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_11); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 265, __pyx_L8_error) - #else - __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - #endif - } else { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_11); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 265, __pyx_L8_error) - #else - __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 265, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - #endif - } - } else { - __pyx_t_11 = __pyx_t_8(__pyx_t_4); - if (unlikely(!__pyx_t_11)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 265, __pyx_L8_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_11); - } - __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_11); - __pyx_t_11 = 0; - - /* "src/utils/utils.pyx":267 - * for line in input_stream: - * #process lines in C++ - * fc.index = 12 + script_length # <<<<<<<<<<<<<< - * py_byte_string = line.encode('ascii') - * output_len = convert_to_fcode_by_line(py_byte_string, fc, output) - */ - __pyx_v_fc->index = (12 + __pyx_v_script_length); - - /* "src/utils/utils.pyx":268 - * #process lines in C++ - * fc.index = 12 + script_length - * py_byte_string = line.encode('ascii') # <<<<<<<<<<<<<< - * output_len = convert_to_fcode_by_line(py_byte_string, fc, output) - * - */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_line, __pyx_n_s_encode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 268, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 268, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_XDECREF_SET(__pyx_v_py_byte_string, __pyx_t_6); - __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":269 - * fc.index = 12 + script_length - * py_byte_string = line.encode('ascii') - * output_len = convert_to_fcode_by_line(py_byte_string, fc, output) # <<<<<<<<<<<<<< - * - * output_stream.write(output[:output_len]) - */ - __pyx_t_16 = __Pyx_PyObject_AsString(__pyx_v_py_byte_string); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 269, __pyx_L8_error) - __pyx_v_output_len = convert_to_fcode_by_line(__pyx_t_16, __pyx_v_fc, __pyx_v_output); - - /* "src/utils/utils.pyx":271 - * output_len = convert_to_fcode_by_line(py_byte_string, fc, output) - * - * output_stream.write(output[:output_len]) # <<<<<<<<<<<<<< - * script_length += output_len - * - */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_output_stream, __pyx_n_s_write); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_output) + 0, __pyx_v_output_len - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - } - } - if (!__pyx_t_5) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_17, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } - } - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":272 - * - * output_stream.write(output[:output_len]) - * script_length += output_len # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_script_length = (__pyx_v_script_length + __pyx_v_output_len); - - /* "src/utils/utils.pyx":265 - * - * logger.info("[G2FCPP] Start parsing...") - * for line in input_stream: # <<<<<<<<<<<<<< - * #process lines in C++ - * fc.index = 12 + script_length - */ - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "src/utils/utils.pyx":275 - * - * - * self.T = Thread(target=self.sub_convert_path) # <<<<<<<<<<<<<< - * self.T.start() - * - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Thread); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sub_convert_path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 275, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_target, __pyx_t_11) < 0) __PYX_ERR(0, 275, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 275, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GIVEREF(__pyx_t_11); - __Pyx_GOTREF(__pyx_v_self->T); - __Pyx_DECREF(__pyx_v_self->T); - __pyx_v_self->T = __pyx_t_11; - __pyx_t_11 = 0; - - /* "src/utils/utils.pyx":276 - * - * self.T = Thread(target=self.sub_convert_path) - * self.T.start() # <<<<<<<<<<<<<< - * - * # Calculate File CRC - */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->T, __pyx_n_s_start); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 276, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (__pyx_t_4) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 276, __pyx_L8_error) - } - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - - /* "src/utils/utils.pyx":279 - * - * # Calculate File CRC - * output_stream.seek(12, 0); # <<<<<<<<<<<<<< - * logger.info("[G2FCPP] Full Length " + str(script_length)); - * data = output_stream.read(script_length) - */ - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_output_stream, __pyx_n_s_seek); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 279, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":280 - * # Calculate File CRC - * output_stream.seek(12, 0); - * logger.info("[G2FCPP] Full Length " + str(script_length)); # <<<<<<<<<<<<<< - * data = output_stream.read(script_length) - * self.crc = crc32(data); - */ - __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_script_length); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_17 = PyTuple_New(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_11); - __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_17, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - __pyx_t_17 = PyNumber_Add(__pyx_kp_s_G2FCPP_Full_Length, __pyx_t_11); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_11) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_17}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_17}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } else - #endif - { - __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL; - __Pyx_GIVEREF(__pyx_t_17); - PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_17); - __pyx_t_17 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":281 - * output_stream.seek(12, 0); - * logger.info("[G2FCPP] Full Length " + str(script_length)); - * data = output_stream.read(script_length) # <<<<<<<<<<<<<< - * self.crc = crc32(data); - * logger.info("[G2FCPP] Full CRC " + str(self.crc)); - */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_output_stream, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_script_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_17 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_17)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_17); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_17) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_1}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_1}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_17); __pyx_t_17 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_data = __pyx_t_6; - __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":282 - * logger.info("[G2FCPP] Full Length " + str(script_length)); - * data = output_stream.read(script_length) - * self.crc = crc32(data); # <<<<<<<<<<<<<< - * logger.info("[G2FCPP] Full CRC " + str(self.crc)); - * output_stream.seek(0, 2) # - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_crc32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_11) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_data); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_data}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_v_data}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else - #endif - { - __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL; - __Pyx_INCREF(__pyx_v_data); - __Pyx_GIVEREF(__pyx_v_data); - PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_data); - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_18 = __Pyx_PyInt_As_unsigned_long(__pyx_t_6); if (unlikely((__pyx_t_18 == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 282, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_self->crc = __pyx_t_18; - - /* "src/utils/utils.pyx":283 - * data = output_stream.read(script_length) - * self.crc = crc32(data); - * logger.info("[G2FCPP] Full CRC " + str(self.crc)); # <<<<<<<<<<<<<< - * output_stream.seek(0, 2) # - * # Write back crc and length info - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyInt_From_unsigned_long(__pyx_v_self->crc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = PyNumber_Add(__pyx_kp_s_G2FCPP_Full_CRC, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (!__pyx_t_4) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_11}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_11}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - { - __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_11); - __pyx_t_11 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_17, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":284 - * self.crc = crc32(data); - * logger.info("[G2FCPP] Full CRC " + str(self.crc)); - * output_stream.seek(0, 2) # # <<<<<<<<<<<<<< - * # Write back crc and length info - * output_stream.write(struct.pack('crc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __pyx_t_5 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_I, __pyx_t_11}; - __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_17); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_I, __pyx_t_11}; - __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_17); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - } else - #endif - { - __pyx_t_19 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_19); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_9, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_9, __pyx_t_11); - __pyx_t_11 = 0; - __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_19, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_17}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_17}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } else - #endif - { - __pyx_t_19 = PyTuple_New(1+1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_19); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_17); - PyTuple_SET_ITEM(__pyx_t_19, 0+1, __pyx_t_17); - __pyx_t_17 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - } - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":287 - * # Write back crc and length info - * output_stream.write(struct.pack(' 0 and self.empty_layer[0] == 0: # clean up first empty layer - */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_output_stream, __pyx_n_s_seek); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 289, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 289, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":291 - * output_stream.seek(0, 2) # go back to file end - * - * if len(self.empty_layer) > 0 and self.empty_layer[0] == 0: # clean up first empty layer # <<<<<<<<<<<<<< - * self.empty_layer.pop(0) - * - */ - __pyx_t_1 = __pyx_v_self->empty_layer; - __Pyx_INCREF(__pyx_t_1); - __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 291, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = ((__pyx_t_7 > 0) != 0); - if (__pyx_t_3) { - } else { - __pyx_t_2 = __pyx_t_3; - goto __pyx_L19_bool_binop_done; - } - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->empty_layer, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 291, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_2 = __pyx_t_3; - __pyx_L19_bool_binop_done:; - if (__pyx_t_2) { - - /* "src/utils/utils.pyx":292 - * - * if len(self.empty_layer) > 0 and self.empty_layer[0] == 0: # clean up first empty layer - * self.empty_layer.pop(0) # <<<<<<<<<<<<<< - * - * # warning: fileformat didn't consider multi-extruder, use first extruder instead - */ - __pyx_t_6 = __Pyx_PyObject_PopIndex(__pyx_v_self->empty_layer, __pyx_int_0, 0, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 292, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":291 - * output_stream.seek(0, 2) # go back to file end - * - * if len(self.empty_layer) > 0 and self.empty_layer[0] == 0: # clean up first empty layer # <<<<<<<<<<<<<< - * self.empty_layer.pop(0) - * - */ - } - - /* "src/utils/utils.pyx":296 - * # warning: fileformat didn't consider multi-extruder, use first extruder instead - * # todo: test - * if self.md['HEAD_TYPE'] is None: # <<<<<<<<<<<<<< - * if fc.filament[0] and fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = 'EXTRUDER' - */ - __pyx_t_6 = PyObject_GetItem(__pyx_v_self->md, __pyx_n_s_HEAD_TYPE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = (__pyx_t_6 == Py_None); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "src/utils/utils.pyx":297 - * # todo: test - * if self.md['HEAD_TYPE'] is None: - * if fc.filament[0] and fc.HEAD_TYPE == NULL: # <<<<<<<<<<<<<< - * self.md['HEAD_TYPE'] = 'EXTRUDER' - * elif fc.HEAD_TYPE == NULL: - */ - __pyx_t_2 = ((__pyx_v_fc->filament[0]) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_3 = __pyx_t_2; - goto __pyx_L23_bool_binop_done; - } - __pyx_t_2 = ((__pyx_v_fc->HEAD_TYPE == NULL) != 0); - __pyx_t_3 = __pyx_t_2; - __pyx_L23_bool_binop_done:; - if (__pyx_t_3) { - - /* "src/utils/utils.pyx":298 - * if self.md['HEAD_TYPE'] is None: - * if fc.filament[0] and fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = 'EXTRUDER' # <<<<<<<<<<<<<< - * elif fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = "" + fc.HEAD_TYPE - */ - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_HEAD_TYPE, __pyx_n_s_EXTRUDER) < 0)) __PYX_ERR(0, 298, __pyx_L8_error) - - /* "src/utils/utils.pyx":297 - * # todo: test - * if self.md['HEAD_TYPE'] is None: - * if fc.filament[0] and fc.HEAD_TYPE == NULL: # <<<<<<<<<<<<<< - * self.md['HEAD_TYPE'] = 'EXTRUDER' - * elif fc.HEAD_TYPE == NULL: - */ - goto __pyx_L22; - } - - /* "src/utils/utils.pyx":299 - * if fc.filament[0] and fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = 'EXTRUDER' - * elif fc.HEAD_TYPE == NULL: # <<<<<<<<<<<<<< - * self.md['HEAD_TYPE'] = "" + fc.HEAD_TYPE - * else: - */ - __pyx_t_3 = ((__pyx_v_fc->HEAD_TYPE == NULL) != 0); - if (__pyx_t_3) { - - /* "src/utils/utils.pyx":300 - * self.md['HEAD_TYPE'] = 'EXTRUDER' - * elif fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = "" + fc.HEAD_TYPE # <<<<<<<<<<<<<< - * else: - * self.md['HEAD_TYPE'] = "None"; - */ - __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_fc->HEAD_TYPE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 300, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyNumber_Add(__pyx_kp_s__9, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_HEAD_TYPE, __pyx_t_1) < 0)) __PYX_ERR(0, 300, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":299 - * if fc.filament[0] and fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = 'EXTRUDER' - * elif fc.HEAD_TYPE == NULL: # <<<<<<<<<<<<<< - * self.md['HEAD_TYPE'] = "" + fc.HEAD_TYPE - * else: - */ - goto __pyx_L22; - } - - /* "src/utils/utils.pyx":302 - * self.md['HEAD_TYPE'] = "" + fc.HEAD_TYPE - * else: - * self.md['HEAD_TYPE'] = "None"; # <<<<<<<<<<<<<< - * - * if self.md['HEAD_TYPE'] == 'EXTRUDER': - */ - /*else*/ { - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_HEAD_TYPE, __pyx_n_s_None) < 0)) __PYX_ERR(0, 302, __pyx_L8_error) - } - __pyx_L22:; - - /* "src/utils/utils.pyx":296 - * # warning: fileformat didn't consider multi-extruder, use first extruder instead - * # todo: test - * if self.md['HEAD_TYPE'] is None: # <<<<<<<<<<<<<< - * if fc.filament[0] and fc.HEAD_TYPE == NULL: - * self.md['HEAD_TYPE'] = 'EXTRUDER' - */ - } - - /* "src/utils/utils.pyx":304 - * self.md['HEAD_TYPE'] = "None"; - * - * if self.md['HEAD_TYPE'] == 'EXTRUDER': # <<<<<<<<<<<<<< - * self.md['FILAMENT_USED'] = ','.join(map(str, fc.filament)) - * # self.md['CORRECTION'] = 'A' - */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_self->md, __pyx_n_s_HEAD_TYPE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_EXTRUDER, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 304, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_3) { - - /* "src/utils/utils.pyx":305 - * - * if self.md['HEAD_TYPE'] == 'EXTRUDER': - * self.md['FILAMENT_USED'] = ','.join(map(str, fc.filament)) # <<<<<<<<<<<<<< - * # self.md['CORRECTION'] = 'A' - * self.md['SETTING'] = str(comment_list[-137:]) - */ - __pyx_t_1 = __Pyx_carray_to_py_float(__pyx_v_fc->filament, 3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 305, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(((PyObject *)(&PyString_Type))); - __Pyx_GIVEREF(((PyObject *)(&PyString_Type))); - PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)(&PyString_Type))); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Join(__pyx_kp_s__3, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 305, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_FILAMENT_USED, __pyx_t_6) < 0)) __PYX_ERR(0, 305, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":307 - * self.md['FILAMENT_USED'] = ','.join(map(str, fc.filament)) - * # self.md['CORRECTION'] = 'A' - * self.md['SETTING'] = str(comment_list[-137:]) # <<<<<<<<<<<<<< - * else: - * self.md['CORRECTION'] = 'N' - */ - __pyx_t_6 = __Pyx_PyList_GetSlice(__pyx_v_comment_list, -137L, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_SETTING, __pyx_t_6) < 0)) __PYX_ERR(0, 307, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":304 - * self.md['HEAD_TYPE'] = "None"; - * - * if self.md['HEAD_TYPE'] == 'EXTRUDER': # <<<<<<<<<<<<<< - * self.md['FILAMENT_USED'] = ','.join(map(str, fc.filament)) - * # self.md['CORRECTION'] = 'A' - */ - goto __pyx_L25; - } - - /* "src/utils/utils.pyx":309 - * self.md['SETTING'] = str(comment_list[-137:]) - * else: - * self.md['CORRECTION'] = 'N' # <<<<<<<<<<<<<< - * - * self.md['TRAVEL_DIST'] = str(fc.distance) - */ - /*else*/ { - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_CORRECTION, __pyx_n_s_N) < 0)) __PYX_ERR(0, 309, __pyx_L8_error) - } - __pyx_L25:; - - /* "src/utils/utils.pyx":311 - * self.md['CORRECTION'] = 'N' - * - * self.md['TRAVEL_DIST'] = str(fc.distance) # <<<<<<<<<<<<<< - * fc.max_range[3] = sqrt(fc.max_range[3]) - * for v, k in enumerate(['X', 'Y', 'Z', 'R']): - */ - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_fc->distance); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 311, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 311, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 311, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_TRAVEL_DIST, __pyx_t_6) < 0)) __PYX_ERR(0, 311, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":312 - * - * self.md['TRAVEL_DIST'] = str(fc.distance) - * fc.max_range[3] = sqrt(fc.max_range[3]) # <<<<<<<<<<<<<< - * for v, k in enumerate(['X', 'Y', 'Z', 'R']): - * self.md['MAX_' + k] = str(fc.max_range[v]) - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyFloat_FromDouble((__pyx_v_fc->max_range[3])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_19 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_19)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_19); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (!__pyx_t_19) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_t_5}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_19, __pyx_t_5}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_19); __pyx_t_19 = NULL; - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 312, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - (__pyx_v_fc->max_range[3]) = __pyx_t_12; - - /* "src/utils/utils.pyx":313 - * self.md['TRAVEL_DIST'] = str(fc.distance) - * fc.max_range[3] = sqrt(fc.max_range[3]) - * for v, k in enumerate(['X', 'Y', 'Z', 'R']): # <<<<<<<<<<<<<< - * self.md['MAX_' + k] = str(fc.max_range[v]) - * - */ - __Pyx_INCREF(__pyx_int_0); - __pyx_t_6 = __pyx_int_0; - __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_X); - __Pyx_GIVEREF(__pyx_n_s_X); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_X); - __Pyx_INCREF(__pyx_n_s_Y); - __Pyx_GIVEREF(__pyx_n_s_Y); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_Y); - __Pyx_INCREF(__pyx_n_s_Z); - __Pyx_GIVEREF(__pyx_n_s_Z); - PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_Z); - __Pyx_INCREF(__pyx_n_s_R); - __Pyx_GIVEREF(__pyx_n_s_R); - PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_R); - __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (;;) { - if (__pyx_t_7 >= 4) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 313, __pyx_L8_error) - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - #endif - __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_1); - __pyx_t_1 = 0; - __Pyx_INCREF(__pyx_t_6); - __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6); - __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_6, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); - __pyx_t_6 = __pyx_t_1; - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":314 - * fc.max_range[3] = sqrt(fc.max_range[3]) - * for v, k in enumerate(['X', 'Y', 'Z', 'R']): - * self.md['MAX_' + k] = str(fc.max_range[v]) # <<<<<<<<<<<<<< - * - * self.md['TIME_COST'] = str(fc.time_need) - */ - __pyx_t_20 = __Pyx_PyIndex_AsSsize_t(__pyx_v_v); if (unlikely((__pyx_t_20 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 314, __pyx_L8_error) - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_fc->max_range[__pyx_t_20])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 314, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Add(__pyx_n_s_MAX, __pyx_v_k); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 314, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_t_5, __pyx_t_1) < 0)) __PYX_ERR(0, 314, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":313 - * self.md['TRAVEL_DIST'] = str(fc.distance) - * fc.max_range[3] = sqrt(fc.max_range[3]) - * for v, k in enumerate(['X', 'Y', 'Z', 'R']): # <<<<<<<<<<<<<< - * self.md['MAX_' + k] = str(fc.max_range[v]) - * - */ - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":316 - * self.md['MAX_' + k] = str(fc.max_range[v]) - * - * self.md['TIME_COST'] = str(fc.time_need) # <<<<<<<<<<<<<< - * self.md['CREATED_AT'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(time.time())) - * self.md['AUTHOR'] = getuser() # TODO: use fluxstudio user name? - */ - __pyx_t_6 = PyFloat_FromDouble(__pyx_v_fc->time_need); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 316, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyString_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 316, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_TIME_COST, __pyx_t_6) < 0)) __PYX_ERR(0, 316, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":317 - * - * self.md['TIME_COST'] = str(fc.time_need) - * self.md['CREATED_AT'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(time.time())) # <<<<<<<<<<<<<< - * self.md['AUTHOR'] = getuser() # TODO: use fluxstudio user name? - * - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strftime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_localtime); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_19); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_time); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_time); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - __pyx_t_17 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { - __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_11); - if (likely(__pyx_t_17)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); - __Pyx_INCREF(__pyx_t_17); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_11, function); - } - } - if (__pyx_t_17) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } else { - __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 317, __pyx_L8_error) - } - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) { - __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_19); - if (likely(__pyx_t_11)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19); - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_19, function); - } - } - if (!__pyx_t_11) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_19, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_19)) { - PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_5}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) { - PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_5}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_11); __pyx_t_11 = NULL; - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_17, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } - } - __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; - __pyx_t_19 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_19)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_19); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_kp_s_Y_m_dT_H_M_SZ, __pyx_t_4}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_kp_s_Y_m_dT_H_M_SZ, __pyx_t_4}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_17 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_17); - if (__pyx_t_19) { - __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_19); __pyx_t_19 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_Y_m_dT_H_M_SZ); - __Pyx_GIVEREF(__pyx_kp_s_Y_m_dT_H_M_SZ); - PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_9, __pyx_kp_s_Y_m_dT_H_M_SZ); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_9, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_17, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_CREATED_AT, __pyx_t_6) < 0)) __PYX_ERR(0, 317, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":318 - * self.md['TIME_COST'] = str(fc.time_need) - * self.md['CREATED_AT'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(time.time())) - * self.md['AUTHOR'] = getuser() # TODO: use fluxstudio user name? # <<<<<<<<<<<<<< - * - * if self.config and self.config.get('geometric_error_correction_on', '0') == '1': - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_getuser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_17 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_17)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_17); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (__pyx_t_17) { - __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 318, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; - } else { - __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 318, __pyx_L8_error) - } - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_AUTHOR, __pyx_t_6) < 0)) __PYX_ERR(0, 318, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "src/utils/utils.pyx":320 - * self.md['AUTHOR'] = getuser() # TODO: use fluxstudio user name? - * - * if self.config and self.config.get('geometric_error_correction_on', '0') == '1': # <<<<<<<<<<<<<< - * self.md['BACKLASH'] = 'Y' - * - */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_self->config); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 320, __pyx_L8_error) - if (__pyx_t_2) { - } else { - __pyx_t_3 = __pyx_t_2; - goto __pyx_L29_bool_binop_done; - } - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->config, __pyx_n_s_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 320, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_kp_s_1, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 320, __pyx_L8_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_t_2; - __pyx_L29_bool_binop_done:; - if (__pyx_t_3) { - - /* "src/utils/utils.pyx":321 - * - * if self.config and self.config.get('geometric_error_correction_on', '0') == '1': - * self.md['BACKLASH'] = 'Y' # <<<<<<<<<<<<<< - * - * logger.info("[G2FCPP] Finished parsing"); - */ - if (unlikely(PyObject_SetItem(__pyx_v_self->md, __pyx_n_s_BACKLASH, __pyx_n_s_Y) < 0)) __PYX_ERR(0, 321, __pyx_L8_error) - - /* "src/utils/utils.pyx":320 - * self.md['AUTHOR'] = getuser() # TODO: use fluxstudio user name? - * - * if self.config and self.config.get('geometric_error_correction_on', '0') == '1': # <<<<<<<<<<<<<< - * self.md['BACKLASH'] = 'Y' - * - */ - } - - /* "src/utils/utils.pyx":323 - * self.md['BACKLASH'] = 'Y' - * - * logger.info("[G2FCPP] Finished parsing"); # <<<<<<<<<<<<<< - * self.write_metadata(output_stream, self.md) - * - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":324 - * - * logger.info("[G2FCPP] Finished parsing"); - * self.write_metadata(output_stream, self.md) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_metadata); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 324, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_17 = NULL; - __pyx_t_9 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_17)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_17); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - __pyx_t_9 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_v_output_stream, __pyx_v_self->md}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_17, __pyx_v_output_stream, __pyx_v_self->md}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L8_error) - __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 324, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_17) { - __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_17); __pyx_t_17 = NULL; - } - __Pyx_INCREF(__pyx_v_output_stream); - __Pyx_GIVEREF(__pyx_v_output_stream); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_output_stream); - __Pyx_INCREF(__pyx_v_self->md); - __Pyx_GIVEREF(__pyx_v_self->md); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_v_self->md); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L8_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":258 - * logger.info("[G2FCPP] FCode Tool = " + str(fc.tool)) - * - * try: # <<<<<<<<<<<<<< - * output_stream.write(self.header()) - * output_stream.write(struct.pack('fc); - - /* "src/utils/utils.pyx":334 - * return 'broken' - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * PyMem_Free(self.fc) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "src/utils/utils.pyx":113 - * cdef FCode* fc - * cdef unsigned long crc - * cdef public object image # <<<<<<<<<<<<<< - * cdef public object md - * cdef char record_path - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->image); - __pyx_r = __pyx_v_self->image; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->image); - __Pyx_DECREF(__pyx_v_self->image); - __pyx_v_self->image = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->image); - __Pyx_DECREF(__pyx_v_self->image); - __pyx_v_self->image = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":114 - * cdef unsigned long crc - * cdef public object image - * cdef public object md # <<<<<<<<<<<<<< - * cdef char record_path - * cdef public object empty_layer - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->md); - __pyx_r = __pyx_v_self->md; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->md); - __Pyx_DECREF(__pyx_v_self->md); - __pyx_v_self->md = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->md); - __Pyx_DECREF(__pyx_v_self->md); - __pyx_v_self->md = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":116 - * cdef public object md - * cdef char record_path - * cdef public object empty_layer # <<<<<<<<<<<<<< - * cdef public object pause_at_layers - * cdef object path_js - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->empty_layer); - __pyx_r = __pyx_v_self->empty_layer; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->empty_layer); - __Pyx_DECREF(__pyx_v_self->empty_layer); - __pyx_v_self->empty_layer = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->empty_layer); - __Pyx_DECREF(__pyx_v_self->empty_layer); - __pyx_v_self->empty_layer = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":117 - * cdef char record_path - * cdef public object empty_layer - * cdef public object pause_at_layers # <<<<<<<<<<<<<< - * cdef object path_js - * cdef object T #Thread - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->pause_at_layers); - __pyx_r = __pyx_v_self->pause_at_layers; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->pause_at_layers); - __Pyx_DECREF(__pyx_v_self->pause_at_layers); - __pyx_v_self->pause_at_layers = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->pause_at_layers); - __Pyx_DECREF(__pyx_v_self->pause_at_layers); - __pyx_v_self->pause_at_layers = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":120 - * cdef object path_js - * cdef object T #Thread - * cdef public str engine # <<<<<<<<<<<<<< - * cdef public object path - * cdef public object G92_delta - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->engine); - __pyx_r = __pyx_v_self->engine; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__set__", 0); - if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 120, __pyx_L1_error) - __pyx_t_1 = __pyx_v_value; - __Pyx_INCREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->engine); - __Pyx_DECREF(__pyx_v_self->engine); - __pyx_v_self->engine = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("fluxclient.utils._utils.GcodeToFcodeCpp.engine.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->engine); - __Pyx_DECREF(__pyx_v_self->engine); - __pyx_v_self->engine = ((PyObject*)Py_None); - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":121 - * cdef object T #Thread - * cdef public str engine - * cdef public object path # <<<<<<<<<<<<<< - * cdef public object G92_delta - * cdef public object config - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->path); - __pyx_r = __pyx_v_self->path; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->path); - __Pyx_DECREF(__pyx_v_self->path); - __pyx_v_self->path = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->path); - __Pyx_DECREF(__pyx_v_self->path); - __pyx_v_self->path = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":122 - * cdef public str engine - * cdef public object path - * cdef public object G92_delta # <<<<<<<<<<<<<< - * cdef public object config - * """transform from gcode to fcode - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->G92_delta); - __pyx_r = __pyx_v_self->G92_delta; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->G92_delta); - __Pyx_DECREF(__pyx_v_self->G92_delta); - __pyx_v_self->G92_delta = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->G92_delta); - __Pyx_DECREF(__pyx_v_self->G92_delta); - __pyx_v_self->G92_delta = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "src/utils/utils.pyx":123 - * cdef public object path - * cdef public object G92_delta - * cdef public object config # <<<<<<<<<<<<<< - * """transform from gcode to fcode - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config___get__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config___get__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->config); - __pyx_r = __pyx_v_self->config; - goto __pyx_L0; - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_2__set__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_2__set__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->config); - __Pyx_DECREF(__pyx_v_self->config); - __pyx_v_self->config = __pyx_v_value; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_4__del__(((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_4__del__(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->config); - __Pyx_DECREF(__pyx_v_self->config); - __pyx_v_self->config = Py_None; - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "string.to_py":31 - * - * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - -static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0); - - /* "string.to_py":32 - * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): - * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< - * cdef extern from *: - * cdef object __Pyx_PyUnicode_FromStringAndSize(char*, size_t) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 32, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "string.to_py":31 - * - * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "string.to_py":37 - * - * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - -static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0); - - /* "string.to_py":38 - * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): - * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< - * cdef extern from *: - * cdef object __Pyx_PyStr_FromStringAndSize(char*, size_t) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 38, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "string.to_py":37 - * - * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "string.to_py":43 - * - * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - -static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0); - - /* "string.to_py":44 - * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): - * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< - * cdef extern from *: - * cdef object __Pyx_PyBytes_FromStringAndSize(char*, size_t) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "string.to_py":43 - * - * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "string.to_py":49 - * - * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - -static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0); - - /* "string.to_py":50 - * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): - * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< - * cdef extern from *: - * cdef object __Pyx_PyByteArray_FromStringAndSize(char*, size_t) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "string.to_py":49 - * - * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) - * cdef extern from *: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "string.to_py":55 - * - * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) - * - */ - -static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0); - - /* "string.to_py":56 - * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): - * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "string.to_py":55 - * - * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") - * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< - * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "vector.from_py":49 - * - * @cname("__pyx_convert_vector_from_py_float") - * cdef vector[X] __pyx_convert_vector_from_py_float(object o) except *: # <<<<<<<<<<<<<< - * cdef vector[X] v - * for item in o: - */ - -static std::vector __pyx_convert_vector_from_py_float(PyObject *__pyx_v_o) { - std::vector __pyx_v_v; - PyObject *__pyx_v_item = NULL; - std::vector __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - float __pyx_t_5; - __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_float", 0); - - /* "vector.from_py":51 - * cdef vector[X] __pyx_convert_vector_from_py_float(object o) except *: - * cdef vector[X] v - * for item in o: # <<<<<<<<<<<<<< - * v.push_back(X_from_py(item)) - * return v - */ - if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { - __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 51, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_3)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 51, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 51, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(1, 51, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4); - __pyx_t_4 = 0; - - /* "vector.from_py":52 - * cdef vector[X] v - * for item in o: - * v.push_back(X_from_py(item)) # <<<<<<<<<<<<<< - * return v - * - */ - __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_v_item); if (unlikely(__pyx_t_5 == -1.0 && PyErr_Occurred())) __PYX_ERR(1, 52, __pyx_L1_error) - __pyx_v_v.push_back(__pyx_t_5); - - /* "vector.from_py":51 - * cdef vector[X] __pyx_convert_vector_from_py_float(object o) except *: - * cdef vector[X] v - * for item in o: # <<<<<<<<<<<<<< - * v.push_back(X_from_py(item)) - * return v - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "vector.from_py":53 - * for item in o: - * v.push_back(X_from_py(item)) - * return v # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_v; - goto __pyx_L0; - - /* "vector.from_py":49 - * - * @cname("__pyx_convert_vector_from_py_float") - * cdef vector[X] __pyx_convert_vector_from_py_float(object o) except *: # <<<<<<<<<<<<<< - * cdef vector[X] v - * for item in o: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_float", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_item); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "vector.from_py":50 - * - * @cname("__pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___") - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(object o) except *: # <<<<<<<<<<<<<< - * cdef vector[X] v - * for item in o: - */ - -static std::vector > __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(PyObject *__pyx_v_o) { - std::vector > __pyx_v_v; - PyObject *__pyx_v_item = NULL; - std::vector > __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - std::vector __pyx_t_5; - __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___", 0); - - /* "vector.from_py":52 - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(object o) except *: - * cdef vector[X] v - * for item in o: # <<<<<<<<<<<<<< - * v.push_back(X_from_py(item)) - * return v - */ - if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { - __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 52, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_3)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 52, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 52, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(1, 52, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4); - __pyx_t_4 = 0; - - /* "vector.from_py":53 - * cdef vector[X] v - * for item in o: - * v.push_back(X_from_py(item)) # <<<<<<<<<<<<<< - * return v - * - */ - __pyx_t_5 = __pyx_convert_vector_from_py_float(__pyx_v_item); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L1_error) - __pyx_v_v.push_back(__pyx_t_5); - - /* "vector.from_py":52 - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(object o) except *: - * cdef vector[X] v - * for item in o: # <<<<<<<<<<<<<< - * v.push_back(X_from_py(item)) - * return v - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "vector.from_py":54 - * for item in o: - * v.push_back(X_from_py(item)) - * return v # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_v; - goto __pyx_L0; - - /* "vector.from_py":50 - * - * @cname("__pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___") - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(object o) except *: # <<<<<<<<<<<<<< - * cdef vector[X] v - * for item in o: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_item); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static std::vector > > __pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___(PyObject *__pyx_v_o) { - std::vector > > __pyx_v_v; - PyObject *__pyx_v_item = NULL; - std::vector > > __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - std::vector > __pyx_t_5; - __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___", 0); - - /* "vector.from_py":52 - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___(object o) except *: - * cdef vector[X] v - * for item in o: # <<<<<<<<<<<<<< - * v.push_back(X_from_py(item)) - * return v - */ - if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { - __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 52, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_3)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 52, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 52, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(1, 52, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4); - __pyx_t_4 = 0; - - /* "vector.from_py":53 - * cdef vector[X] v - * for item in o: - * v.push_back(X_from_py(item)) # <<<<<<<<<<<<<< - * return v - * - */ - __pyx_t_5 = __pyx_convert_vector_from_py_std_3a__3a_vector_3c_float_3e___(__pyx_v_item); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L1_error) - __pyx_v_v.push_back(__pyx_t_5); - - /* "vector.from_py":52 - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___(object o) except *: - * cdef vector[X] v - * for item in o: # <<<<<<<<<<<<<< - * v.push_back(X_from_py(item)) - * return v - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "vector.from_py":54 - * for item in o: - * v.push_back(X_from_py(item)) - * return v # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_v; - goto __pyx_L0; - - /* "vector.from_py":50 - * - * @cname("__pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___") - * cdef vector[X] __pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___(object o) except *: # <<<<<<<<<<<<<< - * cdef vector[X] v - * for item in o: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_std_3a__3a_vector_3c_std_3a__3a_vector_3c_float_3e____3e___", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_item); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "FromPyStructUtility":11 - * - * @cname("__pyx_convert__from_py_PathVector") - * cdef PathVector __pyx_convert__from_py_PathVector(obj) except *: # <<<<<<<<<<<<<< - * cdef PathVector result - * if not PyMapping_Check(obj): - */ - -static PathVector __pyx_convert__from_py_PathVector(PyObject *__pyx_v_obj) { - PathVector __pyx_v_result; - PathVector __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__pyx_convert__from_py_PathVector", 0); - - /* "FromPyStructUtility":13 - * cdef PathVector __pyx_convert__from_py_PathVector(obj) except *: - * cdef PathVector result - * if not PyMapping_Check(obj): # <<<<<<<<<<<<<< - * PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) - * - */ - __pyx_t_1 = ((!(PyMapping_Check(__pyx_v_obj) != 0)) != 0); - if (__pyx_t_1) { - - /* "FromPyStructUtility":14 - * cdef PathVector result - * if not PyMapping_Check(obj): - * PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) # <<<<<<<<<<<<<< - * - * return result - */ - __pyx_t_2 = PyErr_Format(__pyx_builtin_TypeError, ((char const *)"Expected %.16s, got %.200s"), ((char *)"a mapping"), Py_TYPE(__pyx_v_obj)->tp_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "FromPyStructUtility":13 - * cdef PathVector __pyx_convert__from_py_PathVector(obj) except *: - * cdef PathVector result - * if not PyMapping_Check(obj): # <<<<<<<<<<<<<< - * PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) - * - */ - } - - /* "FromPyStructUtility":16 - * PyErr_Format(TypeError, b"Expected %.16s, got %.200s", b"a mapping", Py_TYPE(obj).tp_name) - * - * return result # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; - - /* "FromPyStructUtility":11 - * - * @cname("__pyx_convert__from_py_PathVector") - * cdef PathVector __pyx_convert__from_py_PathVector(obj) except *: # <<<<<<<<<<<<<< - * cdef PathVector result - * if not PyMapping_Check(obj): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("FromPyStructUtility.__pyx_convert__from_py_PathVector", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "carray.to_py":112 - * - * @cname("__Pyx_carray_to_py_float") - * cdef inline list __Pyx_carray_to_py_float(float *v, Py_ssize_t length): # <<<<<<<<<<<<<< - * cdef size_t i - * cdef object value - */ - -static CYTHON_INLINE PyObject *__Pyx_carray_to_py_float(float *__pyx_v_v, Py_ssize_t __pyx_v_length) { - size_t __pyx_v_i; - PyObject *__pyx_v_value = 0; - PyObject *__pyx_v_l = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - size_t __pyx_t_2; - size_t __pyx_t_3; - __Pyx_RefNannySetupContext("__Pyx_carray_to_py_float", 0); - - /* "carray.to_py":115 - * cdef size_t i - * cdef object value - * l = PyList_New(length) # <<<<<<<<<<<<<< - * for i in range(length): - * value = v[i] - */ - __pyx_t_1 = PyList_New(__pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_l = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "carray.to_py":116 - * cdef object value - * l = PyList_New(length) - * for i in range(length): # <<<<<<<<<<<<<< - * value = v[i] - * Py_INCREF(value) - */ - __pyx_t_2 = ((size_t)__pyx_v_length); - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; - - /* "carray.to_py":117 - * l = PyList_New(length) - * for i in range(length): - * value = v[i] # <<<<<<<<<<<<<< - * Py_INCREF(value) - * PyList_SET_ITEM(l, i, value) - */ - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_1); - __pyx_t_1 = 0; - - /* "carray.to_py":118 - * for i in range(length): - * value = v[i] - * Py_INCREF(value) # <<<<<<<<<<<<<< - * PyList_SET_ITEM(l, i, value) - * return l - */ - Py_INCREF(__pyx_v_value); - - /* "carray.to_py":119 - * value = v[i] - * Py_INCREF(value) - * PyList_SET_ITEM(l, i, value) # <<<<<<<<<<<<<< - * return l - * - */ - PyList_SET_ITEM(__pyx_v_l, __pyx_v_i, __pyx_v_value); - } - - /* "carray.to_py":120 - * Py_INCREF(value) - * PyList_SET_ITEM(l, i, value) - * return l # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_l); - __pyx_r = __pyx_v_l; - goto __pyx_L0; - - /* "carray.to_py":112 - * - * @cname("__Pyx_carray_to_py_float") - * cdef inline list __Pyx_carray_to_py_float(float *v, Py_ssize_t length): # <<<<<<<<<<<<<< - * cdef size_t i - * cdef object value - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("carray.to_py.__Pyx_carray_to_py_float", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_value); - __Pyx_XDECREF(__pyx_v_l); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "carray.to_py":124 - * - * @cname("__Pyx_carray_to_tuple_float") - * cdef inline tuple __Pyx_carray_to_tuple_float(float *v, Py_ssize_t length): # <<<<<<<<<<<<<< - * cdef size_t i - * cdef object value - */ - -static CYTHON_INLINE PyObject *__Pyx_carray_to_tuple_float(float *__pyx_v_v, Py_ssize_t __pyx_v_length) { - size_t __pyx_v_i; - PyObject *__pyx_v_value = 0; - PyObject *__pyx_v_t = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - size_t __pyx_t_2; - size_t __pyx_t_3; - __Pyx_RefNannySetupContext("__Pyx_carray_to_tuple_float", 0); - - /* "carray.to_py":127 - * cdef size_t i - * cdef object value - * t = PyTuple_New(length) # <<<<<<<<<<<<<< - * for i in range(length): - * value = v[i] - */ - __pyx_t_1 = PyTuple_New(__pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 127, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_t = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "carray.to_py":128 - * cdef object value - * t = PyTuple_New(length) - * for i in range(length): # <<<<<<<<<<<<<< - * value = v[i] - * Py_INCREF(value) - */ - __pyx_t_2 = ((size_t)__pyx_v_length); - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; - - /* "carray.to_py":129 - * t = PyTuple_New(length) - * for i in range(length): - * value = v[i] # <<<<<<<<<<<<<< - * Py_INCREF(value) - * PyTuple_SET_ITEM(t, i, value) - */ - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_v[__pyx_v_i])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_1); - __pyx_t_1 = 0; - - /* "carray.to_py":130 - * for i in range(length): - * value = v[i] - * Py_INCREF(value) # <<<<<<<<<<<<<< - * PyTuple_SET_ITEM(t, i, value) - * return t - */ - Py_INCREF(__pyx_v_value); - - /* "carray.to_py":131 - * value = v[i] - * Py_INCREF(value) - * PyTuple_SET_ITEM(t, i, value) # <<<<<<<<<<<<<< - * return t - */ - PyTuple_SET_ITEM(__pyx_v_t, __pyx_v_i, __pyx_v_value); - } - - /* "carray.to_py":132 - * Py_INCREF(value) - * PyTuple_SET_ITEM(t, i, value) - * return t # <<<<<<<<<<<<<< - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_t); - __pyx_r = __pyx_v_t; - goto __pyx_L0; - - /* "carray.to_py":124 - * - * @cname("__Pyx_carray_to_tuple_float") - * cdef inline tuple __Pyx_carray_to_tuple_float(float *v, Py_ssize_t length): # <<<<<<<<<<<<<< - * cdef size_t i - * cdef object value - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("carray.to_py.__Pyx_carray_to_tuple_float", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_value); - __Pyx_XDECREF(__pyx_v_t); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_NativePath __pyx_vtable_10fluxclient_5utils_6_utils_NativePath; - -static PyObject *__pyx_tp_new_10fluxclient_5utils_6_utils_NativePath(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *)o); - p->__pyx_vtab = __pyx_vtabptr_10fluxclient_5utils_6_utils_NativePath; - return o; -} - -static void __pyx_tp_dealloc_10fluxclient_5utils_6_utils_NativePath(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_10fluxclient_5utils_6_utils_10NativePath_3__dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_10fluxclient_5utils_6_utils_NativePath[] = { - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_10fluxclient_5utils_6_utils_NativePath = { - PyVarObject_HEAD_INIT(0, 0) - "fluxclient.utils._utils.NativePath", /*tp_name*/ - sizeof(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_10fluxclient_5utils_6_utils_NativePath, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_10fluxclient_5utils_6_utils_NativePath, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pw_10fluxclient_5utils_6_utils_10NativePath_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_10fluxclient_5utils_6_utils_NativePath, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; -static struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_Tools __pyx_vtable_10fluxclient_5utils_6_utils_Tools; - -static PyObject *__pyx_tp_new_10fluxclient_5utils_6_utils_Tools(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *)o); - p->__pyx_vtab = __pyx_vtabptr_10fluxclient_5utils_6_utils_Tools; - return o; -} - -static void __pyx_tp_dealloc_10fluxclient_5utils_6_utils_Tools(PyObject *o) { - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_10fluxclient_5utils_6_utils_Tools[] = { - {"path_to_js", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_5Tools_3path_to_js, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_10fluxclient_5utils_6_utils_Tools = { - PyVarObject_HEAD_INIT(0, 0) - "fluxclient.utils._utils.Tools", /*tp_name*/ - sizeof(struct __pyx_obj_10fluxclient_5utils_6_utils_Tools), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_10fluxclient_5utils_6_utils_Tools, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_10fluxclient_5utils_6_utils_Tools, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pw_10fluxclient_5utils_6_utils_5Tools_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_10fluxclient_5utils_6_utils_Tools, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; -static struct __pyx_vtabstruct_10fluxclient_5utils_6_utils_GcodeToFcodeCpp __pyx_vtable_10fluxclient_5utils_6_utils_GcodeToFcodeCpp; - -static PyObject *__pyx_tp_new_10fluxclient_5utils_6_utils_GcodeToFcodeCpp(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)o); - p->__pyx_vtab = __pyx_vtabptr_10fluxclient_5utils_6_utils_GcodeToFcodeCpp; - p->image = Py_None; Py_INCREF(Py_None); - p->md = Py_None; Py_INCREF(Py_None); - p->empty_layer = Py_None; Py_INCREF(Py_None); - p->pause_at_layers = Py_None; Py_INCREF(Py_None); - p->path_js = Py_None; Py_INCREF(Py_None); - p->T = Py_None; Py_INCREF(Py_None); - p->engine = ((PyObject*)Py_None); Py_INCREF(Py_None); - p->path = Py_None; Py_INCREF(Py_None); - p->G92_delta = Py_None; Py_INCREF(Py_None); - p->config = Py_None; Py_INCREF(Py_None); - return o; -} - -static void __pyx_tp_dealloc_10fluxclient_5utils_6_utils_GcodeToFcodeCpp(PyObject *o) { - struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *p = (struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)o; - #if PY_VERSION_HEX >= 0x030400a1 - if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_23__dealloc__(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - Py_CLEAR(p->image); - Py_CLEAR(p->md); - Py_CLEAR(p->empty_layer); - Py_CLEAR(p->pause_at_layers); - Py_CLEAR(p->path_js); - Py_CLEAR(p->T); - Py_CLEAR(p->engine); - Py_CLEAR(p->path); - Py_CLEAR(p->G92_delta); - Py_CLEAR(p->config); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_10fluxclient_5utils_6_utils_GcodeToFcodeCpp(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *p = (struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)o; - if (p->image) { - e = (*v)(p->image, a); if (e) return e; - } - if (p->md) { - e = (*v)(p->md, a); if (e) return e; - } - if (p->empty_layer) { - e = (*v)(p->empty_layer, a); if (e) return e; - } - if (p->pause_at_layers) { - e = (*v)(p->pause_at_layers, a); if (e) return e; - } - if (p->path_js) { - e = (*v)(p->path_js, a); if (e) return e; - } - if (p->T) { - e = (*v)(p->T, a); if (e) return e; - } - if (p->path) { - e = (*v)(p->path, a); if (e) return e; - } - if (p->G92_delta) { - e = (*v)(p->G92_delta, a); if (e) return e; - } - if (p->config) { - e = (*v)(p->config, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_10fluxclient_5utils_6_utils_GcodeToFcodeCpp(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *p = (struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *)o; - tmp = ((PyObject*)p->image); - p->image = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->md); - p->md = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->empty_layer); - p->empty_layer = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->pause_at_layers); - p->pause_at_layers = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->path_js); - p->path_js = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->T); - p->T = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->path); - p->path = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->G92_delta); - p->G92_delta = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->config); - p->config = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_image(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_image(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5image_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_md(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_md(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2md_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_empty_layer(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_empty_layer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11empty_layer_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_pause_at_layers(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_pause_at_layers(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15pause_at_layers_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_engine(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_engine(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6engine_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_path(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_path(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4path_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_G92_delta(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_G92_delta(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9G92_delta_5__del__(o); - } -} - -static PyObject *__pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_config(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_1__get__(o); -} - -static int __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_config(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_3__set__(o, v); - } - else { - return __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6config_5__del__(o); - } -} - -static PyMethodDef __pyx_methods_10fluxclient_5utils_6_utils_GcodeToFcodeCpp[] = { - {"get_metadata", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_3get_metadata, METH_NOARGS, __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_2get_metadata}, - {"get_img", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_5get_img, METH_NOARGS, __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_4get_img}, - {"header", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_7header, METH_NOARGS, __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_6header}, - {"extract_vector", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_9extract_vector, METH_O, 0}, - {"sub_convert_path", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_11sub_convert_path, METH_NOARGS, 0}, - {"offset", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_13offset, METH_VARARGS|METH_KEYWORDS, 0}, - {"get_path", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_15get_path, METH_VARARGS|METH_KEYWORDS, 0}, - {"trim_ends", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_17trim_ends, METH_O, __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_16trim_ends}, - {"write_metadata", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_19write_metadata, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_18write_metadata}, - {"process", (PyCFunction)__pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_21process, METH_VARARGS|METH_KEYWORDS, __pyx_doc_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_20process}, - {0, 0, 0, 0} -}; - -static struct PyGetSetDef __pyx_getsets_10fluxclient_5utils_6_utils_GcodeToFcodeCpp[] = { - {(char *)"image", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_image, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_image, (char *)0, 0}, - {(char *)"md", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_md, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_md, (char *)0, 0}, - {(char *)"empty_layer", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_empty_layer, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_empty_layer, (char *)0, 0}, - {(char *)"pause_at_layers", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_pause_at_layers, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_pause_at_layers, (char *)0, 0}, - {(char *)"engine", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_engine, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_engine, (char *)0, 0}, - {(char *)"path", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_path, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_path, (char *)0, 0}, - {(char *)"G92_delta", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_G92_delta, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_G92_delta, (char *)0, 0}, - {(char *)"config", __pyx_getprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_config, __pyx_setprop_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_config, (char *)"transform from gcode to fcode\n\n this should done several thing:\n transform gcode into fcode\n analyze metadata\n ", 0}, - {0, 0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_10fluxclient_5utils_6_utils_GcodeToFcodeCpp = { - PyVarObject_HEAD_INIT(0, 0) - "fluxclient.utils._utils.GcodeToFcodeCpp", /*tp_name*/ - sizeof(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_10fluxclient_5utils_6_utils_GcodeToFcodeCpp, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_10fluxclient_5utils_6_utils_GcodeToFcodeCpp, /*tp_traverse*/ - __pyx_tp_clear_10fluxclient_5utils_6_utils_GcodeToFcodeCpp, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_10fluxclient_5utils_6_utils_GcodeToFcodeCpp, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_10fluxclient_5utils_6_utils_GcodeToFcodeCpp, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pw_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_10fluxclient_5utils_6_utils_GcodeToFcodeCpp, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else - PyModuleDef_HEAD_INIT, - #endif - "_utils", - 0, /* m_doc */ - -1, /* m_size */ - __pyx_methods /* m_methods */, - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_s_0, __pyx_k_0, sizeof(__pyx_k_0), 0, 0, 1, 0}, - {&__pyx_kp_s_0_0_0, __pyx_k_0_0_0, sizeof(__pyx_k_0_0_0), 0, 0, 1, 0}, - {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, - {&__pyx_n_s_AUTHOR, __pyx_k_AUTHOR, sizeof(__pyx_k_AUTHOR), 0, 0, 1, 1}, - {&__pyx_kp_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 0}, - {&__pyx_n_s_BACKLASH, __pyx_k_BACKLASH, sizeof(__pyx_k_BACKLASH), 0, 0, 1, 1}, - {&__pyx_n_s_BytesIO, __pyx_k_BytesIO, sizeof(__pyx_k_BytesIO), 0, 0, 1, 1}, - {&__pyx_n_s_CORRECTION, __pyx_k_CORRECTION, sizeof(__pyx_k_CORRECTION), 0, 0, 1, 1}, - {&__pyx_n_s_CREATED_AT, __pyx_k_CREATED_AT, sizeof(__pyx_k_CREATED_AT), 0, 0, 1, 1}, - {&__pyx_n_s_EXTRUDER, __pyx_k_EXTRUDER, sizeof(__pyx_k_EXTRUDER), 0, 0, 1, 1}, - {&__pyx_n_b_FCx0001, __pyx_k_FCx0001, sizeof(__pyx_k_FCx0001), 0, 0, 0, 1}, - {&__pyx_n_s_FILAMENT_USED, __pyx_k_FILAMENT_USED, sizeof(__pyx_k_FILAMENT_USED), 0, 0, 1, 1}, - {&__pyx_kp_s_G2FCPP_FCode_Printing_Temperatu, __pyx_k_G2FCPP_FCode_Printing_Temperatu, sizeof(__pyx_k_G2FCPP_FCode_Printing_Temperatu), 0, 0, 1, 0}, - {&__pyx_kp_s_G2FCPP_FCode_Tool, __pyx_k_G2FCPP_FCode_Tool, sizeof(__pyx_k_G2FCPP_FCode_Tool), 0, 0, 1, 0}, - {&__pyx_kp_s_G2FCPP_Finished_parsing, __pyx_k_G2FCPP_Finished_parsing, sizeof(__pyx_k_G2FCPP_Finished_parsing), 0, 0, 1, 0}, - {&__pyx_kp_s_G2FCPP_Full_CRC, __pyx_k_G2FCPP_Full_CRC, sizeof(__pyx_k_G2FCPP_Full_CRC), 0, 0, 1, 0}, - {&__pyx_kp_s_G2FCPP_Full_Length, __pyx_k_G2FCPP_Full_Length, sizeof(__pyx_k_G2FCPP_Full_Length), 0, 0, 1, 0}, - {&__pyx_kp_s_G2FCPP_G2fcpp_failed, __pyx_k_G2FCPP_G2fcpp_failed, sizeof(__pyx_k_G2FCPP_G2fcpp_failed), 0, 0, 1, 0}, - {&__pyx_kp_s_G2FCPP_Start_parsing, __pyx_k_G2FCPP_Start_parsing, sizeof(__pyx_k_G2FCPP_Start_parsing), 0, 0, 1, 0}, - {&__pyx_kp_s_G_to_F_fail, __pyx_k_G_to_F_fail, sizeof(__pyx_k_G_to_F_fail), 0, 0, 1, 0}, - {&__pyx_n_s_HEAD_TYPE, __pyx_k_HEAD_TYPE, sizeof(__pyx_k_HEAD_TYPE), 0, 0, 1, 1}, - {&__pyx_n_s_HW_PROFILE, __pyx_k_HW_PROFILE, sizeof(__pyx_k_HW_PROFILE), 0, 0, 1, 1}, - {&__pyx_kp_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 0}, - {&__pyx_n_s_MAX, __pyx_k_MAX, sizeof(__pyx_k_MAX), 0, 0, 1, 1}, - {&__pyx_n_s_MAX_R, __pyx_k_MAX_R, sizeof(__pyx_k_MAX_R), 0, 0, 1, 1}, - {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1}, - {&__pyx_n_s_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 0, 1, 1}, - {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1}, - {&__pyx_n_s_SETTING, __pyx_k_SETTING, sizeof(__pyx_k_SETTING), 0, 0, 1, 1}, - {&__pyx_n_s_StringIO, __pyx_k_StringIO, sizeof(__pyx_k_StringIO), 0, 0, 1, 1}, - {&__pyx_n_s_TIME_COST, __pyx_k_TIME_COST, sizeof(__pyx_k_TIME_COST), 0, 0, 1, 1}, - {&__pyx_n_s_TRAVEL_DIST, __pyx_k_TRAVEL_DIST, sizeof(__pyx_k_TRAVEL_DIST), 0, 0, 1, 1}, - {&__pyx_n_s_Thread, __pyx_k_Thread, sizeof(__pyx_k_Thread), 0, 0, 1, 1}, - {&__pyx_n_s_Tools, __pyx_k_Tools, sizeof(__pyx_k_Tools), 0, 0, 1, 1}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1}, - {&__pyx_n_s_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 0, 1, 1}, - {&__pyx_kp_s_Y_m_dT_H_M_SZ, __pyx_k_Y_m_dT_H_M_SZ, sizeof(__pyx_k_Y_m_dT_H_M_SZ), 0, 0, 1, 0}, - {&__pyx_n_s_Z, __pyx_k_Z, sizeof(__pyx_k_Z), 0, 0, 1, 1}, - {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, - {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0}, - {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0}, - {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0}, - {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0}, - {&__pyx_kp_s__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 1, 0}, - {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1}, - {&__pyx_n_s_atan2, __pyx_k_atan2, sizeof(__pyx_k_atan2), 0, 0, 1, 1}, - {&__pyx_n_s_binascii, __pyx_k_binascii, sizeof(__pyx_k_binascii), 0, 0, 1, 1}, - {&__pyx_n_s_broken, __pyx_k_broken, sizeof(__pyx_k_broken), 0, 0, 1, 1}, - {&__pyx_n_s_cos, __pyx_k_cos, sizeof(__pyx_k_cos), 0, 0, 1, 1}, - {&__pyx_n_s_crc32, __pyx_k_crc32, sizeof(__pyx_k_crc32), 0, 0, 1, 1}, - {&__pyx_n_s_cura, __pyx_k_cura, sizeof(__pyx_k_cura), 0, 0, 1, 1}, - {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, - {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1}, - {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, - {&__pyx_n_s_ext_metadata, __pyx_k_ext_metadata, sizeof(__pyx_k_ext_metadata), 0, 0, 1, 1}, - {&__pyx_n_s_extract_vector, __pyx_k_extract_vector, sizeof(__pyx_k_extract_vector), 0, 0, 1, 1}, - {&__pyx_kp_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 0}, - {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1}, - {&__pyx_n_s_findall, __pyx_k_findall, sizeof(__pyx_k_findall), 0, 0, 1, 1}, - {&__pyx_n_s_fluxclient_hw_profile, __pyx_k_fluxclient_hw_profile, sizeof(__pyx_k_fluxclient_hw_profile), 0, 0, 1, 1}, - {&__pyx_n_s_fluxclient_utils__utils, __pyx_k_fluxclient_utils__utils, sizeof(__pyx_k_fluxclient_utils__utils), 0, 0, 1, 1}, - {&__pyx_n_s_geometric_error_correction_on, __pyx_k_geometric_error_correction_on, sizeof(__pyx_k_geometric_error_correction_on), 0, 0, 1, 1}, - {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, - {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1}, - {&__pyx_n_s_get_path, __pyx_k_get_path, sizeof(__pyx_k_get_path), 0, 0, 1, 1}, - {&__pyx_n_s_getpass, __pyx_k_getpass, sizeof(__pyx_k_getpass), 0, 0, 1, 1}, - {&__pyx_n_s_getuser, __pyx_k_getuser, sizeof(__pyx_k_getuser), 0, 0, 1, 1}, - {&__pyx_n_s_head_type, __pyx_k_head_type, sizeof(__pyx_k_head_type), 0, 0, 1, 1}, - {&__pyx_n_s_header, __pyx_k_header, sizeof(__pyx_k_header), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1}, - {&__pyx_n_s_input_stream, __pyx_k_input_stream, sizeof(__pyx_k_input_stream), 0, 0, 1, 1}, - {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1}, - {&__pyx_n_s_isdigit, __pyx_k_isdigit, sizeof(__pyx_k_isdigit), 0, 0, 1, 1}, - {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1}, - {&__pyx_n_s_js, __pyx_k_js, sizeof(__pyx_k_js), 0, 0, 1, 1}, - {&__pyx_n_s_localtime, __pyx_k_localtime, sizeof(__pyx_k_localtime), 0, 0, 1, 1}, - {&__pyx_n_s_logger, __pyx_k_logger, sizeof(__pyx_k_logger), 0, 0, 1, 1}, - {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1}, - {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1}, - {&__pyx_n_s_md, __pyx_k_md, sizeof(__pyx_k_md), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1}, - {&__pyx_n_s_output_stream, __pyx_k_output_stream, sizeof(__pyx_k_output_stream), 0, 0, 1, 1}, - {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, - {&__pyx_n_s_path_to_js, __pyx_k_path_to_js, sizeof(__pyx_k_path_to_js), 0, 0, 1, 1}, - {&__pyx_kp_s_path_to_js_origin_called, __pyx_k_path_to_js_origin_called, sizeof(__pyx_k_path_to_js_origin_called), 0, 0, 1, 0}, - {&__pyx_kp_s_path_type, __pyx_k_path_type, sizeof(__pyx_k_path_type), 0, 0, 1, 0}, - {&__pyx_n_s_path_type_2, __pyx_k_path_type_2, sizeof(__pyx_k_path_type_2), 0, 0, 1, 1}, - {&__pyx_n_s_pause_at_layers, __pyx_k_pause_at_layers, sizeof(__pyx_k_pause_at_layers), 0, 0, 1, 1}, - {&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1}, - {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1}, - {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, - {&__pyx_n_s_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 0, 0, 1, 1}, - {&__pyx_n_s_process_locals_lambda, __pyx_k_process_locals_lambda, sizeof(__pyx_k_process_locals_lambda), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, - {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1}, - {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1}, - {&__pyx_n_s_seek, __pyx_k_seek, sizeof(__pyx_k_seek), 0, 0, 1, 1}, - {&__pyx_n_s_sin, __pyx_k_sin, sizeof(__pyx_k_sin), 0, 0, 1, 1}, - {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1}, - {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1}, - {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, - {&__pyx_n_s_stdout, __pyx_k_stdout, sizeof(__pyx_k_stdout), 0, 0, 1, 1}, - {&__pyx_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1}, - {&__pyx_n_s_strftime, __pyx_k_strftime, sizeof(__pyx_k_strftime), 0, 0, 1, 1}, - {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, - {&__pyx_n_s_sub_convert_path, __pyx_k_sub_convert_path, sizeof(__pyx_k_sub_convert_path), 0, 0, 1, 1}, - {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, - {&__pyx_n_s_target, __pyx_k_target, sizeof(__pyx_k_target), 0, 0, 1, 1}, - {&__pyx_n_s_temperature, __pyx_k_temperature, sizeof(__pyx_k_temperature), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_threading, __pyx_k_threading, sizeof(__pyx_k_threading), 0, 0, 1, 1}, - {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1}, - {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_trim_ends, __pyx_k_trim_ends, sizeof(__pyx_k_trim_ends), 0, 0, 1, 1}, - {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, - {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1}, - {&__pyx_kp_s_warning_get_path_of_g2fcpp_funct, __pyx_k_warning_get_path_of_g2fcpp_funct, sizeof(__pyx_k_warning_get_path_of_g2fcpp_funct), 0, 0, 1, 0}, - {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1}, - {&__pyx_n_s_write_metadata, __pyx_k_write_metadata, sizeof(__pyx_k_write_metadata), 0, 0, 1, 1}, - {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, - {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1}, - {&__pyx_n_s_z, __pyx_k_z, sizeof(__pyx_k_z), 0, 0, 1, 1}, - {&__pyx_n_s_z_offset, __pyx_k_z_offset, sizeof(__pyx_k_z_offset), 0, 0, 1, 1}, - {&__pyx_n_s_zlib, __pyx_k_zlib, sizeof(__pyx_k_zlib), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_map = __Pyx_GetBuiltinName(__pyx_n_s_map); if (!__pyx_builtin_map) __PYX_ERR(0, 305, __pyx_L1_error) - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 313, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 14, __pyx_L1_error) - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 116, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "src/utils/utils.pyx":221 - * - * if self.image is None: - * stream.write(struct.pack(' 0 and self.empty_layer[0] == 0: # clean up first empty layer - */ - __pyx_tuple__19 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_2); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 289, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - - /* "src/utils/utils.pyx":320 - * self.md['AUTHOR'] = getuser() # TODO: use fluxstudio user name? - * - * if self.config and self.config.get('geometric_error_correction_on', '0') == '1': # <<<<<<<<<<<<<< - * self.md['BACKLASH'] = 'Y' - * - */ - __pyx_tuple__20 = PyTuple_Pack(2, __pyx_n_s_geometric_error_correction_on, __pyx_kp_s_0); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); - - /* "src/utils/utils.pyx":323 - * self.md['BACKLASH'] = 'Y' - * - * logger.info("[G2FCPP] Finished parsing"); # <<<<<<<<<<<<<< - * self.write_metadata(output_stream, self.md) - * - */ - __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_G2FCPP_Finished_parsing); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 323, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - - /* "src/utils/utils.pyx":329 - * except Exception as e: - * import traceback - * logger.info('G_to_F fail') # <<<<<<<<<<<<<< - * print("[G2FCPP] G2fcpp failed"); - * traceback.print_exc(file=sys.stdout) - */ - __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_G_to_F_fail); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 329, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC init_utils(void); /*proto*/ -PyMODINIT_FUNC init_utils(void) -#else -PyMODINIT_FUNC PyInit__utils(void); /*proto*/ -PyMODINIT_FUNC PyInit__utils(void) -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } - #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__utils(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("_utils", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_fluxclient__utils___utils) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "fluxclient.utils._utils")) { - if (unlikely(PyDict_SetItemString(modules, "fluxclient.utils._utils", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - __pyx_vtabptr_10fluxclient_5utils_6_utils_NativePath = &__pyx_vtable_10fluxclient_5utils_6_utils_NativePath; - __pyx_vtable_10fluxclient_5utils_6_utils_NativePath.setPtr = (void (*)(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *, std::vector > *))__pyx_f_10fluxclient_5utils_6_utils_10NativePath_setPtr; - __pyx_vtable_10fluxclient_5utils_6_utils_NativePath.getPtr = (std::vector > *(*)(struct __pyx_obj_10fluxclient_5utils_6_utils_NativePath *))__pyx_f_10fluxclient_5utils_6_utils_10NativePath_getPtr; - if (PyType_Ready(&__pyx_type_10fluxclient_5utils_6_utils_NativePath) < 0) __PYX_ERR(0, 40, __pyx_L1_error) - __pyx_type_10fluxclient_5utils_6_utils_NativePath.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_10fluxclient_5utils_6_utils_NativePath.tp_dict, __pyx_vtabptr_10fluxclient_5utils_6_utils_NativePath) < 0) __PYX_ERR(0, 40, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "NativePath", (PyObject *)&__pyx_type_10fluxclient_5utils_6_utils_NativePath) < 0) __PYX_ERR(0, 40, __pyx_L1_error) - __pyx_ptype_10fluxclient_5utils_6_utils_NativePath = &__pyx_type_10fluxclient_5utils_6_utils_NativePath; - __pyx_vtabptr_10fluxclient_5utils_6_utils_Tools = &__pyx_vtable_10fluxclient_5utils_6_utils_Tools; - __pyx_vtable_10fluxclient_5utils_6_utils_Tools.path_to_js = (PyObject *(*)(struct __pyx_obj_10fluxclient_5utils_6_utils_Tools *, PyObject *, int __pyx_skip_dispatch))__pyx_f_10fluxclient_5utils_6_utils_5Tools_path_to_js; - if (PyType_Ready(&__pyx_type_10fluxclient_5utils_6_utils_Tools) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - __pyx_type_10fluxclient_5utils_6_utils_Tools.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_10fluxclient_5utils_6_utils_Tools.tp_dict, __pyx_vtabptr_10fluxclient_5utils_6_utils_Tools) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "Tools", (PyObject *)&__pyx_type_10fluxclient_5utils_6_utils_Tools) < 0) __PYX_ERR(0, 56, __pyx_L1_error) - __pyx_ptype_10fluxclient_5utils_6_utils_Tools = &__pyx_type_10fluxclient_5utils_6_utils_Tools; - __pyx_vtabptr_10fluxclient_5utils_6_utils_GcodeToFcodeCpp = &__pyx_vtable_10fluxclient_5utils_6_utils_GcodeToFcodeCpp; - __pyx_vtable_10fluxclient_5utils_6_utils_GcodeToFcodeCpp.extract_vector = (PyObject *(*)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, PyObject *, int __pyx_skip_dispatch))__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_extract_vector; - __pyx_vtable_10fluxclient_5utils_6_utils_GcodeToFcodeCpp.sub_convert_path = (PyObject *(*)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, int __pyx_skip_dispatch))__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_sub_convert_path; - __pyx_vtable_10fluxclient_5utils_6_utils_GcodeToFcodeCpp.get_path = (PyObject *(*)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, int __pyx_skip_dispatch, struct __pyx_opt_args_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path *__pyx_optional_args))__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_get_path; - __pyx_vtable_10fluxclient_5utils_6_utils_GcodeToFcodeCpp.trim_ends = (PyObject *(*)(struct __pyx_obj_10fluxclient_5utils_6_utils_GcodeToFcodeCpp *, PyObject *, int __pyx_skip_dispatch))__pyx_f_10fluxclient_5utils_6_utils_15GcodeToFcodeCpp_trim_ends; - if (PyType_Ready(&__pyx_type_10fluxclient_5utils_6_utils_GcodeToFcodeCpp) < 0) __PYX_ERR(0, 110, __pyx_L1_error) - __pyx_type_10fluxclient_5utils_6_utils_GcodeToFcodeCpp.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_10fluxclient_5utils_6_utils_GcodeToFcodeCpp.tp_dict, __pyx_vtabptr_10fluxclient_5utils_6_utils_GcodeToFcodeCpp) < 0) __PYX_ERR(0, 110, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "GcodeToFcodeCpp", (PyObject *)&__pyx_type_10fluxclient_5utils_6_utils_GcodeToFcodeCpp) < 0) __PYX_ERR(0, 110, __pyx_L1_error) - __pyx_ptype_10fluxclient_5utils_6_utils_GcodeToFcodeCpp = &__pyx_type_10fluxclient_5utils_6_utils_GcodeToFcodeCpp; - /*--- Type import code ---*/ - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "src/utils/utils.pyx":2 - * # !/usr/bin/env python3 - * import binascii # <<<<<<<<<<<<<< - * import logging - * import struct - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_binascii, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_binascii, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":3 - * # !/usr/bin/env python3 - * import binascii - * import logging # <<<<<<<<<<<<<< - * import struct - * import sys - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":4 - * import binascii - * import logging - * import struct # <<<<<<<<<<<<<< - * import sys - * from zlib import crc32 - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":5 - * import logging - * import struct - * import sys # <<<<<<<<<<<<<< - * from zlib import crc32 - * from math import sqrt, sin, cos, pi, atan2 - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":6 - * import struct - * import sys - * from zlib import crc32 # <<<<<<<<<<<<<< - * from math import sqrt, sin, cos, pi, atan2 - * import time - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_crc32); - __Pyx_GIVEREF(__pyx_n_s_crc32); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_crc32); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_zlib, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_crc32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_crc32, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "src/utils/utils.pyx":7 - * import sys - * from zlib import crc32 - * from math import sqrt, sin, cos, pi, atan2 # <<<<<<<<<<<<<< - * import time - * from re import findall - */ - __pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_sqrt); - __Pyx_GIVEREF(__pyx_n_s_sqrt); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_sqrt); - __Pyx_INCREF(__pyx_n_s_sin); - __Pyx_GIVEREF(__pyx_n_s_sin); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_sin); - __Pyx_INCREF(__pyx_n_s_cos); - __Pyx_GIVEREF(__pyx_n_s_cos); - PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_cos); - __Pyx_INCREF(__pyx_n_s_pi); - __Pyx_GIVEREF(__pyx_n_s_pi); - PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_pi); - __Pyx_INCREF(__pyx_n_s_atan2); - __Pyx_GIVEREF(__pyx_n_s_atan2); - PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_atan2); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_math, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sqrt, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_sin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_sin, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_cos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_cos, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_pi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_pi, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_atan2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_atan2, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":8 - * from zlib import crc32 - * from math import sqrt, sin, cos, pi, atan2 - * import time # <<<<<<<<<<<<<< - * from re import findall - * from getpass import getuser - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_time, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_time, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":9 - * from math import sqrt, sin, cos, pi, atan2 - * import time - * from re import findall # <<<<<<<<<<<<<< - * from getpass import getuser - * from threading import Thread - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_findall); - __Pyx_GIVEREF(__pyx_n_s_findall); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_findall); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_re, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_findall); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_findall, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "src/utils/utils.pyx":10 - * import time - * from re import findall - * from getpass import getuser # <<<<<<<<<<<<<< - * from threading import Thread - * from io import BytesIO, StringIO - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_getuser); - __Pyx_GIVEREF(__pyx_n_s_getuser); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_getuser); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_getpass, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_getuser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_getuser, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":11 - * from re import findall - * from getpass import getuser - * from threading import Thread # <<<<<<<<<<<<<< - * from io import BytesIO, StringIO - * - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_Thread); - __Pyx_GIVEREF(__pyx_n_s_Thread); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Thread); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_threading, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Thread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_Thread, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "src/utils/utils.pyx":12 - * from getpass import getuser - * from threading import Thread - * from io import BytesIO, StringIO # <<<<<<<<<<<<<< - * - * from fluxclient.hw_profile import HW_PROFILE - */ - __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_BytesIO); - __Pyx_GIVEREF(__pyx_n_s_BytesIO); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_BytesIO); - __Pyx_INCREF(__pyx_n_s_StringIO); - __Pyx_GIVEREF(__pyx_n_s_StringIO); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_StringIO); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_io, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BytesIO); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_BytesIO, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_StringIO); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_StringIO, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":14 - * from io import BytesIO, StringIO - * - * from fluxclient.hw_profile import HW_PROFILE # <<<<<<<<<<<<<< - * - * import cython - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_HW_PROFILE); - __Pyx_GIVEREF(__pyx_n_s_HW_PROFILE); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_HW_PROFILE); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_fluxclient_hw_profile, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HW_PROFILE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_HW_PROFILE, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "src/utils/utils.pyx":20 - * from libcpp.string cimport string - * - * from fluxclient.utils._utils import Tools # <<<<<<<<<<<<<< - * from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free - * - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_Tools); - __Pyx_GIVEREF(__pyx_n_s_Tools); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Tools); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_fluxclient_utils__utils, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":23 - * from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free - * - * logger = logging.getLogger(__name__) # <<<<<<<<<<<<<< - * - * cimport libc.stdlib - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_1) < 0) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":130 - * analyze metadata - * """ - * def __init__(self, version=1, head_type="EXTRUDER", ext_metadata={}): # <<<<<<<<<<<<<< - * self.T = None - * - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_k_ = __pyx_t_1; - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - - /* "src/utils/utils.pyx":1 - * # !/usr/bin/env python3 # <<<<<<<<<<<<<< - * import binascii - * import logging - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "carray.to_py":124 - * - * @cname("__Pyx_carray_to_tuple_float") - * cdef inline tuple __Pyx_carray_to_tuple_float(float *v, Py_ssize_t length): # <<<<<<<<<<<<<< - * cdef size_t i - * cdef object value - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init fluxclient.utils._utils", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init fluxclient.utils._utils"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else - return __pyx_m; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* RaiseArgTupleInvalid */ -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* KeywordStringCheck */ -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( - PyObject *kwdict, - const char* function_name, - int kw_allowed) -{ - PyObject* key = 0; - Py_ssize_t pos = 0; -#if CYTHON_COMPILING_IN_PYPY - if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) - goto invalid_keyword; - return 1; -#else - while (PyDict_Next(kwdict, &pos, &key, 0)) { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) - #endif - if (unlikely(!PyUnicode_Check(key))) - goto invalid_keyword_type; - } - if ((!kw_allowed) && unlikely(key)) - goto invalid_keyword; - return 1; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - return 0; -#endif -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif - return 0; -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); -} -#endif // CYTHON_FAST_PYCCALL - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -#include "frameobject.h" -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = PyThreadState_GET(); - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif // CPython < 3.6 -#endif // CYTHON_FAST_PYCALL - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallMethO */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* ExtTypeTest */ - static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(PyObject_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* GetItemInt */ - static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* SetItemInt */ - static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { - int r; - if (!j) return -1; - r = PyObject_SetItem(o, j, v); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, - CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); - if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { - PyObject* old = PyList_GET_ITEM(o, n); - Py_INCREF(v); - PyList_SET_ITEM(o, n, v); - Py_DECREF(old); - return 1; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_ass_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return -1; - PyErr_Clear(); - } - } - return m->sq_ass_item(o, i, v); - } - } -#else -#if CYTHON_COMPILING_IN_PYPY - if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { -#else - if (is_list || PySequence_Check(o)) { -#endif - return PySequence_SetItem(o, i, v); - } -#endif - return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); -} - -/* BytesEquals */ - static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else - if (s1 == s2) { - return (equals == Py_EQ); - } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { - const char *ps1, *ps2; - Py_ssize_t length = PyBytes_GET_SIZE(s1); - if (length != PyBytes_GET_SIZE(s2)) - return (equals == Py_NE); - ps1 = PyBytes_AS_STRING(s1); - ps2 = PyBytes_AS_STRING(s2); - if (ps1[0] != ps2[0]) { - return (equals == Py_NE); - } else if (length == 1) { - return (equals == Py_EQ); - } else { - int result = memcmp(ps1, ps2, (size_t)length); - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -#endif -} - -/* UnicodeEquals */ - static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else -#if PY_MAJOR_VERSION < 3 - PyObject* owned_ref = NULL; -#endif - int s1_is_unicode, s2_is_unicode; - if (s1 == s2) { - goto return_eq; - } - s1_is_unicode = PyUnicode_CheckExact(s1); - s2_is_unicode = PyUnicode_CheckExact(s2); -#if PY_MAJOR_VERSION < 3 - if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { - owned_ref = PyUnicode_FromObject(s2); - if (unlikely(!owned_ref)) - return -1; - s2 = owned_ref; - s2_is_unicode = 1; - } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { - owned_ref = PyUnicode_FromObject(s1); - if (unlikely(!owned_ref)) - return -1; - s1 = owned_ref; - s1_is_unicode = 1; - } else if (((!s2_is_unicode) & (!s1_is_unicode))) { - return __Pyx_PyBytes_Equals(s1, s2, equals); - } -#endif - if (s1_is_unicode & s2_is_unicode) { - Py_ssize_t length; - int kind; - void *data1, *data2; - if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) - return -1; - length = __Pyx_PyUnicode_GET_LENGTH(s1); - if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { - goto return_ne; - } - kind = __Pyx_PyUnicode_KIND(s1); - if (kind != __Pyx_PyUnicode_KIND(s2)) { - goto return_ne; - } - data1 = __Pyx_PyUnicode_DATA(s1); - data2 = __Pyx_PyUnicode_DATA(s2); - if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { - goto return_ne; - } else if (length == 1) { - goto return_eq; - } else { - int result = memcmp(data1, data2, (size_t)(length * kind)); - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & s2_is_unicode) { - goto return_ne; - } else if ((s2 == Py_None) & s1_is_unicode) { - goto return_ne; - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -return_eq: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_EQ); -return_ne: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_NE); -#endif -} - -/* decode_c_bytes */ - static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( - const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { - if (unlikely((start < 0) | (stop < 0))) { - if (start < 0) { - start += length; - if (start < 0) - start = 0; - } - if (stop < 0) - stop += length; - } - if (stop > length) - stop = length; - length = stop - start; - if (unlikely(length <= 0)) - return PyUnicode_FromUnicode(NULL, 0); - cstring += start; - if (decode_func) { - return decode_func(cstring, length, errors); - } else { - return PyUnicode_Decode(cstring, length, encoding, errors); - } -} - -/* StringJoin */ - #if !CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) { - return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL); -} -#endif - -/* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* FetchCommonType */ - static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { - PyObject* fake_module; - PyTypeObject* cached_type = NULL; - fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); - if (!fake_module) return NULL; - Py_INCREF(fake_module); - cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name); - if (cached_type) { - if (!PyType_Check((PyObject*)cached_type)) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s is not a type object", - type->tp_name); - goto bad; - } - if (cached_type->tp_basicsize != type->tp_basicsize) { - PyErr_Format(PyExc_TypeError, - "Shared Cython type %.200s has the wrong size, try recompiling", - type->tp_name); - goto bad; - } - } else { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; - PyErr_Clear(); - if (PyType_Ready(type) < 0) goto bad; - if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0) - goto bad; - Py_INCREF(type); - cached_type = type; - } -done: - Py_DECREF(fake_module); - return cached_type; -bad: - Py_XDECREF(cached_type); - cached_type = NULL; - goto done; -} - -/* CythonFunction */ - static PyObject * -__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) -{ - if (unlikely(op->func_doc == NULL)) { - if (op->func.m_ml->ml_doc) { -#if PY_MAJOR_VERSION >= 3 - op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc); -#else - op->func_doc = PyString_FromString(op->func.m_ml->ml_doc); -#endif - if (unlikely(op->func_doc == NULL)) - return NULL; - } else { - Py_INCREF(Py_None); - return Py_None; - } - } - Py_INCREF(op->func_doc); - return op->func_doc; -} -static int -__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp = op->func_doc; - if (value == NULL) { - value = Py_None; - } - Py_INCREF(value); - op->func_doc = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op) -{ - if (unlikely(op->func_name == NULL)) { -#if PY_MAJOR_VERSION >= 3 - op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name); -#else - op->func_name = PyString_InternFromString(op->func.m_ml->ml_name); -#endif - if (unlikely(op->func_name == NULL)) - return NULL; - } - Py_INCREF(op->func_name); - return op->func_name; -} -static int -__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) { -#else - if (unlikely(value == NULL || !PyString_Check(value))) { -#endif - PyErr_SetString(PyExc_TypeError, - "__name__ must be set to a string object"); - return -1; - } - tmp = op->func_name; - Py_INCREF(value); - op->func_name = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op) -{ - Py_INCREF(op->func_qualname); - return op->func_qualname; -} -static int -__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; -#if PY_MAJOR_VERSION >= 3 - if (unlikely(value == NULL || !PyUnicode_Check(value))) { -#else - if (unlikely(value == NULL || !PyString_Check(value))) { -#endif - PyErr_SetString(PyExc_TypeError, - "__qualname__ must be set to a string object"); - return -1; - } - tmp = op->func_qualname; - Py_INCREF(value); - op->func_qualname = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure) -{ - PyObject *self; - self = m->func_closure; - if (self == NULL) - self = Py_None; - Py_INCREF(self); - return self; -} -static PyObject * -__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op) -{ - if (unlikely(op->func_dict == NULL)) { - op->func_dict = PyDict_New(); - if (unlikely(op->func_dict == NULL)) - return NULL; - } - Py_INCREF(op->func_dict); - return op->func_dict; -} -static int -__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value) -{ - PyObject *tmp; - if (unlikely(value == NULL)) { - PyErr_SetString(PyExc_TypeError, - "function's dictionary may not be deleted"); - return -1; - } - if (unlikely(!PyDict_Check(value))) { - PyErr_SetString(PyExc_TypeError, - "setting function's dictionary to a non-dict"); - return -1; - } - tmp = op->func_dict; - Py_INCREF(value); - op->func_dict = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op) -{ - Py_INCREF(op->func_globals); - return op->func_globals; -} -static PyObject * -__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op) -{ - Py_INCREF(Py_None); - return Py_None; -} -static PyObject * -__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op) -{ - PyObject* result = (op->func_code) ? op->func_code : Py_None; - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { - int result = 0; - PyObject *res = op->defaults_getter((PyObject *) op); - if (unlikely(!res)) - return -1; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - op->defaults_tuple = PyTuple_GET_ITEM(res, 0); - Py_INCREF(op->defaults_tuple); - op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); - Py_INCREF(op->defaults_kwdict); - #else - op->defaults_tuple = PySequence_ITEM(res, 0); - if (unlikely(!op->defaults_tuple)) result = -1; - else { - op->defaults_kwdict = PySequence_ITEM(res, 1); - if (unlikely(!op->defaults_kwdict)) result = -1; - } - #endif - Py_DECREF(res); - return result; -} -static int -__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) { - PyObject* tmp; - if (!value) { - value = Py_None; - } else if (value != Py_None && !PyTuple_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__defaults__ must be set to a tuple object"); - return -1; - } - Py_INCREF(value); - tmp = op->defaults_tuple; - op->defaults_tuple = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) { - PyObject* result = op->defaults_tuple; - if (unlikely(!result)) { - if (op->defaults_getter) { - if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; - result = op->defaults_tuple; - } else { - result = Py_None; - } - } - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) { - PyObject* tmp; - if (!value) { - value = Py_None; - } else if (value != Py_None && !PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__kwdefaults__ must be set to a dict object"); - return -1; - } - Py_INCREF(value); - tmp = op->defaults_kwdict; - op->defaults_kwdict = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) { - PyObject* result = op->defaults_kwdict; - if (unlikely(!result)) { - if (op->defaults_getter) { - if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL; - result = op->defaults_kwdict; - } else { - result = Py_None; - } - } - Py_INCREF(result); - return result; -} -static int -__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) { - PyObject* tmp; - if (!value || value == Py_None) { - value = NULL; - } else if (!PyDict_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "__annotations__ must be set to a dict object"); - return -1; - } - Py_XINCREF(value); - tmp = op->func_annotations; - op->func_annotations = value; - Py_XDECREF(tmp); - return 0; -} -static PyObject * -__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) { - PyObject* result = op->func_annotations; - if (unlikely(!result)) { - result = PyDict_New(); - if (unlikely(!result)) return NULL; - op->func_annotations = result; - } - Py_INCREF(result); - return result; -} -static PyGetSetDef __pyx_CyFunction_getsets[] = { - {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, - {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, - {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, - {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, - {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, - {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0}, - {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, - {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, - {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, - {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, - {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, - {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, - {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, - {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, - {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, - {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, - {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, - {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, - {0, 0, 0, 0, 0} -}; -static PyMemberDef __pyx_CyFunction_members[] = { - {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0}, - {0, 0, 0, 0, 0} -}; -static PyObject * -__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args) -{ -#if PY_MAJOR_VERSION >= 3 - return PyUnicode_FromString(m->func.m_ml->ml_name); -#else - return PyString_FromString(m->func.m_ml->ml_name); -#endif -} -static PyMethodDef __pyx_CyFunction_methods[] = { - {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, - {0, 0, 0, 0} -}; -#if PY_VERSION_HEX < 0x030500A0 -#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) -#else -#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist) -#endif -static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname, - PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { - __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type); - if (op == NULL) - return NULL; - op->flags = flags; - __Pyx_CyFunction_weakreflist(op) = NULL; - op->func.m_ml = ml; - op->func.m_self = (PyObject *) op; - Py_XINCREF(closure); - op->func_closure = closure; - Py_XINCREF(module); - op->func.m_module = module; - op->func_dict = NULL; - op->func_name = NULL; - Py_INCREF(qualname); - op->func_qualname = qualname; - op->func_doc = NULL; - op->func_classobj = NULL; - op->func_globals = globals; - Py_INCREF(op->func_globals); - Py_XINCREF(code); - op->func_code = code; - op->defaults_pyobjects = 0; - op->defaults = NULL; - op->defaults_tuple = NULL; - op->defaults_kwdict = NULL; - op->defaults_getter = NULL; - op->func_annotations = NULL; - PyObject_GC_Track(op); - return (PyObject *) op; -} -static int -__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) -{ - Py_CLEAR(m->func_closure); - Py_CLEAR(m->func.m_module); - Py_CLEAR(m->func_dict); - Py_CLEAR(m->func_name); - Py_CLEAR(m->func_qualname); - Py_CLEAR(m->func_doc); - Py_CLEAR(m->func_globals); - Py_CLEAR(m->func_code); - Py_CLEAR(m->func_classobj); - Py_CLEAR(m->defaults_tuple); - Py_CLEAR(m->defaults_kwdict); - Py_CLEAR(m->func_annotations); - if (m->defaults) { - PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); - int i; - for (i = 0; i < m->defaults_pyobjects; i++) - Py_XDECREF(pydefaults[i]); - PyObject_Free(m->defaults); - m->defaults = NULL; - } - return 0; -} -static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) -{ - PyObject_GC_UnTrack(m); - if (__Pyx_CyFunction_weakreflist(m) != NULL) - PyObject_ClearWeakRefs((PyObject *) m); - __Pyx_CyFunction_clear(m); - PyObject_GC_Del(m); -} -static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) -{ - Py_VISIT(m->func_closure); - Py_VISIT(m->func.m_module); - Py_VISIT(m->func_dict); - Py_VISIT(m->func_name); - Py_VISIT(m->func_qualname); - Py_VISIT(m->func_doc); - Py_VISIT(m->func_globals); - Py_VISIT(m->func_code); - Py_VISIT(m->func_classobj); - Py_VISIT(m->defaults_tuple); - Py_VISIT(m->defaults_kwdict); - if (m->defaults) { - PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); - int i; - for (i = 0; i < m->defaults_pyobjects; i++) - Py_VISIT(pydefaults[i]); - } - return 0; -} -static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type) -{ - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) { - Py_INCREF(func); - return func; - } - if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) { - if (type == NULL) - type = (PyObject *)(Py_TYPE(obj)); - return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type))); - } - if (obj == Py_None) - obj = NULL; - return __Pyx_PyMethod_New(func, obj, type); -} -static PyObject* -__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) -{ -#if PY_MAJOR_VERSION >= 3 - return PyUnicode_FromFormat("", - op->func_qualname, (void *)op); -#else - return PyString_FromFormat("", - PyString_AsString(op->func_qualname), (void *)op); -#endif -} -static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { - PyCFunctionObject* f = (PyCFunctionObject*)func; - PyCFunction meth = f->m_ml->ml_meth; - Py_ssize_t size; - switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { - case METH_VARARGS: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) - return (*meth)(self, arg); - break; - case METH_VARARGS | METH_KEYWORDS: - return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); - case METH_NOARGS: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) { - size = PyTuple_GET_SIZE(arg); - if (likely(size == 0)) - return (*meth)(self, NULL); - PyErr_Format(PyExc_TypeError, - "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - case METH_O: - if (likely(kw == NULL || PyDict_Size(kw) == 0)) { - size = PyTuple_GET_SIZE(arg); - if (likely(size == 1)) { - PyObject *result, *arg0 = PySequence_ITEM(arg, 0); - if (unlikely(!arg0)) return NULL; - result = (*meth)(self, arg0); - Py_DECREF(arg0); - return result; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", - f->m_ml->ml_name, size); - return NULL; - } - break; - default: - PyErr_SetString(PyExc_SystemError, "Bad call flags in " - "__Pyx_CyFunction_Call. METH_OLDARGS is no " - "longer supported!"); - return NULL; - } - PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", - f->m_ml->ml_name); - return NULL; -} -static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); -} -static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { - PyObject *result; - __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; - if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { - Py_ssize_t argc; - PyObject *new_args; - PyObject *self; - argc = PyTuple_GET_SIZE(args); - new_args = PyTuple_GetSlice(args, 1, argc); - if (unlikely(!new_args)) - return NULL; - self = PyTuple_GetItem(args, 0); - if (unlikely(!self)) { - Py_DECREF(new_args); - return NULL; - } - result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); - Py_DECREF(new_args); - } else { - result = __Pyx_CyFunction_Call(func, args, kw); - } - return result; -} -static PyTypeObject __pyx_CyFunctionType_type = { - PyVarObject_HEAD_INIT(0, 0) - "cython_function_or_method", - sizeof(__pyx_CyFunctionObject), - 0, - (destructor) __Pyx_CyFunction_dealloc, - 0, - 0, - 0, -#if PY_MAJOR_VERSION < 3 - 0, -#else - 0, -#endif - (reprfunc) __Pyx_CyFunction_repr, - 0, - 0, - 0, - 0, - __Pyx_CyFunction_CallAsMethod, - 0, - 0, - 0, - 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - 0, - (traverseproc) __Pyx_CyFunction_traverse, - (inquiry) __Pyx_CyFunction_clear, - 0, -#if PY_VERSION_HEX < 0x030500A0 - offsetof(__pyx_CyFunctionObject, func_weakreflist), -#else - offsetof(PyCFunctionObject, m_weakreflist), -#endif - 0, - 0, - __pyx_CyFunction_methods, - __pyx_CyFunction_members, - __pyx_CyFunction_getsets, - 0, - 0, - __Pyx_CyFunction_descr_get, - 0, - offsetof(__pyx_CyFunctionObject, func_dict), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -#if PY_VERSION_HEX >= 0x030400a1 - 0, -#endif -}; -static int __pyx_CyFunction_init(void) { - __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); - if (__pyx_CyFunctionType == NULL) { - return -1; - } - return 0; -} -static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults = PyObject_Malloc(size); - if (!m->defaults) - return PyErr_NoMemory(); - memset(m->defaults, 0, size); - m->defaults_pyobjects = pyobjects; - return m->defaults; -} -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults_tuple = tuple; - Py_INCREF(tuple); -} -static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->defaults_kwdict = dict; - Py_INCREF(dict); -} -static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { - __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; - m->func_annotations = dict; - Py_INCREF(dict); -} - -/* pyobject_as_double */ - static double __Pyx__PyObject_AsDouble(PyObject* obj) { - PyObject* float_value; -#if !CYTHON_USE_TYPE_SLOTS - float_value = PyNumber_Float(obj); if (0) goto bad; -#else - PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number; - if (likely(nb) && likely(nb->nb_float)) { - float_value = nb->nb_float(obj); - if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) { - PyErr_Format(PyExc_TypeError, - "__float__ returned non-float (type %.200s)", - Py_TYPE(float_value)->tp_name); - Py_DECREF(float_value); - goto bad; - } - } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) { -#if PY_MAJOR_VERSION >= 3 - float_value = PyFloat_FromString(obj); -#else - float_value = PyFloat_FromString(obj, 0); -#endif - } else { - PyObject* args = PyTuple_New(1); - if (unlikely(!args)) goto bad; - PyTuple_SET_ITEM(args, 0, obj); - float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0); - PyTuple_SET_ITEM(args, 0, 0); - Py_DECREF(args); - } -#endif - if (likely(float_value)) { - double value = PyFloat_AS_DOUBLE(float_value); - Py_DECREF(float_value); - return value; - } -bad: - return (double)-1; -} - -/* PyIntBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { - if (op1 == op2) { - Py_RETURN_TRUE; - } - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long a = PyInt_AS_LONG(op1); - if (a == b) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a; - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; - } - #if PyLong_SHIFT < 30 && PyLong_SHIFT != 15 - default: return PyLong_Type.tp_richcompare(op1, op2, Py_EQ); - #else - default: Py_RETURN_FALSE; - #endif - } - } - if (a == b) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - if ((double)a == (double)b) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } - } - return PyObject_RichCompare(op1, op2, Py_EQ); -} -#endif - -/* PyObjectCallMethod1 */ - static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { - PyObject *method, *result = NULL; - method = __Pyx_PyObject_GetAttrStr(obj, method_name); - if (unlikely(!method)) goto done; -#if CYTHON_UNPACK_METHODS - if (likely(PyMethod_Check(method))) { - PyObject *self = PyMethod_GET_SELF(method); - if (likely(self)) { - PyObject *args; - PyObject *function = PyMethod_GET_FUNCTION(method); - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {self, arg}; - result = __Pyx_PyFunction_FastCall(function, args, 2); - goto done; - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {self, arg}; - result = __Pyx_PyCFunction_FastCall(function, args, 2); - goto done; - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(self); - PyTuple_SET_ITEM(args, 0, self); - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 1, arg); - Py_INCREF(function); - Py_DECREF(method); method = NULL; - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); - return result; - } - } -#endif - result = __Pyx_PyObject_CallOneArg(method, arg); -done: - Py_XDECREF(method); - return result; -} - -/* pop_index */ - static PyObject* __Pyx__PyObject_PopNewIndex(PyObject* L, PyObject* py_ix) { - PyObject *r; - if (unlikely(!py_ix)) return NULL; - r = __Pyx__PyObject_PopIndex(L, py_ix); - Py_DECREF(py_ix); - return r; -} -static PyObject* __Pyx__PyObject_PopIndex(PyObject* L, PyObject* py_ix) { - return __Pyx_PyObject_CallMethod1(L, __pyx_n_s_pop, py_ix); -} -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static PyObject* __Pyx__PyList_PopIndex(PyObject* L, PyObject* py_ix, Py_ssize_t ix) { - Py_ssize_t size = PyList_GET_SIZE(L); - if (likely(size > (((PyListObject*)L)->allocated >> 1))) { - Py_ssize_t cix = ix; - if (cix < 0) { - cix += size; - } - if (likely(0 <= cix && cix < size)) { - PyObject* v = PyList_GET_ITEM(L, cix); - Py_SIZE(L) -= 1; - size -= 1; - memmove(&PyList_GET_ITEM(L, cix), &PyList_GET_ITEM(L, cix+1), (size_t)(size-cix)*sizeof(PyObject*)); - return v; - } - } - if (py_ix == Py_None) { - return __Pyx__PyObject_PopNewIndex(L, PyInt_FromSsize_t(ix)); - } else { - return __Pyx__PyObject_PopIndex(L, py_ix); - } -} -#endif - -/* SliceTupleAndList */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) { - Py_ssize_t start = *_start, stop = *_stop, length = *_length; - if (start < 0) { - start += length; - if (start < 0) - start = 0; - } - if (stop < 0) - stop += length; - else if (stop > length) - stop = length; - *_length = stop - start; - *_start = start; - *_stop = stop; -} -static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { - PyObject *v; - Py_ssize_t i; - for (i = 0; i < length; i++) { - v = dest[i] = src[i]; - Py_INCREF(v); - } -} -static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice( - PyObject* src, Py_ssize_t start, Py_ssize_t stop) { - PyObject* dest; - Py_ssize_t length = PyList_GET_SIZE(src); - __Pyx_crop_slice(&start, &stop, &length); - if (unlikely(length <= 0)) - return PyList_New(0); - dest = PyList_New(length); - if (unlikely(!dest)) - return NULL; - __Pyx_copy_object_array( - ((PyListObject*)src)->ob_item + start, - ((PyListObject*)dest)->ob_item, - length); - return dest; -} -static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice( - PyObject* src, Py_ssize_t start, Py_ssize_t stop) { - PyObject* dest; - Py_ssize_t length = PyTuple_GET_SIZE(src); - __Pyx_crop_slice(&start, &stop, &length); - if (unlikely(length <= 0)) - return PyTuple_New(0); - dest = PyTuple_New(length); - if (unlikely(!dest)) - return NULL; - __Pyx_copy_object_array( - ((PyTupleObject*)src)->ob_item + start, - ((PyTupleObject*)dest)->ob_item, - length); - return dest; -} -#endif - -/* PyIntBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long x; - long a = PyInt_AS_LONG(op1); - x = (long)((unsigned long)a + b); - if (likely((x^a) >= 0 || (x^b) >= 0)) - return PyInt_FromLong(x); - return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG llb = intval; - PY_LONG_LONG lla, llx; -#endif - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - default: return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - } - x = a + b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla + llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - double result; - PyFPE_START_PROTECT("add", return NULL) - result = ((double)a) + (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); -} -#endif - -/* SaveResetException */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* PyErrExceptionMatches */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) { - PyObject *exc_type = tstate->curexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - return PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetException */ - #if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { -#endif - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - #endif - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_VERSION_HEX < 0x03030000 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* SetVTable */ - static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -/* ImportFrom */ - static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { - PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); - if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); - if (!py_code) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); - } - py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -/* Print */ - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static PyObject *__Pyx_GetStdout(void) { - PyObject *f = PySys_GetObject((char *)"stdout"); - if (!f) { - PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); - } - return f; -} -static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) { - int i; - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) { - PyObject* v; - if (PyFile_SoftSpace(f, 1)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - v = PyTuple_GET_ITEM(arg_tuple, i); - if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) - goto error; - if (PyString_Check(v)) { - char *s = PyString_AsString(v); - Py_ssize_t len = PyString_Size(v); - if (len > 0) { - switch (s[len-1]) { - case ' ': break; - case '\f': case '\r': case '\n': case '\t': case '\v': - PyFile_SoftSpace(f, 0); - break; - default: break; - } - } - } - } - if (newline) { - if (PyFile_WriteString("\n", f) < 0) - goto error; - PyFile_SoftSpace(f, 0); - } - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; -} -#else -static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) { - PyObject* kwargs = 0; - PyObject* result = 0; - PyObject* end_string; - if (unlikely(!__pyx_print)) { - __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print); - if (!__pyx_print) - return -1; - } - if (stream) { - kwargs = PyDict_New(); - if (unlikely(!kwargs)) - return -1; - if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0)) - goto bad; - if (!newline) { - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - goto bad; - if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - goto bad; - } - Py_DECREF(end_string); - } - } else if (!newline) { - if (unlikely(!__pyx_print_kwargs)) { - __pyx_print_kwargs = PyDict_New(); - if (unlikely(!__pyx_print_kwargs)) - return -1; - end_string = PyUnicode_FromStringAndSize(" ", 1); - if (unlikely(!end_string)) - return -1; - if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) { - Py_DECREF(end_string); - return -1; - } - Py_DECREF(end_string); - } - kwargs = __pyx_print_kwargs; - } - result = PyObject_Call(__pyx_print, arg_tuple, kwargs); - if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs)) - Py_DECREF(kwargs); - if (!result) - return -1; - Py_DECREF(result); - return 0; -bad: - if (kwargs != __pyx_print_kwargs) - Py_XDECREF(kwargs); - return -1; -} -#endif - -static PyObject* __pyx_convert__to_py_PathVector(PathVector s) { - PyObject* res; - PyObject* member; - res = PyDict_New(); if (unlikely(!res)) return NULL; - return res; - bad: - Py_XDECREF(member); - Py_DECREF(res); - return NULL; - } - /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) { - const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(unsigned long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(unsigned long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(unsigned long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(unsigned long), - little, !is_unsigned); - } -} - -/* PrintOne */ - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3 -static int __Pyx_PrintOne(PyObject* f, PyObject *o) { - if (!f) { - if (!(f = __Pyx_GetStdout())) - return -1; - } - Py_INCREF(f); - if (PyFile_SoftSpace(f, 0)) { - if (PyFile_WriteString(" ", f) < 0) - goto error; - } - if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0) - goto error; - if (PyFile_WriteString("\n", f) < 0) - goto error; - Py_DECREF(f); - return 0; -error: - Py_DECREF(f); - return -1; - /* the line below is just to avoid C compiler - * warnings about unused functions */ - return __Pyx_Print(f, NULL, 0); -} -#else -static int __Pyx_PrintOne(PyObject* stream, PyObject *o) { - int res; - PyObject* arg_tuple = PyTuple_Pack(1, o); - if (unlikely(!arg_tuple)) - return -1; - res = __Pyx_Print(stream, arg_tuple, 1); - Py_DECREF(arg_tuple); - return res; -} -#endif - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE unsigned long __Pyx_PyInt_As_unsigned_long(PyObject *x) { - const unsigned long neg_one = (unsigned long) -1, const_zero = (unsigned long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(unsigned long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(unsigned long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (unsigned long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (unsigned long) 0; - case 1: __PYX_VERIFY_RETURN_INT(unsigned long, digit, digits[0]) - case 2: - if (8 * sizeof(unsigned long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) >= 2 * PyLong_SHIFT) { - return (unsigned long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) >= 3 * PyLong_SHIFT) { - return (unsigned long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) >= 4 * PyLong_SHIFT) { - return (unsigned long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (unsigned long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(unsigned long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(unsigned long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(unsigned long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(unsigned long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (unsigned long) 0; - case -1: __PYX_VERIFY_RETURN_INT(unsigned long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(unsigned long, digit, +digits[0]) - case -2: - if (8 * sizeof(unsigned long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) - 1 > 2 * PyLong_SHIFT) { - return (unsigned long) (((unsigned long)-1)*(((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(unsigned long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) - 1 > 2 * PyLong_SHIFT) { - return (unsigned long) ((((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(unsigned long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) - 1 > 3 * PyLong_SHIFT) { - return (unsigned long) (((unsigned long)-1)*(((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) - 1 > 3 * PyLong_SHIFT) { - return (unsigned long) ((((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(unsigned long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) - 1 > 4 * PyLong_SHIFT) { - return (unsigned long) (((unsigned long)-1)*(((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(unsigned long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(unsigned long) - 1 > 4 * PyLong_SHIFT) { - return (unsigned long) ((((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(unsigned long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(unsigned long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(unsigned long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(unsigned long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - unsigned long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (unsigned long) -1; - } - } else { - unsigned long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (unsigned long) -1; - val = __Pyx_PyInt_As_unsigned_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to unsigned long"); - return (unsigned long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) { - const size_t neg_one = (size_t) -1, const_zero = (size_t) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(size_t) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (size_t) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (size_t) 0; - case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0]) - case 2: - if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) { - return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) { - return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) { - return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (size_t) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(size_t) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (size_t) 0; - case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(size_t, digit, +digits[0]) - case -2: - if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { - return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) { - return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]))); - } - } - break; - } -#endif - if (sizeof(size_t) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - size_t val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (size_t) -1; - } - } else { - size_t val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (size_t) -1; - val = __Pyx_PyInt_As_size_t(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to size_t"); - return (size_t) -1; -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - return PyErr_WarnEx(NULL, message, 1); - } - return 0; -} - -/* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -#else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -#endif - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) -#else - if (PyLong_Check(x)) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = PyNumber_Long(x); - } - #else - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Long(x); - } - #endif -#else - res = PyNumber_Int(x); -#endif - if (res) { -#if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { -#else - if (!PyLong_Check(res)) { -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(x); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/src/utils/utils.pyx b/src/utils/utils.pyx index b768d01..c5c3046 100644 --- a/src/utils/utils.pyx +++ b/src/utils/utils.pyx @@ -60,12 +60,10 @@ cdef class Tools: cpdef path_to_js(self, path): cdef vector[vector[vector [float]]] origin; cdef NativePath native = NativePath(); - print("path_type "+str(type(path))); if(type(path) is type(native)): native = path return path_to_js_cpp(native.ptr) else: - print("path_to_js origin called") return path_to_js(path) cdef extern from "g2f_module.h": @@ -171,7 +169,6 @@ cdef class GcodeToFcodeCpp: cpdef extract_vector(self, obj): cdef PathVector v = obj - print("{" + str(v.x) + "," + str(v.y) + "}") cpdef sub_convert_path(self): # self.path_js = FcodeBase.path_to_js(self.path) @@ -184,7 +181,6 @@ cdef class GcodeToFcodeCpp: self.G92_delta[2] += z cpdef get_path(self, path_type='js'): - print("warning: get_path of g2fcpp function deprecated") if path_type == 'js': self.T.join() if self.path_js is None: @@ -325,10 +321,7 @@ cdef class GcodeToFcodeCpp: except Exception as e: - import traceback - logger.info('G_to_F fail') - print("[G2FCPP] G2fcpp failed"); - traceback.print_exc(file=sys.stdout) + logger.exception("G_to_F fail") return 'broken' def __dealloc__(self): diff --git a/src/utils/utils_module.cpp b/src/utils/utils_module.cpp index 81920c5..edb92cf 100644 --- a/src/utils/utils_module.cpp +++ b/src/utils/utils_module.cpp @@ -75,6 +75,6 @@ std::string path_to_js_cpp(vector< vector< PathVector > >* path){ } } builder.append("]"); - fprintf(stderr, "path_to_js_cpp end, size = %d\n", builder.length()); + // fprintf(stderr, "path_to_js_cpp end, size = %d\n", builder.length()); return builder.toString(); } diff --git a/tests/toolpath/__init__.py b/tests/toolpath/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/toolpath/test_gcode_tools.py b/tests/toolpath/test_gcode_tools.py new file mode 100644 index 0000000..42db2f2 --- /dev/null +++ b/tests/toolpath/test_gcode_tools.py @@ -0,0 +1,142 @@ + +import unittest +from fluxclient.toolpath import _toolpath + + +class TestGCodeParser(unittest.TestCase): + def setUp(self): + self.proc = _toolpath.PyToolpathProcessor(self.append_command) + self.parser = _toolpath.GCodeParser() + self.parser.set_processor(self.proc) + self.calllist = None + + def append_command(self, cmd, **kw): + if self.calllist: + ccmd, ckw = self.calllist.pop(0) + if ccmd != cmd: + raise AssertionError("%r != %r (Recv=%s, Act=%s)" % ( + cmd, ccmd, kw, ckw)) + self.assertDictContainsSubset(ckw, kw) + else: + raise AssertionError("Recv unexcept command: %r: %s" % (cmd, kw)) + + def test_g0g1(self): + self.calllist = [ + ("moveto", {'flags': 112, 'feedrate': 9000.0, + 'x': 50.5, 'y': 50.0}), + ("append_comment", {'message': "YAHOO"}) + ] + self.parser.parse_command(b"G1F9000 X50.5 Y50 ;YAHOO\n") + self.assertEqual([], self.calllist) + + def test_x2(self): + self.calllist = [ + ("set_toolhead_pwm", {'strength': 0}), + ("append_comment", {'message': "YAHOO"}), + ("set_toolhead_pwm", {'strength': 1}), + ("append_comment", {'message': "YAHOO"}), + ] + self.parser.parse_command(b"X2O0 ;YAHOO\n") + self.parser.parse_command(b"X2O255;YAHOO\n") + self.assertEqual([], self.calllist) + + def test_comment(self): + self.calllist = [ + ("append_comment", {'message': "YAHOO"}), + ] + self.parser.parse_command(b";YAHOO\n") + self.assertEqual([], self.calllist) + + +class TestGCodeWriter(unittest.TestCase): + def setUp(self): + self.proc = _toolpath.GCodeMemoryWriter() + + def test_movement(self): + self.proc.moveto(feedrate=6000, x=128) + self.proc.moveto(x=64) + self.proc.append_comment("DATATA") + self.proc.terminated() + self.assertEqual( + self.proc.get_buffer(), + b'G1 F6000.0000 X128.0000\nG1 X64.0000\n;DATATA\n') + + def test_sleep_2100p(self): + self.proc.sleep(2.1) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'G4 P2100\n') + + def test_sleep_2s(self): + self.proc.sleep(2.0) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'G4 S2\n') + + def test_sleep_1p(self): + self.proc.sleep(0.001) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'G4 P1\n') + + def test_enable_motor(self): + self.proc.enable_motor() + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M17\n') + + def test_disable_motor(self): + self.proc.disable_motor() + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M84\n') + + def test_pause_m25(self): + self.proc.pause(False) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M25\n') + + def test_pause_m226(self): + self.proc.pause(True) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M226\n') + + def test_home(self): + self.proc.home() + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'G28\n') + + def test_set_toolhead_heater_temperature_nowait(self): + self.proc.set_toolhead_heater_temperature(200, False) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M104 S200.0\n') + + def test_set_toolhead_heater_temperature_wait(self): + self.proc.set_toolhead_heater_temperature(200, True) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M109 S200.0\n') + + def test_set_toolhead_fan_speed_0(self): + self.proc.set_toolhead_fan_speed(0) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M107\n') + + def test_set_toolhead_fan_speed_0_01(self): + self.proc.set_toolhead_fan_speed(0.01) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M106 S2\n') + + def test_set_toolhead_fan_speed_1(self): + self.proc.set_toolhead_fan_speed(1.0) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'M106 S255\n') + + def test_set_toolhead_pwm_0(self): + self.proc.set_toolhead_pwm(0) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'X2O0\n') + + def test_set_toolhead_pwm_0_01(self): + self.proc.set_toolhead_pwm(0.01) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'X2O2\n') + + def test_set_toolhead_pwm_1(self): + self.proc.set_toolhead_pwm(1) + self.proc.terminated() + self.assertEqual(self.proc.get_buffer(), b'X2O255\n')