Commits

Dean Hall  committed fd8a287

#187 mainlined directly

  • Participants
  • Parent commits b2dd668

Comments (0)

Files changed (6)

File src/platform/desktop/Makefile

 PM_USR_SOURCES = main.py
 PM_HEAP_SIZE = 0x2000
 PMIMGCREATOR := ../../tools/pmImgCreator.py
+IPM = true
 
 TARGET = main
 SOURCES = $(TARGET).c plat.c $(TARGET)_nat.c $(TARGET)_img.c
 endif
 CFLAGS = -Os -Wall -gstabs -Wstrict-prototypes -Werror -I../../vm $(CDEFS)
 
-%.out : %*_nat.c %*_img.c %.c
-	$(CC) $(CFLAGS) -o $@ $*_nat.c $*_img.c $*.c ../../vm/libpmvm.a
+export CFLAGS IPM HEAP_SIZE PM_LIB_FN
+
 
 .PHONY: all clean
 
-export CFLAGS IPM HEAP_SIZE PM_LIB_FN
-
 all : $(TARGET).out
 
 $(PM_LIB_PATH) : ../../vm/*.c ../../vm/*.h
-	make -C ../../vm IPM=true
+	make -C ../../vm
 
 $(TARGET).out : $(OBJS) $(PM_LIB_PATH)
 	$(CC) -o $@ $(OBJS) $(PM_LIB_PATH)

File src/tests/system/Makefile

 
 # PyMite Configuration
 PLATFORM ?= desktop
-PM_LIB_ROOT = pmvm.$(PLATFORM)
+PM_LIB_ROOT = pmvm_$(PLATFORM)
 PM_LIB_FN = lib$(PM_LIB_ROOT).a
 PM_LIB_PATH = ../../vm/$(PM_LIB_FN)
 PM_USR_SOURCES = $(SOURCES:.c=.py)

File src/tests/system/t187.c

+/*
+ * PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers.
+ * Copyright 2002 Dean Hall.  All rights reserved.
+ * PyMite is offered through one of two licenses: commercial or open-source.
+ * See the LICENSE file at the root of this package for licensing details.
+ */
+
+/**
+ * System Test 187
+ * Remove module-level docstring
+ */
+
+#include "pm.h"
+
+
+extern unsigned char usrlib_img[];
+
+
+int main(void)
+{
+    PmReturn_t retval;
+
+    retval = pm_init(MEMSPACE_PROG, usrlib_img);
+    PM_RETURN_IF_ERROR(retval);
+
+    retval = pm_run((uint8_t *)"t187");
+    return (int)retval;
+}

File src/tests/system/t187.py

+#
+# PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers.
+# Copyright 2002 Dean Hall.  All rights reserved.
+# PyMite is offered through one of two licenses: commercial or open-source.
+# See the LICENSE file at the root of this package for licensing details.
+#
+
+#
+# System Test 187
+# Remove module-level docstring
+#
+"""NOT__NATIVE__
+/* Inserted this so there is a module-level __doc__ string in the code object */
+"""
+
+b = "__doc__" in globals()
+print "__doc__ in globals == ", b
+if b:
+    print "len(__doc__) == ", len(globals()["__doc__"])

File src/tests/unit/Makefile

 
 # PyMite Configuration
 PLATFORM ?= desktop
-PM_LIB_ROOT = pmvm.$(PLATFORM)
+PM_LIB_ROOT = pmvm_$(PLATFORM)
 PM_LIB_FN = lib$(PM_LIB_ROOT).a
 PM_LIB_PATH = ../../vm/$(PM_LIB_FN)
 PM_HEAP_SIZE = 0x2000

File src/tools/pmImgCreator.py

 EX_USAGE = 64
 
 # remove documentation string from const pool
-REMOVE_DOC_STR = 0
+REMOVE_DOC_STR = False
 
 # Pm obj descriptor type constants
 # Must match PmType_e in pm.h
             ## Consts filter
             # if want to remove __doc__ string
             # WARNING: this heuristic is not always accurate
-            elif REMOVE_DOC_STR and co.co_names[0] == "__doc__":
+            elif (REMOVE_DOC_STR and len(co.co_names) > 0
+                  and co.co_names[0] == "__doc__"):
                 consts[0] = None
 
         ## Names filter
         names = list(co.co_names)
+
+        # Remove __doc__ name if requested
+        if REMOVE_DOC_STR and len(names) > 0 and names[0] == "__doc__":
+            names[0] = ''
+
         # if co_name is the module identifier change it to module name
         if co.co_name == MODULE_IDENTIFIER:
             names.append(mn)