def dynload_Tk (): try: Tk_Init return except: pass TKlib = DLL.dllopen ('libtk8.4.so') def DF (name, spec, ret='', blocking=False): print "ADD NAME:", name globals() [name] = TKlib.get ((ret, name, spec), blocking) DF ('Tk_Init', 'i', 'i') DF ('Tk_MainWindow', 'i', 'i') DF ('Tk_GetNumMainWindows', '', 'i')
def __call__(self, func): if not self.callable: self.callable = DLL.Callback(self.argspec) if func: if self.converter: real_func = func def proxy(*args): self.converter(real_func, *args) func = proxy self.callable.set_callback(func) self.glFunc(self.callable.fptr()) else: self.glFunc(0)
def flattened_linked_lst(lnk_lst): output_lst = DLL.DLL() curr_node = lnk_lst._header.next while curr_node.next is not None: if isinstance(curr_node.data, DLL.DLL): temp_lst = flattened_linked_lst(curr_node.data) output_lst._trailer.prior.next, temp_lst._header.next.prior = temp_lst._header.next, output_lst._trailer.prior output_lst._trailer = temp_lst._trailer #temp_node = temp_lst._header.next #while temp_node.next is not None: # output_lst.add_tail(temp_node.data) # temp_node = temp_node.next else: output_lst.add_tail(curr_node.data) curr_node = curr_node.next return output_lst
# in python w/ DLL # # although, in reallity this is tcl.py: we can call # a tcl interpreter from python. The tk part is an # application of this module. Therefore we should allow # this module to be usable without libtk... # import DLL # # dynload libtcl # libtcl = 'tcl8.4' TCLlib = DLL.dllopen ('lib' + libtcl + '.so') def DF (name, spec, ret='', blocking=False): globals() [name] = TCLlib.get ((ret, name, spec), blocking) DF ('Tcl_CreateInterp', '', 'i') DF ('Tcl_Init', 'i', 'i') DF ('Tcl_GetCurrentThread', '', 'i') DF ('Tcl_GetVar2Ex', 'iszi', 'i') DF ('Tcl_GetObjType', 's', 'i') DF ('Tcl_DeleteCommand', 'is') DF ('Tcl_SetVar2', 'isssi', 'i') DF ('Tcl_SetVar', 'issi', 'i') DF ('Tcl_GetObjResult', 'i', 'i') DF ('Tcl_NewStringObj', 'si', 'i') DF ('Tcl_NewBooleanObj', 'i', 'i')
# # zlib from our internally linked libz.a # from _JIT import fptr_wrapper import _zlibfuncs _adler32 = fptr_wrapper ('i', _zlibfuncs.adler32, 'isi') _crc32 = fptr_wrapper ('i', _zlibfuncs.crc32, 'isi') compress2 = fptr_wrapper ('i', _zlibfuncs.compress2, 'sp32sii', True) uncompress = fptr_wrapper ('i', _zlibfuncs.uncompress, 'sp32si', True) del fptr_wrapper, _zlibfuncs else: import DLL # # zlib ABI from system's libz.so # Zlib = DLL.dllopen ('libz.so') def DF (name, spec, ret='', blocking=False, iname=''): globals() [iname or name] = Zlib.get ((ret, name, spec), blocking) DF ('adler32', 'isi', 'i', iname='_adler32') DF ('crc32', 'isi', 'i', iname='_crc32') DF ('compress2', 'sp32sii', 'i', blocking=True) DF ('uncompress', 'sp32si', 'i', blocking=True) del DLL, DF Z_BUF_ERROR = -5 # #
# in python w/ DLL # # although, in reallity this is tcl.py: we can call # a tcl interpreter from python. The tk part is an # application of this module. Therefore we should allow # this module to be usable without libtk... # import DLL # # dynload libtcl # libtcl = 'tcl8.4' TCLlib = DLL.dllopen('lib' + libtcl + '.so') def DF(name, spec, ret='', blocking=False): globals()[name] = TCLlib.get((ret, name, spec), blocking) DF('Tcl_CreateInterp', '', 'i') DF('Tcl_Init', 'i', 'i') DF('Tcl_GetCurrentThread', '', 'i') DF('Tcl_GetVar2Ex', 'iszi', 'i') DF('Tcl_GetObjType', 's', 'i') DF('Tcl_DeleteCommand', 'is') DF('Tcl_SetVar2', 'isssi', 'i') DF('Tcl_SetVar', 'issi', 'i') DF('Tcl_GetObjResult', 'i', 'i')
def flattened_linked_lst(lnk_lst): output_lst = DLL.DLL() curr_node = lnk_lst._header.next while curr_node.next is not None: if isinstance(curr_node.data, DLL.DLL): temp_lst = flattened_linked_lst(curr_node.data) output_lst._trailer.prior.next, temp_lst._header.next.prior = temp_lst._header.next, output_lst._trailer.prior output_lst._trailer = temp_lst._trailer #temp_node = temp_lst._header.next #while temp_node.next is not None: # output_lst.add_tail(temp_node.data) # temp_node = temp_node.next else: output_lst.add_tail(curr_node.data) curr_node = curr_node.next return output_lst if __name__ == '__main__': lnk_lst1 = DLL.DLL() lnk_lst1.add_head(4) elem2 = DLL.DLL() elem3 = DLL.DLL() elem3.add_head(3) elem2.add_head(elem3) elem2.add_head(2) lnk_lst1.add_head(elem2) lnk_lst1.add_head(1) lnk_lst2 = flattened_linked_lst(lnk_lst1) print(lnk_lst1) print(lnk_lst2)
""" #importantdo classes from tkinter import * from interface import Interface from DAL import * from DTO import * from DLL import * tk = Tk() #instanciando classe tkinter e inserindo tamanho a janela tk.geometry('400x300') dal = DAL( ) #instanciando a classe responsavel por criar as prosedures e datasets dto = dto( ) #instanciando a classe que armazena os dados do usuario para tratar dll = DLL() #instanciando a classe que cria a logica SQL mensagem = dll.criar_Tabela( ) #criando a tabela quando carrega o programa, a tabela retorna um aviso, temos que mostrar esse aviso para o usuario na lable criada abaixo do botão inserir novo interface = Interface( tk ) #intanciando classe Interface responsavel por criar os Widgets na tela principal #criando o campos para entrada de dados interface.setLblText( 'Nome') #criando label para identificar entrada nome de usuario dto.setNome( interface.setInput() ) #craindo um textbox para usuario inserir nome, e automaticamente ja passamos o nome para classe DTO salvar a entrada na memoria interface.setLblText( 'Senha') #criando label para identificar entrada de senha do usuario
import sys, os import DLL import GLCONSTS, GLUCONSTS, GLUTCONSTS from GLCONSTS import * from GLUTCONSTS import * from GLUCONSTS import * # we really need __all__ __all__ = GLCONSTS.__all__ + GLUCONSTS.__all__ + GLUTCONSTS.__all__ # for linux, for windows something else here, # like DLL.dllopen ('glut32.DLL') GLUTlib = DLL.dllopen('libglut.so') # def DF(name, spec, ret=''): print "ADD NAME:", name globals()[name] = GLUTlib.get((ret, name, spec)) __all__.append(name) DF('glAccum', 'if') DF('glBegin', 'i') DF('glBitmap', 'iiffffp8') DF('glBlendFunc', 'ii') DF('glCallList', 'i')
import sys, os import DLL import GLCONSTS, GLUCONSTS, GLUTCONSTS from GLCONSTS import * from GLUTCONSTS import * from GLUCONSTS import * # we really need __all__ __all__ = GLCONSTS.__all__ + GLUCONSTS.__all__ + GLUTCONSTS.__all__ # for linux, for windows something else here, # like DLL.dllopen ('glut32.DLL') GLUTlib = DLL.dllopen ('libglut.so') # def DF (name, spec, ret=''): print "ADD NAME:", name globals() [name] = GLUTlib.get ((ret, name, spec)) __all__.append (name) DF ('glAccum', 'if') DF ('glBegin', 'i') DF ('glBitmap', 'iiffffp8') DF ('glBlendFunc', 'ii') DF ('glCallList', 'i') DF ('glCallLists', 'iiv') DF ('glClearColor', 'ffff')
# # static typed, JITted code # # This doesn't give any impressive speedup. But it is good # to check the JITer in the bootstrap. # try: import DLL count_idnt = DLL.CachedLib( 'pyc-jit', """ int count_idnt (const char *s) { int cnt = 0; for (;;) switch (*s++) { case ' ': cnt += 1; break; case '\t': cnt = ((cnt + 8) / 8) * 8; break; default: return cnt; } } """, ['-O3']).get(('i', "count_idnt", 's')) del DLL except: def count_idnt(line): cnt = 0 for i in line: if i == ' ': cnt += 1 elif i == '\t': cnt = ((cnt + 8) / 8) * 8 else: return cnt
# # datetime in py # # based on -complex- datetime.c # # basically, pyRacerz needs datetime.now().seconds # and we go as far as providing this... # # DLL libc.so import DLL, os from array import array from time import strftime Clib = DLL.dllopen ('/lib/libc.so.6') def DF (name, spec, ret='', blocking=False): print "ADD NAME:", name globals() [name] = Clib.get ((ret, name, spec), blocking) DF ('gettimeofday', 'p32', 'i') DF ('gmtime', 'p32', 'i') DF ('localtime', 'p32', 'i') # private classes def struct_access (ns, memb): for i, tm in enumerate (memb): gettm = lambda self, i=i: self.c_array [i] def settm (self, x, i=i):